documentation.d.ts 3.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. /**
  333. * Message to display when a message has been logged too many times
  334. */
  335. static MessageLimitReached: string;
  336. private static _LogCache;
  337. private static _LogLimitOutputs;
  338. /**
  339. * Gets a value indicating the number of loading errors
  340. * @ignorenaming
  341. */
  342. static errorsCount: number;
  343. /**
  344. * Callback called when a new log is added
  345. */
  346. static OnNewCacheEntry: (entry: string) => void;
  347. private static _CheckLimit;
  348. private static _GenerateLimitMessage;
  349. private static _AddLogEntry;
  350. private static _FormatMessage;
  351. private static _LogDisabled;
  352. private static _LogEnabled;
  353. private static _WarnDisabled;
  354. private static _WarnEnabled;
  355. private static _ErrorDisabled;
  356. private static _ErrorEnabled;
  357. /**
  358. * Log a message to the console
  359. */
  360. static Log: (message: string, limit?: number) => void;
  361. /**
  362. * Write a warning message to the console
  363. */
  364. static Warn: (message: string, limit?: number) => void;
  365. /**
  366. * Write an error message to the console
  367. */
  368. static Error: (message: string, limit?: number) => void;
  369. /**
  370. * Gets current log cache (list of logs)
  371. */
  372. static get LogCache(): string;
  373. /**
  374. * Clears the log cache
  375. */
  376. static ClearLogCache(): void;
  377. /**
  378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  379. */
  380. static set LogLevels(level: number);
  381. }
  382. }
  383. declare module BABYLON {
  384. /** @hidden */
  385. export class _TypeStore {
  386. /** @hidden */
  387. static RegisteredTypes: {
  388. [key: string]: Object;
  389. };
  390. /** @hidden */
  391. static GetClass(fqdn: string): any;
  392. }
  393. }
  394. declare module BABYLON {
  395. /**
  396. * Helper to manipulate strings
  397. */
  398. export class StringTools {
  399. /**
  400. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static EndsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  408. * @param str Source string
  409. * @param suffix Suffix to search for in the source string
  410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  411. */
  412. static StartsWith(str: string, suffix: string): boolean;
  413. /**
  414. * Decodes a buffer into a string
  415. * @param buffer The buffer to decode
  416. * @returns The decoded string
  417. */
  418. static Decode(buffer: Uint8Array | Uint16Array): string;
  419. /**
  420. * Encode a buffer to a base64 string
  421. * @param buffer defines the buffer to encode
  422. * @returns the encoded string
  423. */
  424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  425. /**
  426. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  427. * @param num the number to convert and pad
  428. * @param length the expected length of the string
  429. * @returns the padded string
  430. */
  431. static PadNumber(num: number, length: number): string;
  432. }
  433. }
  434. declare module BABYLON {
  435. /**
  436. * Class containing a set of static utilities functions for deep copy.
  437. */
  438. export class DeepCopier {
  439. /**
  440. * Tries to copy an object by duplicating every property
  441. * @param source defines the source object
  442. * @param destination defines the target object
  443. * @param doNotCopyList defines a list of properties to avoid
  444. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  445. */
  446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  447. }
  448. }
  449. declare module BABYLON {
  450. /**
  451. * Class containing a set of static utilities functions for precision date
  452. */
  453. export class PrecisionDate {
  454. /**
  455. * Gets either window.performance.now() if supported or Date.now() else
  456. */
  457. static get Now(): number;
  458. }
  459. }
  460. declare module BABYLON {
  461. /** @hidden */
  462. export class _DevTools {
  463. static WarnImport(name: string): string;
  464. }
  465. }
  466. declare module BABYLON {
  467. /**
  468. * Interface used to define the mechanism to get data from the network
  469. */
  470. export interface IWebRequest {
  471. /**
  472. * Returns client's response url
  473. */
  474. responseURL: string;
  475. /**
  476. * Returns client's status
  477. */
  478. status: number;
  479. /**
  480. * Returns client's status as a text
  481. */
  482. statusText: string;
  483. }
  484. }
  485. declare module BABYLON {
  486. /**
  487. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  488. */
  489. export class WebRequest implements IWebRequest {
  490. private readonly _xhr;
  491. /**
  492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  493. * i.e. when loading files, where the server/service expects an Authorization header
  494. */
  495. static CustomRequestHeaders: {
  496. [key: string]: string;
  497. };
  498. /**
  499. * Add callback functions in this array to update all the requests before they get sent to the network
  500. */
  501. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  502. private _injectCustomRequestHeaders;
  503. /**
  504. * Gets or sets a function to be called when loading progress changes
  505. */
  506. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  507. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  508. /**
  509. * Returns client's state
  510. */
  511. get readyState(): number;
  512. /**
  513. * Returns client's status
  514. */
  515. get status(): number;
  516. /**
  517. * Returns client's status as a text
  518. */
  519. get statusText(): string;
  520. /**
  521. * Returns client's response
  522. */
  523. get response(): any;
  524. /**
  525. * Returns client's response url
  526. */
  527. get responseURL(): string;
  528. /**
  529. * Returns client's response as text
  530. */
  531. get responseText(): string;
  532. /**
  533. * Gets or sets the expected response type
  534. */
  535. get responseType(): XMLHttpRequestResponseType;
  536. set responseType(value: XMLHttpRequestResponseType);
  537. /** @hidden */
  538. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  539. /** @hidden */
  540. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  541. /**
  542. * Cancels any network activity
  543. */
  544. abort(): void;
  545. /**
  546. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  547. * @param body defines an optional request body
  548. */
  549. send(body?: Document | BodyInit | null): void;
  550. /**
  551. * Sets the request method, request URL
  552. * @param method defines the method to use (GET, POST, etc..)
  553. * @param url defines the url to connect with
  554. */
  555. open(method: string, url: string): void;
  556. /**
  557. * Sets the value of a request header.
  558. * @param name The name of the header whose value is to be set
  559. * @param value The value to set as the body of the header
  560. */
  561. setRequestHeader(name: string, value: string): void;
  562. /**
  563. * Get the string containing the text of a particular header's value.
  564. * @param name The name of the header
  565. * @returns The string containing the text of the given header name
  566. */
  567. getResponseHeader(name: string): Nullable<string>;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * File request interface
  573. */
  574. export interface IFileRequest {
  575. /**
  576. * Raised when the request is complete (success or error).
  577. */
  578. onCompleteObservable: Observable<IFileRequest>;
  579. /**
  580. * Aborts the request for a file.
  581. */
  582. abort: () => void;
  583. }
  584. }
  585. declare module BABYLON {
  586. /**
  587. * Define options used to create a render target texture
  588. */
  589. export class RenderTargetCreationOptions {
  590. /**
  591. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  592. */
  593. createMipMaps?: boolean;
  594. /**
  595. * Specifies if mipmaps must be generated
  596. */
  597. generateMipMaps?: boolean;
  598. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  599. generateDepthBuffer?: boolean;
  600. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  601. generateStencilBuffer?: boolean;
  602. /** Defines texture type (int by default) */
  603. type?: number;
  604. /** Defines sampling mode (trilinear by default) */
  605. samplingMode?: number;
  606. /** Defines format (RGBA by default) */
  607. format?: number;
  608. /** Defines sample count (1 by default) */
  609. samples?: number;
  610. }
  611. }
  612. declare module BABYLON {
  613. /** Defines the cross module used constants to avoid circular dependncies */
  614. export class Constants {
  615. /** Defines that alpha blending is disabled */
  616. static readonly ALPHA_DISABLE: number;
  617. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  618. static readonly ALPHA_ADD: number;
  619. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  620. static readonly ALPHA_COMBINE: number;
  621. /** Defines that alpha blending is DEST - SRC * DEST */
  622. static readonly ALPHA_SUBTRACT: number;
  623. /** Defines that alpha blending is SRC * DEST */
  624. static readonly ALPHA_MULTIPLY: number;
  625. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  626. static readonly ALPHA_MAXIMIZED: number;
  627. /** Defines that alpha blending is SRC + DEST */
  628. static readonly ALPHA_ONEONE: number;
  629. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  630. static readonly ALPHA_PREMULTIPLIED: number;
  631. /**
  632. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  633. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  634. */
  635. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  636. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  637. static readonly ALPHA_INTERPOLATE: number;
  638. /**
  639. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  640. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  641. */
  642. static readonly ALPHA_SCREENMODE: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA + DST ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEONE: number;
  648. /**
  649. * Defines that alpha blending is SRC * DST ALPHA + DST
  650. * Alpha will be set to 0
  651. */
  652. static readonly ALPHA_ALPHATOCOLOR: number;
  653. /**
  654. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  655. */
  656. static readonly ALPHA_REVERSEONEMINUS: number;
  657. /**
  658. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  659. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  660. */
  661. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  662. /**
  663. * Defines that alpha blending is SRC + DST
  664. * Alpha will be set to SRC ALPHA
  665. */
  666. static readonly ALPHA_ONEONE_ONEZERO: number;
  667. /**
  668. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  669. * Alpha will be set to DST ALPHA
  670. */
  671. static readonly ALPHA_EXCLUSION: number;
  672. /** Defines that alpha blending equation a SUM */
  673. static readonly ALPHA_EQUATION_ADD: number;
  674. /** Defines that alpha blending equation a SUBSTRACTION */
  675. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  676. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  677. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  678. /** Defines that alpha blending equation a MAX operation */
  679. static readonly ALPHA_EQUATION_MAX: number;
  680. /** Defines that alpha blending equation a MIN operation */
  681. static readonly ALPHA_EQUATION_MIN: number;
  682. /**
  683. * Defines that alpha blending equation a DARKEN operation:
  684. * It takes the min of the src and sums the alpha channels.
  685. */
  686. static readonly ALPHA_EQUATION_DARKEN: number;
  687. /** Defines that the ressource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the ressource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the ressource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the ressource is delayed and has not started loading */
  694. static readonly DELAYLOADSTATE_NOTLOADED: number;
  695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  696. static readonly NEVER: number;
  697. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  698. static readonly ALWAYS: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  700. static readonly LESS: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  702. static readonly EQUAL: number;
  703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  704. static readonly LEQUAL: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  706. static readonly GREATER: number;
  707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  708. static readonly GEQUAL: number;
  709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  710. static readonly NOTEQUAL: number;
  711. /** Passed to stencilOperation to specify that stencil value must be kept */
  712. static readonly KEEP: number;
  713. /** Passed to stencilOperation to specify that stencil value must be zero */
  714. static readonly ZERO: number;
  715. /** Passed to stencilOperation to specify that stencil value must be replaced */
  716. static readonly REPLACE: number;
  717. /** Passed to stencilOperation to specify that stencil value must be incremented */
  718. static readonly INCR: number;
  719. /** Passed to stencilOperation to specify that stencil value must be decremented */
  720. static readonly DECR: number;
  721. /** Passed to stencilOperation to specify that stencil value must be inverted */
  722. static readonly INVERT: number;
  723. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  724. static readonly INCR_WRAP: number;
  725. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  726. static readonly DECR_WRAP: number;
  727. /** Texture is not repeating outside of 0..1 UVs */
  728. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  729. /** Texture is repeating outside of 0..1 UVs */
  730. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  731. /** Texture is repeating and mirrored */
  732. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  733. /** ALPHA */
  734. static readonly TEXTUREFORMAT_ALPHA: number;
  735. /** LUMINANCE */
  736. static readonly TEXTUREFORMAT_LUMINANCE: number;
  737. /** LUMINANCE_ALPHA */
  738. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  739. /** RGB */
  740. static readonly TEXTUREFORMAT_RGB: number;
  741. /** RGBA */
  742. static readonly TEXTUREFORMAT_RGBA: number;
  743. /** RED */
  744. static readonly TEXTUREFORMAT_RED: number;
  745. /** RED (2nd reference) */
  746. static readonly TEXTUREFORMAT_R: number;
  747. /** RG */
  748. static readonly TEXTUREFORMAT_RG: number;
  749. /** RED_INTEGER */
  750. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  751. /** RED_INTEGER (2nd reference) */
  752. static readonly TEXTUREFORMAT_R_INTEGER: number;
  753. /** RG_INTEGER */
  754. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  755. /** RGB_INTEGER */
  756. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  757. /** RGBA_INTEGER */
  758. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  759. /** BGRA */
  760. static readonly TEXTUREFORMAT_BGRA: number;
  761. /** Depth 24 bits + Stencil 8 bits */
  762. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  763. /** Depth 32 bits float */
  764. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  765. /** Compressed BC7 */
  766. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  767. /** Compressed BC6 unsigned float */
  768. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  769. /** Compressed BC6 signed float */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  771. /** Compressed BC3 */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  773. /** Compressed BC2 */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  775. /** Compressed BC1 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  777. /** UNSIGNED_BYTE */
  778. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  779. /** UNSIGNED_BYTE (2nd reference) */
  780. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  781. /** FLOAT */
  782. static readonly TEXTURETYPE_FLOAT: number;
  783. /** HALF_FLOAT */
  784. static readonly TEXTURETYPE_HALF_FLOAT: number;
  785. /** BYTE */
  786. static readonly TEXTURETYPE_BYTE: number;
  787. /** SHORT */
  788. static readonly TEXTURETYPE_SHORT: number;
  789. /** UNSIGNED_SHORT */
  790. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  791. /** INT */
  792. static readonly TEXTURETYPE_INT: number;
  793. /** UNSIGNED_INT */
  794. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  795. /** UNSIGNED_SHORT_4_4_4_4 */
  796. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  797. /** UNSIGNED_SHORT_5_5_5_1 */
  798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  799. /** UNSIGNED_SHORT_5_6_5 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  801. /** UNSIGNED_INT_2_10_10_10_REV */
  802. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  803. /** UNSIGNED_INT_24_8 */
  804. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  805. /** UNSIGNED_INT_10F_11F_11F_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  807. /** UNSIGNED_INT_5_9_9_9_REV */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  809. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  810. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  811. /** nearest is mag = nearest and min = nearest and no mip */
  812. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  813. /** mag = nearest and min = nearest and mip = none */
  814. static readonly TEXTURE_NEAREST_NEAREST: number;
  815. /** Bilinear is mag = linear and min = linear and no mip */
  816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  817. /** mag = linear and min = linear and mip = none */
  818. static readonly TEXTURE_LINEAR_LINEAR: number;
  819. /** Trilinear is mag = linear and min = linear and mip = linear */
  820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  821. /** Trilinear is mag = linear and min = linear and mip = linear */
  822. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  823. /** mag = nearest and min = nearest and mip = nearest */
  824. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  825. /** mag = nearest and min = linear and mip = nearest */
  826. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  827. /** mag = nearest and min = linear and mip = linear */
  828. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  829. /** mag = nearest and min = linear and mip = none */
  830. static readonly TEXTURE_NEAREST_LINEAR: number;
  831. /** nearest is mag = nearest and min = nearest and mip = linear */
  832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  833. /** mag = linear and min = nearest and mip = nearest */
  834. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  835. /** mag = linear and min = nearest and mip = linear */
  836. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = none */
  840. static readonly TEXTURE_LINEAR_NEAREST: number;
  841. /** Explicit coordinates mode */
  842. static readonly TEXTURE_EXPLICIT_MODE: number;
  843. /** Spherical coordinates mode */
  844. static readonly TEXTURE_SPHERICAL_MODE: number;
  845. /** Planar coordinates mode */
  846. static readonly TEXTURE_PLANAR_MODE: number;
  847. /** Cubic coordinates mode */
  848. static readonly TEXTURE_CUBIC_MODE: number;
  849. /** Projection coordinates mode */
  850. static readonly TEXTURE_PROJECTION_MODE: number;
  851. /** Skybox coordinates mode */
  852. static readonly TEXTURE_SKYBOX_MODE: number;
  853. /** Inverse Cubic coordinates mode */
  854. static readonly TEXTURE_INVCUBIC_MODE: number;
  855. /** Equirectangular coordinates mode */
  856. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  857. /** Equirectangular Fixed coordinates mode */
  858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  859. /** Equirectangular Fixed Mirrored coordinates mode */
  860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  861. /** Offline (baking) quality for texture filtering */
  862. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  863. /** High quality for texture filtering */
  864. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  865. /** Medium quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  867. /** Low quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  870. static readonly SCALEMODE_FLOOR: number;
  871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  872. static readonly SCALEMODE_NEAREST: number;
  873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  874. static readonly SCALEMODE_CEILING: number;
  875. /**
  876. * The dirty texture flag value
  877. */
  878. static readonly MATERIAL_TextureDirtyFlag: number;
  879. /**
  880. * The dirty light flag value
  881. */
  882. static readonly MATERIAL_LightDirtyFlag: number;
  883. /**
  884. * The dirty fresnel flag value
  885. */
  886. static readonly MATERIAL_FresnelDirtyFlag: number;
  887. /**
  888. * The dirty attribute flag value
  889. */
  890. static readonly MATERIAL_AttributesDirtyFlag: number;
  891. /**
  892. * The dirty misc flag value
  893. */
  894. static readonly MATERIAL_MiscDirtyFlag: number;
  895. /**
  896. * The dirty prepass flag value
  897. */
  898. static readonly MATERIAL_PrePassDirtyFlag: number;
  899. /**
  900. * The all dirty flag value
  901. */
  902. static readonly MATERIAL_AllDirtyFlag: number;
  903. /**
  904. * Returns the triangle fill mode
  905. */
  906. static readonly MATERIAL_TriangleFillMode: number;
  907. /**
  908. * Returns the wireframe mode
  909. */
  910. static readonly MATERIAL_WireFrameFillMode: number;
  911. /**
  912. * Returns the point fill mode
  913. */
  914. static readonly MATERIAL_PointFillMode: number;
  915. /**
  916. * Returns the point list draw mode
  917. */
  918. static readonly MATERIAL_PointListDrawMode: number;
  919. /**
  920. * Returns the line list draw mode
  921. */
  922. static readonly MATERIAL_LineListDrawMode: number;
  923. /**
  924. * Returns the line loop draw mode
  925. */
  926. static readonly MATERIAL_LineLoopDrawMode: number;
  927. /**
  928. * Returns the line strip draw mode
  929. */
  930. static readonly MATERIAL_LineStripDrawMode: number;
  931. /**
  932. * Returns the triangle strip draw mode
  933. */
  934. static readonly MATERIAL_TriangleStripDrawMode: number;
  935. /**
  936. * Returns the triangle fan draw mode
  937. */
  938. static readonly MATERIAL_TriangleFanDrawMode: number;
  939. /**
  940. * Stores the clock-wise side orientation
  941. */
  942. static readonly MATERIAL_ClockWiseSideOrientation: number;
  943. /**
  944. * Stores the counter clock-wise side orientation
  945. */
  946. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  947. /**
  948. * Nothing
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_NothingTrigger: number;
  952. /**
  953. * On pick
  954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPickTrigger: number;
  957. /**
  958. * On left pick
  959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnLeftPickTrigger: number;
  962. /**
  963. * On right pick
  964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnRightPickTrigger: number;
  967. /**
  968. * On center pick
  969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnCenterPickTrigger: number;
  972. /**
  973. * On pick down
  974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnPickDownTrigger: number;
  977. /**
  978. * On double pick
  979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnDoublePickTrigger: number;
  982. /**
  983. * On pick up
  984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  985. */
  986. static readonly ACTION_OnPickUpTrigger: number;
  987. /**
  988. * On pick out.
  989. * This trigger will only be raised if you also declared a OnPickDown
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnPickOutTrigger: number;
  993. /**
  994. * On long press
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnLongPressTrigger: number;
  998. /**
  999. * On pointer over
  1000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1001. */
  1002. static readonly ACTION_OnPointerOverTrigger: number;
  1003. /**
  1004. * On pointer out
  1005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1006. */
  1007. static readonly ACTION_OnPointerOutTrigger: number;
  1008. /**
  1009. * On every frame
  1010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1011. */
  1012. static readonly ACTION_OnEveryFrameTrigger: number;
  1013. /**
  1014. * On intersection enter
  1015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1016. */
  1017. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1018. /**
  1019. * On intersection exit
  1020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1021. */
  1022. static readonly ACTION_OnIntersectionExitTrigger: number;
  1023. /**
  1024. * On key down
  1025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1026. */
  1027. static readonly ACTION_OnKeyDownTrigger: number;
  1028. /**
  1029. * On key up
  1030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1031. */
  1032. static readonly ACTION_OnKeyUpTrigger: number;
  1033. /**
  1034. * Billboard mode will only apply to Y axis
  1035. */
  1036. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1037. /**
  1038. * Billboard mode will apply to all axes
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1041. /**
  1042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1045. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1046. * Test order :
  1047. * Is the bounding sphere outside the frustum ?
  1048. * If not, are the bounding box vertices outside the frustum ?
  1049. * It not, then the cullable object is in the frustum.
  1050. */
  1051. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1052. /** Culling strategy : Bounding Sphere Only.
  1053. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1054. * It's also less accurate than the standard because some not visible objects can still be selected.
  1055. * Test : is the bounding sphere outside the frustum ?
  1056. * If not, then the cullable object is in the frustum.
  1057. */
  1058. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1059. /** Culling strategy : Optimistic Inclusion.
  1060. * This in an inclusion test first, then the standard exclusion test.
  1061. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1062. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1063. * Anyway, it's as accurate as the standard strategy.
  1064. * Test :
  1065. * Is the cullable object bounding sphere center in the frustum ?
  1066. * If not, apply the default culling strategy.
  1067. */
  1068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1069. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1070. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1071. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1072. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1073. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1074. * Test :
  1075. * Is the cullable object bounding sphere center in the frustum ?
  1076. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1077. */
  1078. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1079. /**
  1080. * No logging while loading
  1081. */
  1082. static readonly SCENELOADER_NO_LOGGING: number;
  1083. /**
  1084. * Minimal logging while loading
  1085. */
  1086. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1087. /**
  1088. * Summary logging while loading
  1089. */
  1090. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1091. /**
  1092. * Detailled logging while loading
  1093. */
  1094. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1095. /**
  1096. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1097. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1098. */
  1099. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1100. /**
  1101. * Constant used to retrieve the position texture index in the textures array in the prepass
  1102. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1103. */
  1104. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1105. /**
  1106. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1107. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1108. */
  1109. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1110. /**
  1111. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1112. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1113. */
  1114. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1115. /**
  1116. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1117. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1118. */
  1119. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1120. /**
  1121. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve albedo index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1130. /**
  1131. * Prefixes used by the engine for custom effects
  1132. */
  1133. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export interface HardwareTextureWrapper {
  1139. underlyingResource: any;
  1140. set(hardwareTexture: any): void;
  1141. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1142. reset(): void;
  1143. release(): void;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /**
  1148. * This represents the required contract to create a new type of texture loader.
  1149. */
  1150. export interface IInternalTextureLoader {
  1151. /**
  1152. * Defines wether the loader supports cascade loading the different faces.
  1153. */
  1154. supportCascades: boolean;
  1155. /**
  1156. * This returns if the loader support the current file information.
  1157. * @param extension defines the file extension of the file being loaded
  1158. * @param mimeType defines the optional mime type of the file being loaded
  1159. * @returns true if the loader can load the specified file
  1160. */
  1161. canLoad(extension: string, mimeType?: string): boolean;
  1162. /**
  1163. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1164. * @param data contains the texture data
  1165. * @param texture defines the BabylonJS internal texture
  1166. * @param createPolynomials will be true if polynomials have been requested
  1167. * @param onLoad defines the callback to trigger once the texture is ready
  1168. * @param onError defines the callback to trigger in case of error
  1169. * @param options options to be passed to the loader
  1170. */
  1171. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1172. /**
  1173. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1174. * @param data contains the texture data
  1175. * @param texture defines the BabylonJS internal texture
  1176. * @param callback defines the method to call once ready to upload
  1177. * @param options options to be passed to the loader
  1178. */
  1179. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1180. }
  1181. }
  1182. declare module BABYLON {
  1183. /**
  1184. * @hidden
  1185. */
  1186. export interface IColor4Like {
  1187. r: float;
  1188. g: float;
  1189. b: float;
  1190. a: float;
  1191. }
  1192. /**
  1193. * @hidden
  1194. */
  1195. export interface IColor3Like {
  1196. r: float;
  1197. g: float;
  1198. b: float;
  1199. }
  1200. /**
  1201. * @hidden
  1202. */
  1203. export interface IVector4Like {
  1204. x: float;
  1205. y: float;
  1206. z: float;
  1207. w: float;
  1208. }
  1209. /**
  1210. * @hidden
  1211. */
  1212. export interface IVector3Like {
  1213. x: float;
  1214. y: float;
  1215. z: float;
  1216. }
  1217. /**
  1218. * @hidden
  1219. */
  1220. export interface IVector2Like {
  1221. x: float;
  1222. y: float;
  1223. }
  1224. /**
  1225. * @hidden
  1226. */
  1227. export interface IMatrixLike {
  1228. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1229. updateFlag: int;
  1230. }
  1231. /**
  1232. * @hidden
  1233. */
  1234. export interface IViewportLike {
  1235. x: float;
  1236. y: float;
  1237. width: float;
  1238. height: float;
  1239. }
  1240. /**
  1241. * @hidden
  1242. */
  1243. export interface IPlaneLike {
  1244. normal: IVector3Like;
  1245. d: float;
  1246. normalize(): void;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to store and describe the pipeline context associated with an effect
  1252. */
  1253. export interface IPipelineContext {
  1254. /**
  1255. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1256. */
  1257. isAsync: boolean;
  1258. /**
  1259. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1260. */
  1261. isReady: boolean;
  1262. /** @hidden */
  1263. _name?: string;
  1264. /** @hidden */
  1265. _getVertexShaderCode(): string | null;
  1266. /** @hidden */
  1267. _getFragmentShaderCode(): string | null;
  1268. /** @hidden */
  1269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1270. /** @hidden */
  1271. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1272. [key: string]: number;
  1273. }, uniformsNames: string[], uniforms: {
  1274. [key: string]: Nullable<WebGLUniformLocation>;
  1275. }, samplerList: string[], samplers: {
  1276. [key: string]: number;
  1277. }, attributesNames: string[], attributes: number[]): void;
  1278. /** Releases the resources associated with the pipeline. */
  1279. dispose(): void;
  1280. /**
  1281. * Sets an integer value on a uniform variable.
  1282. * @param uniformName Name of the variable.
  1283. * @param value Value to be set.
  1284. */
  1285. setInt(uniformName: string, value: number): void;
  1286. /**
  1287. * Sets an int2 value on a uniform variable.
  1288. * @param uniformName Name of the variable.
  1289. * @param x First int in int2.
  1290. * @param y Second int in int2.
  1291. */
  1292. setInt2(uniformName: string, x: number, y: number): void;
  1293. /**
  1294. * Sets an int3 value on a uniform variable.
  1295. * @param uniformName Name of the variable.
  1296. * @param x First int in int3.
  1297. * @param y Second int in int3.
  1298. * @param z Third int in int3.
  1299. */
  1300. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1301. /**
  1302. * Sets an int4 value on a uniform variable.
  1303. * @param uniformName Name of the variable.
  1304. * @param x First int in int4.
  1305. * @param y Second int in int4.
  1306. * @param z Third int in int4.
  1307. * @param w Fourth int in int4.
  1308. */
  1309. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1310. /**
  1311. * Sets an int array on a uniform variable.
  1312. * @param uniformName Name of the variable.
  1313. * @param array array to be set.
  1314. */
  1315. setIntArray(uniformName: string, array: Int32Array): void;
  1316. /**
  1317. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1318. * @param uniformName Name of the variable.
  1319. * @param array array to be set.
  1320. */
  1321. setIntArray2(uniformName: string, array: Int32Array): void;
  1322. /**
  1323. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1324. * @param uniformName Name of the variable.
  1325. * @param array array to be set.
  1326. */
  1327. setIntArray3(uniformName: string, array: Int32Array): void;
  1328. /**
  1329. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1330. * @param uniformName Name of the variable.
  1331. * @param array array to be set.
  1332. */
  1333. setIntArray4(uniformName: string, array: Int32Array): void;
  1334. /**
  1335. * Sets an array on a uniform variable.
  1336. * @param uniformName Name of the variable.
  1337. * @param array array to be set.
  1338. */
  1339. setArray(uniformName: string, array: number[] | Float32Array): void;
  1340. /**
  1341. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1342. * @param uniformName Name of the variable.
  1343. * @param array array to be set.
  1344. */
  1345. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1346. /**
  1347. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1348. * @param uniformName Name of the variable.
  1349. * @param array array to be set.
  1350. */
  1351. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1352. /**
  1353. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1354. * @param uniformName Name of the variable.
  1355. * @param array array to be set.
  1356. */
  1357. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1358. /**
  1359. * Sets matrices on a uniform variable.
  1360. * @param uniformName Name of the variable.
  1361. * @param matrices matrices to be set.
  1362. */
  1363. setMatrices(uniformName: string, matrices: Float32Array): void;
  1364. /**
  1365. * Sets matrix on a uniform variable.
  1366. * @param uniformName Name of the variable.
  1367. * @param matrix matrix to be set.
  1368. */
  1369. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1370. /**
  1371. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1372. * @param uniformName Name of the variable.
  1373. * @param matrix matrix to be set.
  1374. */
  1375. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1376. /**
  1377. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1378. * @param uniformName Name of the variable.
  1379. * @param matrix matrix to be set.
  1380. */
  1381. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1382. /**
  1383. * Sets a float on a uniform variable.
  1384. * @param uniformName Name of the variable.
  1385. * @param value value to be set.
  1386. */
  1387. setFloat(uniformName: string, value: number): void;
  1388. /**
  1389. * Sets a Vector2 on a uniform variable.
  1390. * @param uniformName Name of the variable.
  1391. * @param vector2 vector2 to be set.
  1392. */
  1393. setVector2(uniformName: string, vector2: IVector2Like): void;
  1394. /**
  1395. * Sets a float2 on a uniform variable.
  1396. * @param uniformName Name of the variable.
  1397. * @param x First float in float2.
  1398. * @param y Second float in float2.
  1399. */
  1400. setFloat2(uniformName: string, x: number, y: number): void;
  1401. /**
  1402. * Sets a Vector3 on a uniform variable.
  1403. * @param uniformName Name of the variable.
  1404. * @param vector3 Value to be set.
  1405. */
  1406. setVector3(uniformName: string, vector3: IVector3Like): void;
  1407. /**
  1408. * Sets a float3 on a uniform variable.
  1409. * @param uniformName Name of the variable.
  1410. * @param x First float in float3.
  1411. * @param y Second float in float3.
  1412. * @param z Third float in float3.
  1413. */
  1414. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1415. /**
  1416. * Sets a Vector4 on a uniform variable.
  1417. * @param uniformName Name of the variable.
  1418. * @param vector4 Value to be set.
  1419. */
  1420. setVector4(uniformName: string, vector4: IVector4Like): void;
  1421. /**
  1422. * Sets a float4 on a uniform variable.
  1423. * @param uniformName Name of the variable.
  1424. * @param x First float in float4.
  1425. * @param y Second float in float4.
  1426. * @param z Third float in float4.
  1427. * @param w Fourth float in float4.
  1428. */
  1429. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1430. /**
  1431. * Sets a Color3 on a uniform variable.
  1432. * @param uniformName Name of the variable.
  1433. * @param color3 Value to be set.
  1434. */
  1435. setColor3(uniformName: string, color3: IColor3Like): void;
  1436. /**
  1437. * Sets a Color4 on a uniform variable.
  1438. * @param uniformName Name of the variable.
  1439. * @param color3 Value to be set.
  1440. * @param alpha Alpha value to be set.
  1441. */
  1442. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1443. /**
  1444. * Sets a Color4 on a uniform variable
  1445. * @param uniformName defines the name of the variable
  1446. * @param color4 defines the value to be set
  1447. */
  1448. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1449. }
  1450. }
  1451. declare module BABYLON {
  1452. /**
  1453. * Class used to store gfx data (like WebGLBuffer)
  1454. */
  1455. export class DataBuffer {
  1456. private static _Counter;
  1457. /**
  1458. * Gets or sets the number of objects referencing this buffer
  1459. */
  1460. references: number;
  1461. /** Gets or sets the size of the underlying buffer */
  1462. capacity: number;
  1463. /**
  1464. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1465. */
  1466. is32Bits: boolean;
  1467. /**
  1468. * Gets the underlying buffer
  1469. */
  1470. get underlyingResource(): any;
  1471. /**
  1472. * Gets the unique id of this buffer
  1473. */
  1474. readonly uniqueId: number;
  1475. /**
  1476. * Constructs the buffer
  1477. */
  1478. constructor();
  1479. }
  1480. }
  1481. declare module BABYLON {
  1482. /** @hidden */
  1483. export interface IShaderProcessor {
  1484. attributeProcessor?: (attribute: string, preProcessors: {
  1485. [key: string]: string;
  1486. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1487. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1488. [key: string]: string;
  1489. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1490. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1491. [key: string]: string;
  1492. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1493. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1494. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1495. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1496. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1497. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1498. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1499. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1500. vertexCode: string;
  1501. fragmentCode: string;
  1502. };
  1503. }
  1504. }
  1505. declare module BABYLON {
  1506. /** @hidden */
  1507. export interface ShaderProcessingContext {
  1508. }
  1509. /** @hidden */
  1510. export interface ProcessingOptions {
  1511. defines: string[];
  1512. indexParameters: any;
  1513. isFragment: boolean;
  1514. shouldUseHighPrecisionShader: boolean;
  1515. supportsUniformBuffers: boolean;
  1516. shadersRepository: string;
  1517. includesShadersStore: {
  1518. [key: string]: string;
  1519. };
  1520. processor: Nullable<IShaderProcessor>;
  1521. version: string;
  1522. platformName: string;
  1523. lookForClosingBracketForUniformBuffer?: boolean;
  1524. processingContext: Nullable<ShaderProcessingContext>;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /** @hidden */
  1529. export class ShaderCodeNode {
  1530. line: string;
  1531. children: ShaderCodeNode[];
  1532. additionalDefineKey?: string;
  1533. additionalDefineValue?: string;
  1534. isValid(preprocessors: {
  1535. [key: string]: string;
  1536. }): boolean;
  1537. process(preprocessors: {
  1538. [key: string]: string;
  1539. }, options: ProcessingOptions): string;
  1540. }
  1541. }
  1542. declare module BABYLON {
  1543. /** @hidden */
  1544. export class ShaderCodeCursor {
  1545. private _lines;
  1546. lineIndex: number;
  1547. get currentLine(): string;
  1548. get canRead(): boolean;
  1549. set lines(value: string[]);
  1550. }
  1551. }
  1552. declare module BABYLON {
  1553. /** @hidden */
  1554. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1555. process(preprocessors: {
  1556. [key: string]: string;
  1557. }, options: ProcessingOptions): string;
  1558. }
  1559. }
  1560. declare module BABYLON {
  1561. /** @hidden */
  1562. export class ShaderDefineExpression {
  1563. isTrue(preprocessors: {
  1564. [key: string]: string;
  1565. }): boolean;
  1566. private static _OperatorPriority;
  1567. private static _Stack;
  1568. static postfixToInfix(postfix: string[]): string;
  1569. static infixToPostfix(infix: string): string[];
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /** @hidden */
  1574. export class ShaderCodeTestNode extends ShaderCodeNode {
  1575. testExpression: ShaderDefineExpression;
  1576. isValid(preprocessors: {
  1577. [key: string]: string;
  1578. }): boolean;
  1579. }
  1580. }
  1581. declare module BABYLON {
  1582. /** @hidden */
  1583. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1584. define: string;
  1585. not: boolean;
  1586. constructor(define: string, not?: boolean);
  1587. isTrue(preprocessors: {
  1588. [key: string]: string;
  1589. }): boolean;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /** @hidden */
  1594. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1595. leftOperand: ShaderDefineExpression;
  1596. rightOperand: ShaderDefineExpression;
  1597. isTrue(preprocessors: {
  1598. [key: string]: string;
  1599. }): boolean;
  1600. }
  1601. }
  1602. declare module BABYLON {
  1603. /** @hidden */
  1604. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1605. leftOperand: ShaderDefineExpression;
  1606. rightOperand: ShaderDefineExpression;
  1607. isTrue(preprocessors: {
  1608. [key: string]: string;
  1609. }): boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /** @hidden */
  1614. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1615. define: string;
  1616. operand: string;
  1617. testValue: string;
  1618. constructor(define: string, operand: string, testValue: string);
  1619. isTrue(preprocessors: {
  1620. [key: string]: string;
  1621. }): boolean;
  1622. }
  1623. }
  1624. declare module BABYLON {
  1625. /**
  1626. * Class used to enable access to offline support
  1627. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1628. */
  1629. export interface IOfflineProvider {
  1630. /**
  1631. * Gets a boolean indicating if scene must be saved in the database
  1632. */
  1633. enableSceneOffline: boolean;
  1634. /**
  1635. * Gets a boolean indicating if textures must be saved in the database
  1636. */
  1637. enableTexturesOffline: boolean;
  1638. /**
  1639. * Open the offline support and make it available
  1640. * @param successCallback defines the callback to call on success
  1641. * @param errorCallback defines the callback to call on error
  1642. */
  1643. open(successCallback: () => void, errorCallback: () => void): void;
  1644. /**
  1645. * Loads an image from the offline support
  1646. * @param url defines the url to load from
  1647. * @param image defines the target DOM image
  1648. */
  1649. loadImage(url: string, image: HTMLImageElement): void;
  1650. /**
  1651. * Loads a file from offline support
  1652. * @param url defines the URL to load from
  1653. * @param sceneLoaded defines a callback to call on success
  1654. * @param progressCallBack defines a callback to call when progress changed
  1655. * @param errorCallback defines a callback to call on error
  1656. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1657. */
  1658. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1659. }
  1660. }
  1661. declare module BABYLON {
  1662. /**
  1663. * Class used to help managing file picking and drag'n'drop
  1664. * File Storage
  1665. */
  1666. export class FilesInputStore {
  1667. /**
  1668. * List of files ready to be loaded
  1669. */
  1670. static FilesToLoad: {
  1671. [key: string]: File;
  1672. };
  1673. }
  1674. }
  1675. declare module BABYLON {
  1676. /**
  1677. * Class used to define a retry strategy when error happens while loading assets
  1678. */
  1679. export class RetryStrategy {
  1680. /**
  1681. * Function used to defines an exponential back off strategy
  1682. * @param maxRetries defines the maximum number of retries (3 by default)
  1683. * @param baseInterval defines the interval between retries
  1684. * @returns the strategy function to use
  1685. */
  1686. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1687. }
  1688. }
  1689. declare module BABYLON {
  1690. /**
  1691. * @ignore
  1692. * Application error to support additional information when loading a file
  1693. */
  1694. export abstract class BaseError extends Error {
  1695. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1696. }
  1697. }
  1698. declare module BABYLON {
  1699. /** @ignore */
  1700. export class LoadFileError extends BaseError {
  1701. request?: WebRequest;
  1702. file?: File;
  1703. /**
  1704. * Creates a new LoadFileError
  1705. * @param message defines the message of the error
  1706. * @param request defines the optional web request
  1707. * @param file defines the optional file
  1708. */
  1709. constructor(message: string, object?: WebRequest | File);
  1710. }
  1711. /** @ignore */
  1712. export class RequestFileError extends BaseError {
  1713. request: WebRequest;
  1714. /**
  1715. * Creates a new LoadFileError
  1716. * @param message defines the message of the error
  1717. * @param request defines the optional web request
  1718. */
  1719. constructor(message: string, request: WebRequest);
  1720. }
  1721. /** @ignore */
  1722. export class ReadFileError extends BaseError {
  1723. file: File;
  1724. /**
  1725. * Creates a new ReadFileError
  1726. * @param message defines the message of the error
  1727. * @param file defines the optional file
  1728. */
  1729. constructor(message: string, file: File);
  1730. }
  1731. /**
  1732. * @hidden
  1733. */
  1734. export class FileTools {
  1735. /**
  1736. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1737. */
  1738. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1739. /**
  1740. * Gets or sets the base URL to use to load assets
  1741. */
  1742. static BaseUrl: string;
  1743. /**
  1744. * Default behaviour for cors in the application.
  1745. * It can be a string if the expected behavior is identical in the entire app.
  1746. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1747. */
  1748. static CorsBehavior: string | ((url: string | string[]) => string);
  1749. /**
  1750. * Gets or sets a function used to pre-process url before using them to load assets
  1751. */
  1752. static PreprocessUrl: (url: string) => string;
  1753. /**
  1754. * Removes unwanted characters from an url
  1755. * @param url defines the url to clean
  1756. * @returns the cleaned url
  1757. */
  1758. private static _CleanUrl;
  1759. /**
  1760. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1761. * @param url define the url we are trying
  1762. * @param element define the dom element where to configure the cors policy
  1763. */
  1764. static SetCorsBehavior(url: string | string[], element: {
  1765. crossOrigin: string | null;
  1766. }): void;
  1767. /**
  1768. * Loads an image as an HTMLImageElement.
  1769. * @param input url string, ArrayBuffer, or Blob to load
  1770. * @param onLoad callback called when the image successfully loads
  1771. * @param onError callback called when the image fails to load
  1772. * @param offlineProvider offline provider for caching
  1773. * @param mimeType optional mime type
  1774. * @returns the HTMLImageElement of the loaded image
  1775. */
  1776. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1777. /**
  1778. * Reads a file from a File object
  1779. * @param file defines the file to load
  1780. * @param onSuccess defines the callback to call when data is loaded
  1781. * @param onProgress defines the callback to call during loading process
  1782. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1783. * @param onError defines the callback to call when an error occurs
  1784. * @returns a file request object
  1785. */
  1786. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1787. /**
  1788. * Loads a file from a url
  1789. * @param url url to load
  1790. * @param onSuccess callback called when the file successfully loads
  1791. * @param onProgress callback called while file is loading (if the server supports this mode)
  1792. * @param offlineProvider defines the offline provider for caching
  1793. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1794. * @param onError callback called when the file fails to load
  1795. * @returns a file request object
  1796. */
  1797. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1798. /**
  1799. * Loads a file
  1800. * @param url url to load
  1801. * @param onSuccess callback called when the file successfully loads
  1802. * @param onProgress callback called while file is loading (if the server supports this mode)
  1803. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1804. * @param onError callback called when the file fails to load
  1805. * @param onOpened callback called when the web request is opened
  1806. * @returns a file request object
  1807. */
  1808. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1809. /**
  1810. * Checks if the loaded document was accessed via `file:`-Protocol.
  1811. * @returns boolean
  1812. */
  1813. static IsFileURL(): boolean;
  1814. }
  1815. }
  1816. declare module BABYLON {
  1817. /** @hidden */
  1818. export class ShaderProcessor {
  1819. static Initialize(options: ProcessingOptions): void;
  1820. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1821. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1822. vertexCode: string;
  1823. fragmentCode: string;
  1824. };
  1825. private static _ProcessPrecision;
  1826. private static _ExtractOperation;
  1827. private static _BuildSubExpression;
  1828. private static _BuildExpression;
  1829. private static _MoveCursorWithinIf;
  1830. private static _MoveCursor;
  1831. private static _EvaluatePreProcessors;
  1832. private static _PreparePreProcessors;
  1833. private static _ProcessShaderConversion;
  1834. private static _ProcessIncludes;
  1835. /**
  1836. * Loads a file from a url
  1837. * @param url url to load
  1838. * @param onSuccess callback called when the file successfully loads
  1839. * @param onProgress callback called while file is loading (if the server supports this mode)
  1840. * @param offlineProvider defines the offline provider for caching
  1841. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1842. * @param onError callback called when the file fails to load
  1843. * @returns a file request object
  1844. * @hidden
  1845. */
  1846. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Interface used to define common properties for effect fallbacks
  1852. */
  1853. export interface IEffectFallbacks {
  1854. /**
  1855. * Removes the defines that should be removed when falling back.
  1856. * @param currentDefines defines the current define statements for the shader.
  1857. * @param effect defines the current effect we try to compile
  1858. * @returns The resulting defines with defines of the current rank removed.
  1859. */
  1860. reduce(currentDefines: string, effect: Effect): string;
  1861. /**
  1862. * Removes the fallback from the bound mesh.
  1863. */
  1864. unBindMesh(): void;
  1865. /**
  1866. * Checks to see if more fallbacks are still availible.
  1867. */
  1868. hasMoreFallbacks: boolean;
  1869. }
  1870. }
  1871. declare module BABYLON {
  1872. /**
  1873. * Interface for the size containing width and height
  1874. */
  1875. export interface ISize {
  1876. /**
  1877. * Width
  1878. */
  1879. width: number;
  1880. /**
  1881. * Heighht
  1882. */
  1883. height: number;
  1884. }
  1885. /**
  1886. * Size containing widht and height
  1887. */
  1888. export class Size implements ISize {
  1889. /**
  1890. * Width
  1891. */
  1892. width: number;
  1893. /**
  1894. * Height
  1895. */
  1896. height: number;
  1897. /**
  1898. * Creates a Size object from the given width and height (floats).
  1899. * @param width width of the new size
  1900. * @param height height of the new size
  1901. */
  1902. constructor(width: number, height: number);
  1903. /**
  1904. * Returns a string with the Size width and height
  1905. * @returns a string with the Size width and height
  1906. */
  1907. toString(): string;
  1908. /**
  1909. * "Size"
  1910. * @returns the string "Size"
  1911. */
  1912. getClassName(): string;
  1913. /**
  1914. * Returns the Size hash code.
  1915. * @returns a hash code for a unique width and height
  1916. */
  1917. getHashCode(): number;
  1918. /**
  1919. * Updates the current size from the given one.
  1920. * @param src the given size
  1921. */
  1922. copyFrom(src: Size): void;
  1923. /**
  1924. * Updates in place the current Size from the given floats.
  1925. * @param width width of the new size
  1926. * @param height height of the new size
  1927. * @returns the updated Size.
  1928. */
  1929. copyFromFloats(width: number, height: number): Size;
  1930. /**
  1931. * Updates in place the current Size from the given floats.
  1932. * @param width width to set
  1933. * @param height height to set
  1934. * @returns the updated Size.
  1935. */
  1936. set(width: number, height: number): Size;
  1937. /**
  1938. * Multiplies the width and height by numbers
  1939. * @param w factor to multiple the width by
  1940. * @param h factor to multiple the height by
  1941. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1942. */
  1943. multiplyByFloats(w: number, h: number): Size;
  1944. /**
  1945. * Clones the size
  1946. * @returns a new Size copied from the given one.
  1947. */
  1948. clone(): Size;
  1949. /**
  1950. * True if the current Size and the given one width and height are strictly equal.
  1951. * @param other the other size to compare against
  1952. * @returns True if the current Size and the given one width and height are strictly equal.
  1953. */
  1954. equals(other: Size): boolean;
  1955. /**
  1956. * The surface of the Size : width * height (float).
  1957. */
  1958. get surface(): number;
  1959. /**
  1960. * Create a new size of zero
  1961. * @returns a new Size set to (0.0, 0.0)
  1962. */
  1963. static Zero(): Size;
  1964. /**
  1965. * Sums the width and height of two sizes
  1966. * @param otherSize size to add to this size
  1967. * @returns a new Size set as the addition result of the current Size and the given one.
  1968. */
  1969. add(otherSize: Size): Size;
  1970. /**
  1971. * Subtracts the width and height of two
  1972. * @param otherSize size to subtract to this size
  1973. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1974. */
  1975. subtract(otherSize: Size): Size;
  1976. /**
  1977. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1978. * @param start starting size to lerp between
  1979. * @param end end size to lerp between
  1980. * @param amount amount to lerp between the start and end values
  1981. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1982. */
  1983. static Lerp(start: Size, end: Size, amount: number): Size;
  1984. }
  1985. }
  1986. declare module BABYLON {
  1987. /**
  1988. * Base class of all the textures in babylon.
  1989. * It groups all the common properties required to work with Thin Engine.
  1990. */
  1991. export class ThinTexture {
  1992. protected _wrapU: number;
  1993. /**
  1994. * | Value | Type | Description |
  1995. * | ----- | ------------------ | ----------- |
  1996. * | 0 | CLAMP_ADDRESSMODE | |
  1997. * | 1 | WRAP_ADDRESSMODE | |
  1998. * | 2 | MIRROR_ADDRESSMODE | |
  1999. */
  2000. get wrapU(): number;
  2001. set wrapU(value: number);
  2002. protected _wrapV: number;
  2003. /**
  2004. * | Value | Type | Description |
  2005. * | ----- | ------------------ | ----------- |
  2006. * | 0 | CLAMP_ADDRESSMODE | |
  2007. * | 1 | WRAP_ADDRESSMODE | |
  2008. * | 2 | MIRROR_ADDRESSMODE | |
  2009. */
  2010. get wrapV(): number;
  2011. set wrapV(value: number);
  2012. /**
  2013. * | Value | Type | Description |
  2014. * | ----- | ------------------ | ----------- |
  2015. * | 0 | CLAMP_ADDRESSMODE | |
  2016. * | 1 | WRAP_ADDRESSMODE | |
  2017. * | 2 | MIRROR_ADDRESSMODE | |
  2018. */
  2019. wrapR: number;
  2020. /**
  2021. * With compliant hardware and browser (supporting anisotropic filtering)
  2022. * this defines the level of anisotropic filtering in the texture.
  2023. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2024. */
  2025. anisotropicFilteringLevel: number;
  2026. /**
  2027. * Define the current state of the loading sequence when in delayed load mode.
  2028. */
  2029. delayLoadState: number;
  2030. /**
  2031. * How a texture is mapped.
  2032. * Unused in thin texture mode.
  2033. */
  2034. get coordinatesMode(): number;
  2035. /**
  2036. * Define if the texture is a cube texture or if false a 2d texture.
  2037. */
  2038. get isCube(): boolean;
  2039. set isCube(value: boolean);
  2040. /**
  2041. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2042. */
  2043. get is3D(): boolean;
  2044. set is3D(value: boolean);
  2045. /**
  2046. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2047. */
  2048. get is2DArray(): boolean;
  2049. set is2DArray(value: boolean);
  2050. /**
  2051. * Get the class name of the texture.
  2052. * @returns "ThinTexture"
  2053. */
  2054. getClassName(): string;
  2055. /** @hidden */
  2056. _texture: Nullable<InternalTexture>;
  2057. protected _engine: Nullable<ThinEngine>;
  2058. private _cachedSize;
  2059. private _cachedBaseSize;
  2060. /**
  2061. * Instantiates a new ThinTexture.
  2062. * Base class of all the textures in babylon.
  2063. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2064. * @param internalTexture Define the internalTexture to wrap
  2065. */
  2066. constructor(internalTexture: Nullable<InternalTexture>);
  2067. /**
  2068. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2069. * @returns true if fully ready
  2070. */
  2071. isReady(): boolean;
  2072. /**
  2073. * Triggers the load sequence in delayed load mode.
  2074. */
  2075. delayLoad(): void;
  2076. /**
  2077. * Get the underlying lower level texture from Babylon.
  2078. * @returns the insternal texture
  2079. */
  2080. getInternalTexture(): Nullable<InternalTexture>;
  2081. /**
  2082. * Get the size of the texture.
  2083. * @returns the texture size.
  2084. */
  2085. getSize(): ISize;
  2086. /**
  2087. * Get the base size of the texture.
  2088. * It can be different from the size if the texture has been resized for POT for instance
  2089. * @returns the base size
  2090. */
  2091. getBaseSize(): ISize;
  2092. /**
  2093. * Update the sampling mode of the texture.
  2094. * Default is Trilinear mode.
  2095. *
  2096. * | Value | Type | Description |
  2097. * | ----- | ------------------ | ----------- |
  2098. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2099. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2100. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2101. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2102. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2103. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2104. * | 7 | NEAREST_LINEAR | |
  2105. * | 8 | NEAREST_NEAREST | |
  2106. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2107. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2108. * | 11 | LINEAR_LINEAR | |
  2109. * | 12 | LINEAR_NEAREST | |
  2110. *
  2111. * > _mag_: magnification filter (close to the viewer)
  2112. * > _min_: minification filter (far from the viewer)
  2113. * > _mip_: filter used between mip map levels
  2114. *@param samplingMode Define the new sampling mode of the texture
  2115. */
  2116. updateSamplingMode(samplingMode: number): void;
  2117. /**
  2118. * Release and destroy the underlying lower level texture aka internalTexture.
  2119. */
  2120. releaseInternalTexture(): void;
  2121. /**
  2122. * Dispose the texture and release its associated resources.
  2123. */
  2124. dispose(): void;
  2125. }
  2126. }
  2127. declare module BABYLON {
  2128. /**
  2129. * Defines an array and its length.
  2130. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  2131. */
  2132. export interface ISmartArrayLike<T> {
  2133. /**
  2134. * The data of the array.
  2135. */
  2136. data: Array<T>;
  2137. /**
  2138. * The active length of the array.
  2139. */
  2140. length: number;
  2141. }
  2142. /**
  2143. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2144. */
  2145. export class SmartArray<T> implements ISmartArrayLike<T> {
  2146. /**
  2147. * The full set of data from the array.
  2148. */
  2149. data: Array<T>;
  2150. /**
  2151. * The active length of the array.
  2152. */
  2153. length: number;
  2154. protected _id: number;
  2155. /**
  2156. * Instantiates a Smart Array.
  2157. * @param capacity defines the default capacity of the array.
  2158. */
  2159. constructor(capacity: number);
  2160. /**
  2161. * Pushes a value at the end of the active data.
  2162. * @param value defines the object to push in the array.
  2163. */
  2164. push(value: T): void;
  2165. /**
  2166. * Iterates over the active data and apply the lambda to them.
  2167. * @param func defines the action to apply on each value.
  2168. */
  2169. forEach(func: (content: T) => void): void;
  2170. /**
  2171. * Sorts the full sets of data.
  2172. * @param compareFn defines the comparison function to apply.
  2173. */
  2174. sort(compareFn: (a: T, b: T) => number): void;
  2175. /**
  2176. * Resets the active data to an empty array.
  2177. */
  2178. reset(): void;
  2179. /**
  2180. * Releases all the data from the array as well as the array.
  2181. */
  2182. dispose(): void;
  2183. /**
  2184. * Concats the active data with a given array.
  2185. * @param array defines the data to concatenate with.
  2186. */
  2187. concat(array: any): void;
  2188. /**
  2189. * Returns the position of a value in the active data.
  2190. * @param value defines the value to find the index for
  2191. * @returns the index if found in the active data otherwise -1
  2192. */
  2193. indexOf(value: T): number;
  2194. /**
  2195. * Returns whether an element is part of the active data.
  2196. * @param value defines the value to look for
  2197. * @returns true if found in the active data otherwise false
  2198. */
  2199. contains(value: T): boolean;
  2200. private static _GlobalId;
  2201. }
  2202. /**
  2203. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2204. * The data in this array can only be present once
  2205. */
  2206. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2207. private _duplicateId;
  2208. /**
  2209. * Pushes a value at the end of the active data.
  2210. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2211. * @param value defines the object to push in the array.
  2212. */
  2213. push(value: T): void;
  2214. /**
  2215. * Pushes a value at the end of the active data.
  2216. * If the data is already present, it won t be added again
  2217. * @param value defines the object to push in the array.
  2218. * @returns true if added false if it was already present
  2219. */
  2220. pushNoDuplicate(value: T): boolean;
  2221. /**
  2222. * Resets the active data to an empty array.
  2223. */
  2224. reset(): void;
  2225. /**
  2226. * Concats the active data with a given array.
  2227. * This ensures no dupplicate will be present in the result.
  2228. * @param array defines the data to concatenate with.
  2229. */
  2230. concatWithNoDuplicate(array: any): void;
  2231. }
  2232. }
  2233. declare module BABYLON {
  2234. /**
  2235. * Class used to evalaute queries containing `and` and `or` operators
  2236. */
  2237. export class AndOrNotEvaluator {
  2238. /**
  2239. * Evaluate a query
  2240. * @param query defines the query to evaluate
  2241. * @param evaluateCallback defines the callback used to filter result
  2242. * @returns true if the query matches
  2243. */
  2244. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2245. private static _HandleParenthesisContent;
  2246. private static _SimplifyNegation;
  2247. }
  2248. }
  2249. declare module BABYLON {
  2250. /**
  2251. * Class used to store custom tags
  2252. */
  2253. export class Tags {
  2254. /**
  2255. * Adds support for tags on the given object
  2256. * @param obj defines the object to use
  2257. */
  2258. static EnableFor(obj: any): void;
  2259. /**
  2260. * Removes tags support
  2261. * @param obj defines the object to use
  2262. */
  2263. static DisableFor(obj: any): void;
  2264. /**
  2265. * Gets a boolean indicating if the given object has tags
  2266. * @param obj defines the object to use
  2267. * @returns a boolean
  2268. */
  2269. static HasTags(obj: any): boolean;
  2270. /**
  2271. * Gets the tags available on a given object
  2272. * @param obj defines the object to use
  2273. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2274. * @returns the tags
  2275. */
  2276. static GetTags(obj: any, asString?: boolean): any;
  2277. /**
  2278. * Adds tags to an object
  2279. * @param obj defines the object to use
  2280. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2281. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2282. */
  2283. static AddTagsTo(obj: any, tagsString: string): void;
  2284. /**
  2285. * @hidden
  2286. */
  2287. static _AddTagTo(obj: any, tag: string): void;
  2288. /**
  2289. * Removes specific tags from a specific object
  2290. * @param obj defines the object to use
  2291. * @param tagsString defines the tags to remove
  2292. */
  2293. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2294. /**
  2295. * @hidden
  2296. */
  2297. static _RemoveTagFrom(obj: any, tag: string): void;
  2298. /**
  2299. * Defines if tags hosted on an object match a given query
  2300. * @param obj defines the object to use
  2301. * @param tagsQuery defines the tag query
  2302. * @returns a boolean
  2303. */
  2304. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2305. }
  2306. }
  2307. declare module BABYLON {
  2308. /**
  2309. * Scalar computation library
  2310. */
  2311. export class Scalar {
  2312. /**
  2313. * Two pi constants convenient for computation.
  2314. */
  2315. static TwoPi: number;
  2316. /**
  2317. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2318. * @param a number
  2319. * @param b number
  2320. * @param epsilon (default = 1.401298E-45)
  2321. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2322. */
  2323. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2324. /**
  2325. * Returns a string : the upper case translation of the number i to hexadecimal.
  2326. * @param i number
  2327. * @returns the upper case translation of the number i to hexadecimal.
  2328. */
  2329. static ToHex(i: number): string;
  2330. /**
  2331. * Returns -1 if value is negative and +1 is value is positive.
  2332. * @param value the value
  2333. * @returns the value itself if it's equal to zero.
  2334. */
  2335. static Sign(value: number): number;
  2336. /**
  2337. * Returns the value itself if it's between min and max.
  2338. * Returns min if the value is lower than min.
  2339. * Returns max if the value is greater than max.
  2340. * @param value the value to clmap
  2341. * @param min the min value to clamp to (default: 0)
  2342. * @param max the max value to clamp to (default: 1)
  2343. * @returns the clamped value
  2344. */
  2345. static Clamp(value: number, min?: number, max?: number): number;
  2346. /**
  2347. * the log2 of value.
  2348. * @param value the value to compute log2 of
  2349. * @returns the log2 of value.
  2350. */
  2351. static Log2(value: number): number;
  2352. /**
  2353. * the floor part of a log2 value.
  2354. * @param value the value to compute log2 of
  2355. * @returns the log2 of value.
  2356. */
  2357. static ILog2(value: number): number;
  2358. /**
  2359. * Loops the value, so that it is never larger than length and never smaller than 0.
  2360. *
  2361. * This is similar to the modulo operator but it works with floating point numbers.
  2362. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2363. * With t = 5 and length = 2.5, the result would be 0.0.
  2364. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2365. * @param value the value
  2366. * @param length the length
  2367. * @returns the looped value
  2368. */
  2369. static Repeat(value: number, length: number): number;
  2370. /**
  2371. * Normalize the value between 0.0 and 1.0 using min and max values
  2372. * @param value value to normalize
  2373. * @param min max to normalize between
  2374. * @param max min to normalize between
  2375. * @returns the normalized value
  2376. */
  2377. static Normalize(value: number, min: number, max: number): number;
  2378. /**
  2379. * Denormalize the value from 0.0 and 1.0 using min and max values
  2380. * @param normalized value to denormalize
  2381. * @param min max to denormalize between
  2382. * @param max min to denormalize between
  2383. * @returns the denormalized value
  2384. */
  2385. static Denormalize(normalized: number, min: number, max: number): number;
  2386. /**
  2387. * Calculates the shortest difference between two given angles given in degrees.
  2388. * @param current current angle in degrees
  2389. * @param target target angle in degrees
  2390. * @returns the delta
  2391. */
  2392. static DeltaAngle(current: number, target: number): number;
  2393. /**
  2394. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2395. * @param tx value
  2396. * @param length length
  2397. * @returns The returned value will move back and forth between 0 and length
  2398. */
  2399. static PingPong(tx: number, length: number): number;
  2400. /**
  2401. * Interpolates between min and max with smoothing at the limits.
  2402. *
  2403. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2404. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2405. * @param from from
  2406. * @param to to
  2407. * @param tx value
  2408. * @returns the smooth stepped value
  2409. */
  2410. static SmoothStep(from: number, to: number, tx: number): number;
  2411. /**
  2412. * Moves a value current towards target.
  2413. *
  2414. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2415. * Negative values of maxDelta pushes the value away from target.
  2416. * @param current current value
  2417. * @param target target value
  2418. * @param maxDelta max distance to move
  2419. * @returns resulting value
  2420. */
  2421. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2422. /**
  2423. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2424. *
  2425. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2426. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2427. * @param current current value
  2428. * @param target target value
  2429. * @param maxDelta max distance to move
  2430. * @returns resulting angle
  2431. */
  2432. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2433. /**
  2434. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2435. * @param start start value
  2436. * @param end target value
  2437. * @param amount amount to lerp between
  2438. * @returns the lerped value
  2439. */
  2440. static Lerp(start: number, end: number, amount: number): number;
  2441. /**
  2442. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2443. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2444. * @param start start value
  2445. * @param end target value
  2446. * @param amount amount to lerp between
  2447. * @returns the lerped value
  2448. */
  2449. static LerpAngle(start: number, end: number, amount: number): number;
  2450. /**
  2451. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2452. * @param a start value
  2453. * @param b target value
  2454. * @param value value between a and b
  2455. * @returns the inverseLerp value
  2456. */
  2457. static InverseLerp(a: number, b: number, value: number): number;
  2458. /**
  2459. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2460. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2461. * @param value1 spline value
  2462. * @param tangent1 spline value
  2463. * @param value2 spline value
  2464. * @param tangent2 spline value
  2465. * @param amount input value
  2466. * @returns hermite result
  2467. */
  2468. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2469. /**
  2470. * Returns a random float number between and min and max values
  2471. * @param min min value of random
  2472. * @param max max value of random
  2473. * @returns random value
  2474. */
  2475. static RandomRange(min: number, max: number): number;
  2476. /**
  2477. * This function returns percentage of a number in a given range.
  2478. *
  2479. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2480. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2481. * @param number to convert to percentage
  2482. * @param min min range
  2483. * @param max max range
  2484. * @returns the percentage
  2485. */
  2486. static RangeToPercent(number: number, min: number, max: number): number;
  2487. /**
  2488. * This function returns number that corresponds to the percentage in a given range.
  2489. *
  2490. * PercentToRange(0.34,0,100) will return 34.
  2491. * @param percent to convert to number
  2492. * @param min min range
  2493. * @param max max range
  2494. * @returns the number
  2495. */
  2496. static PercentToRange(percent: number, min: number, max: number): number;
  2497. /**
  2498. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2499. * @param angle The angle to normalize in radian.
  2500. * @return The converted angle.
  2501. */
  2502. static NormalizeRadians(angle: number): number;
  2503. }
  2504. }
  2505. declare module BABYLON {
  2506. /**
  2507. * Constant used to convert a value to gamma space
  2508. * @ignorenaming
  2509. */
  2510. export const ToGammaSpace: number;
  2511. /**
  2512. * Constant used to convert a value to linear space
  2513. * @ignorenaming
  2514. */
  2515. export const ToLinearSpace = 2.2;
  2516. /**
  2517. * Constant used to define the minimal number value in Babylon.js
  2518. * @ignorenaming
  2519. */
  2520. let Epsilon: number;
  2521. }
  2522. declare module BABYLON {
  2523. /**
  2524. * Class used to represent a viewport on screen
  2525. */
  2526. export class Viewport {
  2527. /** viewport left coordinate */
  2528. x: number;
  2529. /** viewport top coordinate */
  2530. y: number;
  2531. /**viewport width */
  2532. width: number;
  2533. /** viewport height */
  2534. height: number;
  2535. /**
  2536. * Creates a Viewport object located at (x, y) and sized (width, height)
  2537. * @param x defines viewport left coordinate
  2538. * @param y defines viewport top coordinate
  2539. * @param width defines the viewport width
  2540. * @param height defines the viewport height
  2541. */
  2542. constructor(
  2543. /** viewport left coordinate */
  2544. x: number,
  2545. /** viewport top coordinate */
  2546. y: number,
  2547. /**viewport width */
  2548. width: number,
  2549. /** viewport height */
  2550. height: number);
  2551. /**
  2552. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2553. * @param renderWidth defines the rendering width
  2554. * @param renderHeight defines the rendering height
  2555. * @returns a new Viewport
  2556. */
  2557. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2558. /**
  2559. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2560. * @param renderWidth defines the rendering width
  2561. * @param renderHeight defines the rendering height
  2562. * @param ref defines the target viewport
  2563. * @returns the current viewport
  2564. */
  2565. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2566. /**
  2567. * Returns a new Viewport copied from the current one
  2568. * @returns a new Viewport
  2569. */
  2570. clone(): Viewport;
  2571. }
  2572. }
  2573. declare module BABYLON {
  2574. /**
  2575. * Class containing a set of static utilities functions for arrays.
  2576. */
  2577. export class ArrayTools {
  2578. /**
  2579. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2580. * @param size the number of element to construct and put in the array
  2581. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2582. * @returns a new array filled with new objects
  2583. */
  2584. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2585. }
  2586. }
  2587. declare module BABYLON {
  2588. /**
  2589. * Represents a plane by the equation ax + by + cz + d = 0
  2590. */
  2591. export class Plane {
  2592. private static _TmpMatrix;
  2593. /**
  2594. * Normal of the plane (a,b,c)
  2595. */
  2596. normal: Vector3;
  2597. /**
  2598. * d component of the plane
  2599. */
  2600. d: number;
  2601. /**
  2602. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2603. * @param a a component of the plane
  2604. * @param b b component of the plane
  2605. * @param c c component of the plane
  2606. * @param d d component of the plane
  2607. */
  2608. constructor(a: number, b: number, c: number, d: number);
  2609. /**
  2610. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2611. */
  2612. asArray(): number[];
  2613. /**
  2614. * @returns a new plane copied from the current Plane.
  2615. */
  2616. clone(): Plane;
  2617. /**
  2618. * @returns the string "Plane".
  2619. */
  2620. getClassName(): string;
  2621. /**
  2622. * @returns the Plane hash code.
  2623. */
  2624. getHashCode(): number;
  2625. /**
  2626. * Normalize the current Plane in place.
  2627. * @returns the updated Plane.
  2628. */
  2629. normalize(): Plane;
  2630. /**
  2631. * Applies a transformation the plane and returns the result
  2632. * @param transformation the transformation matrix to be applied to the plane
  2633. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2634. */
  2635. transform(transformation: DeepImmutable<Matrix>): Plane;
  2636. /**
  2637. * Compute the dot product between the point and the plane normal
  2638. * @param point point to calculate the dot product with
  2639. * @returns the dot product (float) of the point coordinates and the plane normal.
  2640. */
  2641. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2642. /**
  2643. * Updates the current Plane from the plane defined by the three given points.
  2644. * @param point1 one of the points used to contruct the plane
  2645. * @param point2 one of the points used to contruct the plane
  2646. * @param point3 one of the points used to contruct the plane
  2647. * @returns the updated Plane.
  2648. */
  2649. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2650. /**
  2651. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2652. * Note that for this function to work as expected you should make sure that:
  2653. * - direction and the plane normal are normalized
  2654. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2655. * @param direction the direction to check if the plane is facing
  2656. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2657. * @returns True if the plane is facing the given direction
  2658. */
  2659. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2660. /**
  2661. * Calculates the distance to a point
  2662. * @param point point to calculate distance to
  2663. * @returns the signed distance (float) from the given point to the Plane.
  2664. */
  2665. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2666. /**
  2667. * Creates a plane from an array
  2668. * @param array the array to create a plane from
  2669. * @returns a new Plane from the given array.
  2670. */
  2671. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2672. /**
  2673. * Creates a plane from three points
  2674. * @param point1 point used to create the plane
  2675. * @param point2 point used to create the plane
  2676. * @param point3 point used to create the plane
  2677. * @returns a new Plane defined by the three given points.
  2678. */
  2679. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2680. /**
  2681. * Creates a plane from an origin point and a normal
  2682. * @param origin origin of the plane to be constructed
  2683. * @param normal normal of the plane to be constructed
  2684. * @returns a new Plane the normal vector to this plane at the given origin point.
  2685. * Note : the vector "normal" is updated because normalized.
  2686. */
  2687. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2688. /**
  2689. * Calculates the distance from a plane and a point
  2690. * @param origin origin of the plane to be constructed
  2691. * @param normal normal of the plane to be constructed
  2692. * @param point point to calculate distance to
  2693. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2694. */
  2695. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2696. }
  2697. }
  2698. declare module BABYLON {
  2699. /** @hidden */
  2700. export class PerformanceConfigurator {
  2701. /** @hidden */
  2702. static MatrixUse64Bits: boolean;
  2703. /** @hidden */
  2704. static MatrixTrackPrecisionChange: boolean;
  2705. /** @hidden */
  2706. static MatrixCurrentType: any;
  2707. /** @hidden */
  2708. static MatrixTrackedMatrices: Array<any> | null;
  2709. /** @hidden */
  2710. static SetMatrixPrecision(use64bits: boolean): void;
  2711. }
  2712. }
  2713. declare module BABYLON {
  2714. /**
  2715. * Class representing a vector containing 2 coordinates
  2716. */
  2717. export class Vector2 {
  2718. /** defines the first coordinate */
  2719. x: number;
  2720. /** defines the second coordinate */
  2721. y: number;
  2722. /**
  2723. * Creates a new Vector2 from the given x and y coordinates
  2724. * @param x defines the first coordinate
  2725. * @param y defines the second coordinate
  2726. */
  2727. constructor(
  2728. /** defines the first coordinate */
  2729. x?: number,
  2730. /** defines the second coordinate */
  2731. y?: number);
  2732. /**
  2733. * Gets a string with the Vector2 coordinates
  2734. * @returns a string with the Vector2 coordinates
  2735. */
  2736. toString(): string;
  2737. /**
  2738. * Gets class name
  2739. * @returns the string "Vector2"
  2740. */
  2741. getClassName(): string;
  2742. /**
  2743. * Gets current vector hash code
  2744. * @returns the Vector2 hash code as a number
  2745. */
  2746. getHashCode(): number;
  2747. /**
  2748. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2749. * @param array defines the source array
  2750. * @param index defines the offset in source array
  2751. * @returns the current Vector2
  2752. */
  2753. toArray(array: FloatArray, index?: number): Vector2;
  2754. /**
  2755. * Update the current vector from an array
  2756. * @param array defines the destination array
  2757. * @param index defines the offset in the destination array
  2758. * @returns the current Vector3
  2759. */
  2760. fromArray(array: FloatArray, index?: number): Vector2;
  2761. /**
  2762. * Copy the current vector to an array
  2763. * @returns a new array with 2 elements: the Vector2 coordinates.
  2764. */
  2765. asArray(): number[];
  2766. /**
  2767. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2768. * @param source defines the source Vector2
  2769. * @returns the current updated Vector2
  2770. */
  2771. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2772. /**
  2773. * Sets the Vector2 coordinates with the given floats
  2774. * @param x defines the first coordinate
  2775. * @param y defines the second coordinate
  2776. * @returns the current updated Vector2
  2777. */
  2778. copyFromFloats(x: number, y: number): Vector2;
  2779. /**
  2780. * Sets the Vector2 coordinates with the given floats
  2781. * @param x defines the first coordinate
  2782. * @param y defines the second coordinate
  2783. * @returns the current updated Vector2
  2784. */
  2785. set(x: number, y: number): Vector2;
  2786. /**
  2787. * Add another vector with the current one
  2788. * @param otherVector defines the other vector
  2789. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2790. */
  2791. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2792. /**
  2793. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2794. * @param otherVector defines the other vector
  2795. * @param result defines the target vector
  2796. * @returns the unmodified current Vector2
  2797. */
  2798. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2799. /**
  2800. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2801. * @param otherVector defines the other vector
  2802. * @returns the current updated Vector2
  2803. */
  2804. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2805. /**
  2806. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2807. * @param otherVector defines the other vector
  2808. * @returns a new Vector2
  2809. */
  2810. addVector3(otherVector: Vector3): Vector2;
  2811. /**
  2812. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2813. * @param otherVector defines the other vector
  2814. * @returns a new Vector2
  2815. */
  2816. subtract(otherVector: Vector2): Vector2;
  2817. /**
  2818. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2819. * @param otherVector defines the other vector
  2820. * @param result defines the target vector
  2821. * @returns the unmodified current Vector2
  2822. */
  2823. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2824. /**
  2825. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2826. * @param otherVector defines the other vector
  2827. * @returns the current updated Vector2
  2828. */
  2829. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2830. /**
  2831. * Multiplies in place the current Vector2 coordinates by the given ones
  2832. * @param otherVector defines the other vector
  2833. * @returns the current updated Vector2
  2834. */
  2835. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2836. /**
  2837. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2838. * @param otherVector defines the other vector
  2839. * @returns a new Vector2
  2840. */
  2841. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2842. /**
  2843. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2844. * @param otherVector defines the other vector
  2845. * @param result defines the target vector
  2846. * @returns the unmodified current Vector2
  2847. */
  2848. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2849. /**
  2850. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2851. * @param x defines the first coordinate
  2852. * @param y defines the second coordinate
  2853. * @returns a new Vector2
  2854. */
  2855. multiplyByFloats(x: number, y: number): Vector2;
  2856. /**
  2857. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2858. * @param otherVector defines the other vector
  2859. * @returns a new Vector2
  2860. */
  2861. divide(otherVector: Vector2): Vector2;
  2862. /**
  2863. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2864. * @param otherVector defines the other vector
  2865. * @param result defines the target vector
  2866. * @returns the unmodified current Vector2
  2867. */
  2868. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2869. /**
  2870. * Divides the current Vector2 coordinates by the given ones
  2871. * @param otherVector defines the other vector
  2872. * @returns the current updated Vector2
  2873. */
  2874. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2875. /**
  2876. * Gets a new Vector2 with current Vector2 negated coordinates
  2877. * @returns a new Vector2
  2878. */
  2879. negate(): Vector2;
  2880. /**
  2881. * Negate this vector in place
  2882. * @returns this
  2883. */
  2884. negateInPlace(): Vector2;
  2885. /**
  2886. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2887. * @param result defines the Vector3 object where to store the result
  2888. * @returns the current Vector2
  2889. */
  2890. negateToRef(result: Vector2): Vector2;
  2891. /**
  2892. * Multiply the Vector2 coordinates by scale
  2893. * @param scale defines the scaling factor
  2894. * @returns the current updated Vector2
  2895. */
  2896. scaleInPlace(scale: number): Vector2;
  2897. /**
  2898. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2899. * @param scale defines the scaling factor
  2900. * @returns a new Vector2
  2901. */
  2902. scale(scale: number): Vector2;
  2903. /**
  2904. * Scale the current Vector2 values by a factor to a given Vector2
  2905. * @param scale defines the scale factor
  2906. * @param result defines the Vector2 object where to store the result
  2907. * @returns the unmodified current Vector2
  2908. */
  2909. scaleToRef(scale: number, result: Vector2): Vector2;
  2910. /**
  2911. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2912. * @param scale defines the scale factor
  2913. * @param result defines the Vector2 object where to store the result
  2914. * @returns the unmodified current Vector2
  2915. */
  2916. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2917. /**
  2918. * Gets a boolean if two vectors are equals
  2919. * @param otherVector defines the other vector
  2920. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2921. */
  2922. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2923. /**
  2924. * Gets a boolean if two vectors are equals (using an epsilon value)
  2925. * @param otherVector defines the other vector
  2926. * @param epsilon defines the minimal distance to consider equality
  2927. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2928. */
  2929. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2930. /**
  2931. * Gets a new Vector2 from current Vector2 floored values
  2932. * @returns a new Vector2
  2933. */
  2934. floor(): Vector2;
  2935. /**
  2936. * Gets a new Vector2 from current Vector2 floored values
  2937. * @returns a new Vector2
  2938. */
  2939. fract(): Vector2;
  2940. /**
  2941. * Gets the length of the vector
  2942. * @returns the vector length (float)
  2943. */
  2944. length(): number;
  2945. /**
  2946. * Gets the vector squared length
  2947. * @returns the vector squared length (float)
  2948. */
  2949. lengthSquared(): number;
  2950. /**
  2951. * Normalize the vector
  2952. * @returns the current updated Vector2
  2953. */
  2954. normalize(): Vector2;
  2955. /**
  2956. * Gets a new Vector2 copied from the Vector2
  2957. * @returns a new Vector2
  2958. */
  2959. clone(): Vector2;
  2960. /**
  2961. * Gets a new Vector2(0, 0)
  2962. * @returns a new Vector2
  2963. */
  2964. static Zero(): Vector2;
  2965. /**
  2966. * Gets a new Vector2(1, 1)
  2967. * @returns a new Vector2
  2968. */
  2969. static One(): Vector2;
  2970. /**
  2971. * Gets a new Vector2 set from the given index element of the given array
  2972. * @param array defines the data source
  2973. * @param offset defines the offset in the data source
  2974. * @returns a new Vector2
  2975. */
  2976. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2977. /**
  2978. * Sets "result" from the given index element of the given array
  2979. * @param array defines the data source
  2980. * @param offset defines the offset in the data source
  2981. * @param result defines the target vector
  2982. */
  2983. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2984. /**
  2985. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2986. * @param value1 defines 1st point of control
  2987. * @param value2 defines 2nd point of control
  2988. * @param value3 defines 3rd point of control
  2989. * @param value4 defines 4th point of control
  2990. * @param amount defines the interpolation factor
  2991. * @returns a new Vector2
  2992. */
  2993. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2994. /**
  2995. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2996. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2997. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2998. * @param value defines the value to clamp
  2999. * @param min defines the lower limit
  3000. * @param max defines the upper limit
  3001. * @returns a new Vector2
  3002. */
  3003. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3004. /**
  3005. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3006. * @param value1 defines the 1st control point
  3007. * @param tangent1 defines the outgoing tangent
  3008. * @param value2 defines the 2nd control point
  3009. * @param tangent2 defines the incoming tangent
  3010. * @param amount defines the interpolation factor
  3011. * @returns a new Vector2
  3012. */
  3013. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3014. /**
  3015. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3016. * @param start defines the start vector
  3017. * @param end defines the end vector
  3018. * @param amount defines the interpolation factor
  3019. * @returns a new Vector2
  3020. */
  3021. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3022. /**
  3023. * Gets the dot product of the vector "left" and the vector "right"
  3024. * @param left defines first vector
  3025. * @param right defines second vector
  3026. * @returns the dot product (float)
  3027. */
  3028. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3029. /**
  3030. * Returns a new Vector2 equal to the normalized given vector
  3031. * @param vector defines the vector to normalize
  3032. * @returns a new Vector2
  3033. */
  3034. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3035. /**
  3036. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3037. * @param left defines 1st vector
  3038. * @param right defines 2nd vector
  3039. * @returns a new Vector2
  3040. */
  3041. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3042. /**
  3043. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3044. * @param left defines 1st vector
  3045. * @param right defines 2nd vector
  3046. * @returns a new Vector2
  3047. */
  3048. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3049. /**
  3050. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3051. * @param vector defines the vector to transform
  3052. * @param transformation defines the matrix to apply
  3053. * @returns a new Vector2
  3054. */
  3055. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3056. /**
  3057. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3058. * @param vector defines the vector to transform
  3059. * @param transformation defines the matrix to apply
  3060. * @param result defines the target vector
  3061. */
  3062. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3063. /**
  3064. * Determines if a given vector is included in a triangle
  3065. * @param p defines the vector to test
  3066. * @param p0 defines 1st triangle point
  3067. * @param p1 defines 2nd triangle point
  3068. * @param p2 defines 3rd triangle point
  3069. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3070. */
  3071. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3072. /**
  3073. * Gets the distance between the vectors "value1" and "value2"
  3074. * @param value1 defines first vector
  3075. * @param value2 defines second vector
  3076. * @returns the distance between vectors
  3077. */
  3078. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3079. /**
  3080. * Returns the squared distance between the vectors "value1" and "value2"
  3081. * @param value1 defines first vector
  3082. * @param value2 defines second vector
  3083. * @returns the squared distance between vectors
  3084. */
  3085. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3086. /**
  3087. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3088. * @param value1 defines first vector
  3089. * @param value2 defines second vector
  3090. * @returns a new Vector2
  3091. */
  3092. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3093. /**
  3094. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3095. * @param value1 defines first vector
  3096. * @param value2 defines second vector
  3097. * @param ref defines third vector
  3098. * @returns ref
  3099. */
  3100. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3101. /**
  3102. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3103. * @param p defines the middle point
  3104. * @param segA defines one point of the segment
  3105. * @param segB defines the other point of the segment
  3106. * @returns the shortest distance
  3107. */
  3108. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3109. }
  3110. /**
  3111. * Class used to store (x,y,z) vector representation
  3112. * A Vector3 is the main object used in 3D geometry
  3113. * It can represent etiher the coordinates of a point the space, either a direction
  3114. * Reminder: js uses a left handed forward facing system
  3115. */
  3116. export class Vector3 {
  3117. private static _UpReadOnly;
  3118. private static _ZeroReadOnly;
  3119. /** @hidden */
  3120. _x: number;
  3121. /** @hidden */
  3122. _y: number;
  3123. /** @hidden */
  3124. _z: number;
  3125. /** @hidden */
  3126. _isDirty: boolean;
  3127. /** Gets or sets the x coordinate */
  3128. get x(): number;
  3129. set x(value: number);
  3130. /** Gets or sets the y coordinate */
  3131. get y(): number;
  3132. set y(value: number);
  3133. /** Gets or sets the z coordinate */
  3134. get z(): number;
  3135. set z(value: number);
  3136. /**
  3137. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3138. * @param x defines the first coordinates (on X axis)
  3139. * @param y defines the second coordinates (on Y axis)
  3140. * @param z defines the third coordinates (on Z axis)
  3141. */
  3142. constructor(x?: number, y?: number, z?: number);
  3143. /**
  3144. * Creates a string representation of the Vector3
  3145. * @returns a string with the Vector3 coordinates.
  3146. */
  3147. toString(): string;
  3148. /**
  3149. * Gets the class name
  3150. * @returns the string "Vector3"
  3151. */
  3152. getClassName(): string;
  3153. /**
  3154. * Creates the Vector3 hash code
  3155. * @returns a number which tends to be unique between Vector3 instances
  3156. */
  3157. getHashCode(): number;
  3158. /**
  3159. * Creates an array containing three elements : the coordinates of the Vector3
  3160. * @returns a new array of numbers
  3161. */
  3162. asArray(): number[];
  3163. /**
  3164. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3165. * @param array defines the destination array
  3166. * @param index defines the offset in the destination array
  3167. * @returns the current Vector3
  3168. */
  3169. toArray(array: FloatArray, index?: number): Vector3;
  3170. /**
  3171. * Update the current vector from an array
  3172. * @param array defines the destination array
  3173. * @param index defines the offset in the destination array
  3174. * @returns the current Vector3
  3175. */
  3176. fromArray(array: FloatArray, index?: number): Vector3;
  3177. /**
  3178. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3179. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3180. */
  3181. toQuaternion(): Quaternion;
  3182. /**
  3183. * Adds the given vector to the current Vector3
  3184. * @param otherVector defines the second operand
  3185. * @returns the current updated Vector3
  3186. */
  3187. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * Adds the given coordinates to the current Vector3
  3190. * @param x defines the x coordinate of the operand
  3191. * @param y defines the y coordinate of the operand
  3192. * @param z defines the z coordinate of the operand
  3193. * @returns the current updated Vector3
  3194. */
  3195. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3196. /**
  3197. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3198. * @param otherVector defines the second operand
  3199. * @returns the resulting Vector3
  3200. */
  3201. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3204. * @param otherVector defines the second operand
  3205. * @param result defines the Vector3 object where to store the result
  3206. * @returns the current Vector3
  3207. */
  3208. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3209. /**
  3210. * Subtract the given vector from the current Vector3
  3211. * @param otherVector defines the second operand
  3212. * @returns the current updated Vector3
  3213. */
  3214. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3215. /**
  3216. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3217. * @param otherVector defines the second operand
  3218. * @returns the resulting Vector3
  3219. */
  3220. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3221. /**
  3222. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3223. * @param otherVector defines the second operand
  3224. * @param result defines the Vector3 object where to store the result
  3225. * @returns the current Vector3
  3226. */
  3227. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3228. /**
  3229. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3230. * @param x defines the x coordinate of the operand
  3231. * @param y defines the y coordinate of the operand
  3232. * @param z defines the z coordinate of the operand
  3233. * @returns the resulting Vector3
  3234. */
  3235. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3236. /**
  3237. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3238. * @param x defines the x coordinate of the operand
  3239. * @param y defines the y coordinate of the operand
  3240. * @param z defines the z coordinate of the operand
  3241. * @param result defines the Vector3 object where to store the result
  3242. * @returns the current Vector3
  3243. */
  3244. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3245. /**
  3246. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3247. * @returns a new Vector3
  3248. */
  3249. negate(): Vector3;
  3250. /**
  3251. * Negate this vector in place
  3252. * @returns this
  3253. */
  3254. negateInPlace(): Vector3;
  3255. /**
  3256. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3257. * @param result defines the Vector3 object where to store the result
  3258. * @returns the current Vector3
  3259. */
  3260. negateToRef(result: Vector3): Vector3;
  3261. /**
  3262. * Multiplies the Vector3 coordinates by the float "scale"
  3263. * @param scale defines the multiplier factor
  3264. * @returns the current updated Vector3
  3265. */
  3266. scaleInPlace(scale: number): Vector3;
  3267. /**
  3268. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3269. * @param scale defines the multiplier factor
  3270. * @returns a new Vector3
  3271. */
  3272. scale(scale: number): Vector3;
  3273. /**
  3274. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3275. * @param scale defines the multiplier factor
  3276. * @param result defines the Vector3 object where to store the result
  3277. * @returns the current Vector3
  3278. */
  3279. scaleToRef(scale: number, result: Vector3): Vector3;
  3280. /**
  3281. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3282. * @param scale defines the scale factor
  3283. * @param result defines the Vector3 object where to store the result
  3284. * @returns the unmodified current Vector3
  3285. */
  3286. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3287. /**
  3288. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3289. * @param origin defines the origin of the projection ray
  3290. * @param plane defines the plane to project to
  3291. * @returns the projected vector3
  3292. */
  3293. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3294. /**
  3295. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3296. * @param origin defines the origin of the projection ray
  3297. * @param plane defines the plane to project to
  3298. * @param result defines the Vector3 where to store the result
  3299. */
  3300. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3301. /**
  3302. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3303. * @param otherVector defines the second operand
  3304. * @returns true if both vectors are equals
  3305. */
  3306. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3307. /**
  3308. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3309. * @param otherVector defines the second operand
  3310. * @param epsilon defines the minimal distance to define values as equals
  3311. * @returns true if both vectors are distant less than epsilon
  3312. */
  3313. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3314. /**
  3315. * Returns true if the current Vector3 coordinates equals the given floats
  3316. * @param x defines the x coordinate of the operand
  3317. * @param y defines the y coordinate of the operand
  3318. * @param z defines the z coordinate of the operand
  3319. * @returns true if both vectors are equals
  3320. */
  3321. equalsToFloats(x: number, y: number, z: number): boolean;
  3322. /**
  3323. * Multiplies the current Vector3 coordinates by the given ones
  3324. * @param otherVector defines the second operand
  3325. * @returns the current updated Vector3
  3326. */
  3327. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3328. /**
  3329. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3330. * @param otherVector defines the second operand
  3331. * @returns the new Vector3
  3332. */
  3333. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3334. /**
  3335. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3336. * @param otherVector defines the second operand
  3337. * @param result defines the Vector3 object where to store the result
  3338. * @returns the current Vector3
  3339. */
  3340. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3341. /**
  3342. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3343. * @param x defines the x coordinate of the operand
  3344. * @param y defines the y coordinate of the operand
  3345. * @param z defines the z coordinate of the operand
  3346. * @returns the new Vector3
  3347. */
  3348. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3349. /**
  3350. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3351. * @param otherVector defines the second operand
  3352. * @returns the new Vector3
  3353. */
  3354. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3355. /**
  3356. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3357. * @param otherVector defines the second operand
  3358. * @param result defines the Vector3 object where to store the result
  3359. * @returns the current Vector3
  3360. */
  3361. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3362. /**
  3363. * Divides the current Vector3 coordinates by the given ones.
  3364. * @param otherVector defines the second operand
  3365. * @returns the current updated Vector3
  3366. */
  3367. divideInPlace(otherVector: Vector3): Vector3;
  3368. /**
  3369. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3370. * @param other defines the second operand
  3371. * @returns the current updated Vector3
  3372. */
  3373. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3374. /**
  3375. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3376. * @param other defines the second operand
  3377. * @returns the current updated Vector3
  3378. */
  3379. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3380. /**
  3381. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3382. * @param x defines the x coordinate of the operand
  3383. * @param y defines the y coordinate of the operand
  3384. * @param z defines the z coordinate of the operand
  3385. * @returns the current updated Vector3
  3386. */
  3387. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3388. /**
  3389. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3390. * @param x defines the x coordinate of the operand
  3391. * @param y defines the y coordinate of the operand
  3392. * @param z defines the z coordinate of the operand
  3393. * @returns the current updated Vector3
  3394. */
  3395. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3396. /**
  3397. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3398. * Check if is non uniform within a certain amount of decimal places to account for this
  3399. * @param epsilon the amount the values can differ
  3400. * @returns if the the vector is non uniform to a certain number of decimal places
  3401. */
  3402. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3403. /**
  3404. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3405. */
  3406. get isNonUniform(): boolean;
  3407. /**
  3408. * Gets a new Vector3 from current Vector3 floored values
  3409. * @returns a new Vector3
  3410. */
  3411. floor(): Vector3;
  3412. /**
  3413. * Gets a new Vector3 from current Vector3 floored values
  3414. * @returns a new Vector3
  3415. */
  3416. fract(): Vector3;
  3417. /**
  3418. * Gets the length of the Vector3
  3419. * @returns the length of the Vector3
  3420. */
  3421. length(): number;
  3422. /**
  3423. * Gets the squared length of the Vector3
  3424. * @returns squared length of the Vector3
  3425. */
  3426. lengthSquared(): number;
  3427. /**
  3428. * Normalize the current Vector3.
  3429. * Please note that this is an in place operation.
  3430. * @returns the current updated Vector3
  3431. */
  3432. normalize(): Vector3;
  3433. /**
  3434. * Reorders the x y z properties of the vector in place
  3435. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3436. * @returns the current updated vector
  3437. */
  3438. reorderInPlace(order: string): this;
  3439. /**
  3440. * Rotates the vector around 0,0,0 by a quaternion
  3441. * @param quaternion the rotation quaternion
  3442. * @param result vector to store the result
  3443. * @returns the resulting vector
  3444. */
  3445. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3446. /**
  3447. * Rotates a vector around a given point
  3448. * @param quaternion the rotation quaternion
  3449. * @param point the point to rotate around
  3450. * @param result vector to store the result
  3451. * @returns the resulting vector
  3452. */
  3453. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3454. /**
  3455. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3456. * The cross product is then orthogonal to both current and "other"
  3457. * @param other defines the right operand
  3458. * @returns the cross product
  3459. */
  3460. cross(other: Vector3): Vector3;
  3461. /**
  3462. * Normalize the current Vector3 with the given input length.
  3463. * Please note that this is an in place operation.
  3464. * @param len the length of the vector
  3465. * @returns the current updated Vector3
  3466. */
  3467. normalizeFromLength(len: number): Vector3;
  3468. /**
  3469. * Normalize the current Vector3 to a new vector
  3470. * @returns the new Vector3
  3471. */
  3472. normalizeToNew(): Vector3;
  3473. /**
  3474. * Normalize the current Vector3 to the reference
  3475. * @param reference define the Vector3 to update
  3476. * @returns the updated Vector3
  3477. */
  3478. normalizeToRef(reference: Vector3): Vector3;
  3479. /**
  3480. * Creates a new Vector3 copied from the current Vector3
  3481. * @returns the new Vector3
  3482. */
  3483. clone(): Vector3;
  3484. /**
  3485. * Copies the given vector coordinates to the current Vector3 ones
  3486. * @param source defines the source Vector3
  3487. * @returns the current updated Vector3
  3488. */
  3489. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3490. /**
  3491. * Copies the given floats to the current Vector3 coordinates
  3492. * @param x defines the x coordinate of the operand
  3493. * @param y defines the y coordinate of the operand
  3494. * @param z defines the z coordinate of the operand
  3495. * @returns the current updated Vector3
  3496. */
  3497. copyFromFloats(x: number, y: number, z: number): Vector3;
  3498. /**
  3499. * Copies the given floats to the current Vector3 coordinates
  3500. * @param x defines the x coordinate of the operand
  3501. * @param y defines the y coordinate of the operand
  3502. * @param z defines the z coordinate of the operand
  3503. * @returns the current updated Vector3
  3504. */
  3505. set(x: number, y: number, z: number): Vector3;
  3506. /**
  3507. * Copies the given float to the current Vector3 coordinates
  3508. * @param v defines the x, y and z coordinates of the operand
  3509. * @returns the current updated Vector3
  3510. */
  3511. setAll(v: number): Vector3;
  3512. /**
  3513. * Get the clip factor between two vectors
  3514. * @param vector0 defines the first operand
  3515. * @param vector1 defines the second operand
  3516. * @param axis defines the axis to use
  3517. * @param size defines the size along the axis
  3518. * @returns the clip factor
  3519. */
  3520. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3521. /**
  3522. * Get angle between two vectors
  3523. * @param vector0 angle between vector0 and vector1
  3524. * @param vector1 angle between vector0 and vector1
  3525. * @param normal direction of the normal
  3526. * @return the angle between vector0 and vector1
  3527. */
  3528. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3529. /**
  3530. * Returns a new Vector3 set from the index "offset" of the given array
  3531. * @param array defines the source array
  3532. * @param offset defines the offset in the source array
  3533. * @returns the new Vector3
  3534. */
  3535. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3536. /**
  3537. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3538. * @param array defines the source array
  3539. * @param offset defines the offset in the source array
  3540. * @returns the new Vector3
  3541. * @deprecated Please use FromArray instead.
  3542. */
  3543. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3544. /**
  3545. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3546. * @param array defines the source array
  3547. * @param offset defines the offset in the source array
  3548. * @param result defines the Vector3 where to store the result
  3549. */
  3550. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3551. /**
  3552. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3553. * @param array defines the source array
  3554. * @param offset defines the offset in the source array
  3555. * @param result defines the Vector3 where to store the result
  3556. * @deprecated Please use FromArrayToRef instead.
  3557. */
  3558. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3559. /**
  3560. * Sets the given vector "result" with the given floats.
  3561. * @param x defines the x coordinate of the source
  3562. * @param y defines the y coordinate of the source
  3563. * @param z defines the z coordinate of the source
  3564. * @param result defines the Vector3 where to store the result
  3565. */
  3566. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3567. /**
  3568. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3569. * @returns a new empty Vector3
  3570. */
  3571. static Zero(): Vector3;
  3572. /**
  3573. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3574. * @returns a new unit Vector3
  3575. */
  3576. static One(): Vector3;
  3577. /**
  3578. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3579. * @returns a new up Vector3
  3580. */
  3581. static Up(): Vector3;
  3582. /**
  3583. * Gets a up Vector3 that must not be updated
  3584. */
  3585. static get UpReadOnly(): DeepImmutable<Vector3>;
  3586. /**
  3587. * Gets a zero Vector3 that must not be updated
  3588. */
  3589. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3590. /**
  3591. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3592. * @returns a new down Vector3
  3593. */
  3594. static Down(): Vector3;
  3595. /**
  3596. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3597. * @param rightHandedSystem is the scene right-handed (negative z)
  3598. * @returns a new forward Vector3
  3599. */
  3600. static Forward(rightHandedSystem?: boolean): Vector3;
  3601. /**
  3602. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3603. * @param rightHandedSystem is the scene right-handed (negative-z)
  3604. * @returns a new forward Vector3
  3605. */
  3606. static Backward(rightHandedSystem?: boolean): Vector3;
  3607. /**
  3608. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3609. * @returns a new right Vector3
  3610. */
  3611. static Right(): Vector3;
  3612. /**
  3613. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3614. * @returns a new left Vector3
  3615. */
  3616. static Left(): Vector3;
  3617. /**
  3618. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3619. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3620. * @param vector defines the Vector3 to transform
  3621. * @param transformation defines the transformation matrix
  3622. * @returns the transformed Vector3
  3623. */
  3624. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3625. /**
  3626. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3627. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3628. * @param vector defines the Vector3 to transform
  3629. * @param transformation defines the transformation matrix
  3630. * @param result defines the Vector3 where to store the result
  3631. */
  3632. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3633. /**
  3634. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3635. * This method computes tranformed coordinates only, not transformed direction vectors
  3636. * @param x define the x coordinate of the source vector
  3637. * @param y define the y coordinate of the source vector
  3638. * @param z define the z coordinate of the source vector
  3639. * @param transformation defines the transformation matrix
  3640. * @param result defines the Vector3 where to store the result
  3641. */
  3642. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3643. /**
  3644. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3645. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3646. * @param vector defines the Vector3 to transform
  3647. * @param transformation defines the transformation matrix
  3648. * @returns the new Vector3
  3649. */
  3650. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3651. /**
  3652. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3653. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3654. * @param vector defines the Vector3 to transform
  3655. * @param transformation defines the transformation matrix
  3656. * @param result defines the Vector3 where to store the result
  3657. */
  3658. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3659. /**
  3660. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3661. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3662. * @param x define the x coordinate of the source vector
  3663. * @param y define the y coordinate of the source vector
  3664. * @param z define the z coordinate of the source vector
  3665. * @param transformation defines the transformation matrix
  3666. * @param result defines the Vector3 where to store the result
  3667. */
  3668. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3669. /**
  3670. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3671. * @param value1 defines the first control point
  3672. * @param value2 defines the second control point
  3673. * @param value3 defines the third control point
  3674. * @param value4 defines the fourth control point
  3675. * @param amount defines the amount on the spline to use
  3676. * @returns the new Vector3
  3677. */
  3678. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3679. /**
  3680. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3681. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3682. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3683. * @param value defines the current value
  3684. * @param min defines the lower range value
  3685. * @param max defines the upper range value
  3686. * @returns the new Vector3
  3687. */
  3688. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3689. /**
  3690. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3691. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3692. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3693. * @param value defines the current value
  3694. * @param min defines the lower range value
  3695. * @param max defines the upper range value
  3696. * @param result defines the Vector3 where to store the result
  3697. */
  3698. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3699. /**
  3700. * Checks if a given vector is inside a specific range
  3701. * @param v defines the vector to test
  3702. * @param min defines the minimum range
  3703. * @param max defines the maximum range
  3704. */
  3705. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3706. /**
  3707. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3708. * @param value1 defines the first control point
  3709. * @param tangent1 defines the first tangent vector
  3710. * @param value2 defines the second control point
  3711. * @param tangent2 defines the second tangent vector
  3712. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3713. * @returns the new Vector3
  3714. */
  3715. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3716. /**
  3717. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3718. * @param start defines the start value
  3719. * @param end defines the end value
  3720. * @param amount max defines amount between both (between 0 and 1)
  3721. * @returns the new Vector3
  3722. */
  3723. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3724. /**
  3725. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3726. * @param start defines the start value
  3727. * @param end defines the end value
  3728. * @param amount max defines amount between both (between 0 and 1)
  3729. * @param result defines the Vector3 where to store the result
  3730. */
  3731. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3732. /**
  3733. * Returns the dot product (float) between the vectors "left" and "right"
  3734. * @param left defines the left operand
  3735. * @param right defines the right operand
  3736. * @returns the dot product
  3737. */
  3738. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3739. /**
  3740. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3741. * The cross product is then orthogonal to both "left" and "right"
  3742. * @param left defines the left operand
  3743. * @param right defines the right operand
  3744. * @returns the cross product
  3745. */
  3746. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3747. /**
  3748. * Sets the given vector "result" with the cross product of "left" and "right"
  3749. * The cross product is then orthogonal to both "left" and "right"
  3750. * @param left defines the left operand
  3751. * @param right defines the right operand
  3752. * @param result defines the Vector3 where to store the result
  3753. */
  3754. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3755. /**
  3756. * Returns a new Vector3 as the normalization of the given vector
  3757. * @param vector defines the Vector3 to normalize
  3758. * @returns the new Vector3
  3759. */
  3760. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3761. /**
  3762. * Sets the given vector "result" with the normalization of the given first vector
  3763. * @param vector defines the Vector3 to normalize
  3764. * @param result defines the Vector3 where to store the result
  3765. */
  3766. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3767. /**
  3768. * Project a Vector3 onto screen space
  3769. * @param vector defines the Vector3 to project
  3770. * @param world defines the world matrix to use
  3771. * @param transform defines the transform (view x projection) matrix to use
  3772. * @param viewport defines the screen viewport to use
  3773. * @returns the new Vector3
  3774. */
  3775. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3776. /**
  3777. * Project a Vector3 onto screen space to reference
  3778. * @param vector defines the Vector3 to project
  3779. * @param world defines the world matrix to use
  3780. * @param transform defines the transform (view x projection) matrix to use
  3781. * @param viewport defines the screen viewport to use
  3782. * @param result the vector in which the screen space will be stored
  3783. * @returns the new Vector3
  3784. */
  3785. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3786. /** @hidden */
  3787. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3788. /**
  3789. * Unproject from screen space to object space
  3790. * @param source defines the screen space Vector3 to use
  3791. * @param viewportWidth defines the current width of the viewport
  3792. * @param viewportHeight defines the current height of the viewport
  3793. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3794. * @param transform defines the transform (view x projection) matrix to use
  3795. * @returns the new Vector3
  3796. */
  3797. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3798. /**
  3799. * Unproject from screen space to object space
  3800. * @param source defines the screen space Vector3 to use
  3801. * @param viewportWidth defines the current width of the viewport
  3802. * @param viewportHeight defines the current height of the viewport
  3803. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3804. * @param view defines the view matrix to use
  3805. * @param projection defines the projection matrix to use
  3806. * @returns the new Vector3
  3807. */
  3808. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3809. /**
  3810. * Unproject from screen space to object space
  3811. * @param source defines the screen space Vector3 to use
  3812. * @param viewportWidth defines the current width of the viewport
  3813. * @param viewportHeight defines the current height of the viewport
  3814. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3815. * @param view defines the view matrix to use
  3816. * @param projection defines the projection matrix to use
  3817. * @param result defines the Vector3 where to store the result
  3818. */
  3819. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3820. /**
  3821. * Unproject from screen space to object space
  3822. * @param sourceX defines the screen space x coordinate to use
  3823. * @param sourceY defines the screen space y coordinate to use
  3824. * @param sourceZ defines the screen space z coordinate to use
  3825. * @param viewportWidth defines the current width of the viewport
  3826. * @param viewportHeight defines the current height of the viewport
  3827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3828. * @param view defines the view matrix to use
  3829. * @param projection defines the projection matrix to use
  3830. * @param result defines the Vector3 where to store the result
  3831. */
  3832. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3833. /**
  3834. * Gets the minimal coordinate values between two Vector3
  3835. * @param left defines the first operand
  3836. * @param right defines the second operand
  3837. * @returns the new Vector3
  3838. */
  3839. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3840. /**
  3841. * Gets the maximal coordinate values between two Vector3
  3842. * @param left defines the first operand
  3843. * @param right defines the second operand
  3844. * @returns the new Vector3
  3845. */
  3846. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3847. /**
  3848. * Returns the distance between the vectors "value1" and "value2"
  3849. * @param value1 defines the first operand
  3850. * @param value2 defines the second operand
  3851. * @returns the distance
  3852. */
  3853. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3854. /**
  3855. * Returns the squared distance between the vectors "value1" and "value2"
  3856. * @param value1 defines the first operand
  3857. * @param value2 defines the second operand
  3858. * @returns the squared distance
  3859. */
  3860. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3861. /**
  3862. * Returns a new Vector3 located at the center between "value1" and "value2"
  3863. * @param value1 defines the first operand
  3864. * @param value2 defines the second operand
  3865. * @returns the new Vector3
  3866. */
  3867. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3868. /**
  3869. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3870. * @param value1 defines first vector
  3871. * @param value2 defines second vector
  3872. * @param ref defines third vector
  3873. * @returns ref
  3874. */
  3875. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3876. /**
  3877. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3878. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3879. * to something in order to rotate it from its local system to the given target system
  3880. * Note: axis1, axis2 and axis3 are normalized during this operation
  3881. * @param axis1 defines the first axis
  3882. * @param axis2 defines the second axis
  3883. * @param axis3 defines the third axis
  3884. * @returns a new Vector3
  3885. */
  3886. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3887. /**
  3888. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3889. * @param axis1 defines the first axis
  3890. * @param axis2 defines the second axis
  3891. * @param axis3 defines the third axis
  3892. * @param ref defines the Vector3 where to store the result
  3893. */
  3894. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3895. }
  3896. /**
  3897. * Vector4 class created for EulerAngle class conversion to Quaternion
  3898. */
  3899. export class Vector4 {
  3900. /** x value of the vector */
  3901. x: number;
  3902. /** y value of the vector */
  3903. y: number;
  3904. /** z value of the vector */
  3905. z: number;
  3906. /** w value of the vector */
  3907. w: number;
  3908. /**
  3909. * Creates a Vector4 object from the given floats.
  3910. * @param x x value of the vector
  3911. * @param y y value of the vector
  3912. * @param z z value of the vector
  3913. * @param w w value of the vector
  3914. */
  3915. constructor(
  3916. /** x value of the vector */
  3917. x: number,
  3918. /** y value of the vector */
  3919. y: number,
  3920. /** z value of the vector */
  3921. z: number,
  3922. /** w value of the vector */
  3923. w: number);
  3924. /**
  3925. * Returns the string with the Vector4 coordinates.
  3926. * @returns a string containing all the vector values
  3927. */
  3928. toString(): string;
  3929. /**
  3930. * Returns the string "Vector4".
  3931. * @returns "Vector4"
  3932. */
  3933. getClassName(): string;
  3934. /**
  3935. * Returns the Vector4 hash code.
  3936. * @returns a unique hash code
  3937. */
  3938. getHashCode(): number;
  3939. /**
  3940. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3941. * @returns the resulting array
  3942. */
  3943. asArray(): number[];
  3944. /**
  3945. * Populates the given array from the given index with the Vector4 coordinates.
  3946. * @param array array to populate
  3947. * @param index index of the array to start at (default: 0)
  3948. * @returns the Vector4.
  3949. */
  3950. toArray(array: FloatArray, index?: number): Vector4;
  3951. /**
  3952. * Update the current vector from an array
  3953. * @param array defines the destination array
  3954. * @param index defines the offset in the destination array
  3955. * @returns the current Vector3
  3956. */
  3957. fromArray(array: FloatArray, index?: number): Vector4;
  3958. /**
  3959. * Adds the given vector to the current Vector4.
  3960. * @param otherVector the vector to add
  3961. * @returns the updated Vector4.
  3962. */
  3963. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3964. /**
  3965. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3966. * @param otherVector the vector to add
  3967. * @returns the resulting vector
  3968. */
  3969. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3970. /**
  3971. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3972. * @param otherVector the vector to add
  3973. * @param result the vector to store the result
  3974. * @returns the current Vector4.
  3975. */
  3976. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3977. /**
  3978. * Subtract in place the given vector from the current Vector4.
  3979. * @param otherVector the vector to subtract
  3980. * @returns the updated Vector4.
  3981. */
  3982. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3983. /**
  3984. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3985. * @param otherVector the vector to add
  3986. * @returns the new vector with the result
  3987. */
  3988. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3989. /**
  3990. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3991. * @param otherVector the vector to subtract
  3992. * @param result the vector to store the result
  3993. * @returns the current Vector4.
  3994. */
  3995. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3996. /**
  3997. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3998. */
  3999. /**
  4000. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4001. * @param x value to subtract
  4002. * @param y value to subtract
  4003. * @param z value to subtract
  4004. * @param w value to subtract
  4005. * @returns new vector containing the result
  4006. */
  4007. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4008. /**
  4009. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4010. * @param x value to subtract
  4011. * @param y value to subtract
  4012. * @param z value to subtract
  4013. * @param w value to subtract
  4014. * @param result the vector to store the result in
  4015. * @returns the current Vector4.
  4016. */
  4017. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4018. /**
  4019. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4020. * @returns a new vector with the negated values
  4021. */
  4022. negate(): Vector4;
  4023. /**
  4024. * Negate this vector in place
  4025. * @returns this
  4026. */
  4027. negateInPlace(): Vector4;
  4028. /**
  4029. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4030. * @param result defines the Vector3 object where to store the result
  4031. * @returns the current Vector4
  4032. */
  4033. negateToRef(result: Vector4): Vector4;
  4034. /**
  4035. * Multiplies the current Vector4 coordinates by scale (float).
  4036. * @param scale the number to scale with
  4037. * @returns the updated Vector4.
  4038. */
  4039. scaleInPlace(scale: number): Vector4;
  4040. /**
  4041. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4042. * @param scale the number to scale with
  4043. * @returns a new vector with the result
  4044. */
  4045. scale(scale: number): Vector4;
  4046. /**
  4047. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4048. * @param scale the number to scale with
  4049. * @param result a vector to store the result in
  4050. * @returns the current Vector4.
  4051. */
  4052. scaleToRef(scale: number, result: Vector4): Vector4;
  4053. /**
  4054. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4055. * @param scale defines the scale factor
  4056. * @param result defines the Vector4 object where to store the result
  4057. * @returns the unmodified current Vector4
  4058. */
  4059. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4060. /**
  4061. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4062. * @param otherVector the vector to compare against
  4063. * @returns true if they are equal
  4064. */
  4065. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4066. /**
  4067. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4068. * @param otherVector vector to compare against
  4069. * @param epsilon (Default: very small number)
  4070. * @returns true if they are equal
  4071. */
  4072. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4073. /**
  4074. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4075. * @param x x value to compare against
  4076. * @param y y value to compare against
  4077. * @param z z value to compare against
  4078. * @param w w value to compare against
  4079. * @returns true if equal
  4080. */
  4081. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4082. /**
  4083. * Multiplies in place the current Vector4 by the given one.
  4084. * @param otherVector vector to multiple with
  4085. * @returns the updated Vector4.
  4086. */
  4087. multiplyInPlace(otherVector: Vector4): Vector4;
  4088. /**
  4089. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4090. * @param otherVector vector to multiple with
  4091. * @returns resulting new vector
  4092. */
  4093. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4094. /**
  4095. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4096. * @param otherVector vector to multiple with
  4097. * @param result vector to store the result
  4098. * @returns the current Vector4.
  4099. */
  4100. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4101. /**
  4102. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4103. * @param x x value multiply with
  4104. * @param y y value multiply with
  4105. * @param z z value multiply with
  4106. * @param w w value multiply with
  4107. * @returns resulting new vector
  4108. */
  4109. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4110. /**
  4111. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4112. * @param otherVector vector to devide with
  4113. * @returns resulting new vector
  4114. */
  4115. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4116. /**
  4117. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4118. * @param otherVector vector to devide with
  4119. * @param result vector to store the result
  4120. * @returns the current Vector4.
  4121. */
  4122. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4123. /**
  4124. * Divides the current Vector3 coordinates by the given ones.
  4125. * @param otherVector vector to devide with
  4126. * @returns the updated Vector3.
  4127. */
  4128. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4129. /**
  4130. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4131. * @param other defines the second operand
  4132. * @returns the current updated Vector4
  4133. */
  4134. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4135. /**
  4136. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4137. * @param other defines the second operand
  4138. * @returns the current updated Vector4
  4139. */
  4140. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4141. /**
  4142. * Gets a new Vector4 from current Vector4 floored values
  4143. * @returns a new Vector4
  4144. */
  4145. floor(): Vector4;
  4146. /**
  4147. * Gets a new Vector4 from current Vector3 floored values
  4148. * @returns a new Vector4
  4149. */
  4150. fract(): Vector4;
  4151. /**
  4152. * Returns the Vector4 length (float).
  4153. * @returns the length
  4154. */
  4155. length(): number;
  4156. /**
  4157. * Returns the Vector4 squared length (float).
  4158. * @returns the length squared
  4159. */
  4160. lengthSquared(): number;
  4161. /**
  4162. * Normalizes in place the Vector4.
  4163. * @returns the updated Vector4.
  4164. */
  4165. normalize(): Vector4;
  4166. /**
  4167. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4168. * @returns this converted to a new vector3
  4169. */
  4170. toVector3(): Vector3;
  4171. /**
  4172. * Returns a new Vector4 copied from the current one.
  4173. * @returns the new cloned vector
  4174. */
  4175. clone(): Vector4;
  4176. /**
  4177. * Updates the current Vector4 with the given one coordinates.
  4178. * @param source the source vector to copy from
  4179. * @returns the updated Vector4.
  4180. */
  4181. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4182. /**
  4183. * Updates the current Vector4 coordinates with the given floats.
  4184. * @param x float to copy from
  4185. * @param y float to copy from
  4186. * @param z float to copy from
  4187. * @param w float to copy from
  4188. * @returns the updated Vector4.
  4189. */
  4190. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4191. /**
  4192. * Updates the current Vector4 coordinates with the given floats.
  4193. * @param x float to set from
  4194. * @param y float to set from
  4195. * @param z float to set from
  4196. * @param w float to set from
  4197. * @returns the updated Vector4.
  4198. */
  4199. set(x: number, y: number, z: number, w: number): Vector4;
  4200. /**
  4201. * Copies the given float to the current Vector3 coordinates
  4202. * @param v defines the x, y, z and w coordinates of the operand
  4203. * @returns the current updated Vector3
  4204. */
  4205. setAll(v: number): Vector4;
  4206. /**
  4207. * Returns a new Vector4 set from the starting index of the given array.
  4208. * @param array the array to pull values from
  4209. * @param offset the offset into the array to start at
  4210. * @returns the new vector
  4211. */
  4212. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4213. /**
  4214. * Updates the given vector "result" from the starting index of the given array.
  4215. * @param array the array to pull values from
  4216. * @param offset the offset into the array to start at
  4217. * @param result the vector to store the result in
  4218. */
  4219. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4220. /**
  4221. * Updates the given vector "result" from the starting index of the given Float32Array.
  4222. * @param array the array to pull values from
  4223. * @param offset the offset into the array to start at
  4224. * @param result the vector to store the result in
  4225. */
  4226. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4227. /**
  4228. * Updates the given vector "result" coordinates from the given floats.
  4229. * @param x float to set from
  4230. * @param y float to set from
  4231. * @param z float to set from
  4232. * @param w float to set from
  4233. * @param result the vector to the floats in
  4234. */
  4235. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4236. /**
  4237. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4238. * @returns the new vector
  4239. */
  4240. static Zero(): Vector4;
  4241. /**
  4242. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4243. * @returns the new vector
  4244. */
  4245. static One(): Vector4;
  4246. /**
  4247. * Returns a new normalized Vector4 from the given one.
  4248. * @param vector the vector to normalize
  4249. * @returns the vector
  4250. */
  4251. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4252. /**
  4253. * Updates the given vector "result" from the normalization of the given one.
  4254. * @param vector the vector to normalize
  4255. * @param result the vector to store the result in
  4256. */
  4257. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4258. /**
  4259. * Returns a vector with the minimum values from the left and right vectors
  4260. * @param left left vector to minimize
  4261. * @param right right vector to minimize
  4262. * @returns a new vector with the minimum of the left and right vector values
  4263. */
  4264. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4265. /**
  4266. * Returns a vector with the maximum values from the left and right vectors
  4267. * @param left left vector to maximize
  4268. * @param right right vector to maximize
  4269. * @returns a new vector with the maximum of the left and right vector values
  4270. */
  4271. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4272. /**
  4273. * Returns the distance (float) between the vectors "value1" and "value2".
  4274. * @param value1 value to calulate the distance between
  4275. * @param value2 value to calulate the distance between
  4276. * @return the distance between the two vectors
  4277. */
  4278. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4279. /**
  4280. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4281. * @param value1 value to calulate the distance between
  4282. * @param value2 value to calulate the distance between
  4283. * @return the distance between the two vectors squared
  4284. */
  4285. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4286. /**
  4287. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4288. * @param value1 value to calulate the center between
  4289. * @param value2 value to calulate the center between
  4290. * @return the center between the two vectors
  4291. */
  4292. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4293. /**
  4294. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4295. * @param value1 defines first vector
  4296. * @param value2 defines second vector
  4297. * @param ref defines third vector
  4298. * @returns ref
  4299. */
  4300. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4301. /**
  4302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4303. * This methods computes transformed normalized direction vectors only.
  4304. * @param vector the vector to transform
  4305. * @param transformation the transformation matrix to apply
  4306. * @returns the new vector
  4307. */
  4308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4309. /**
  4310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4311. * This methods computes transformed normalized direction vectors only.
  4312. * @param vector the vector to transform
  4313. * @param transformation the transformation matrix to apply
  4314. * @param result the vector to store the result in
  4315. */
  4316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4317. /**
  4318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4319. * This methods computes transformed normalized direction vectors only.
  4320. * @param x value to transform
  4321. * @param y value to transform
  4322. * @param z value to transform
  4323. * @param w value to transform
  4324. * @param transformation the transformation matrix to apply
  4325. * @param result the vector to store the results in
  4326. */
  4327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4328. /**
  4329. * Creates a new Vector4 from a Vector3
  4330. * @param source defines the source data
  4331. * @param w defines the 4th component (default is 0)
  4332. * @returns a new Vector4
  4333. */
  4334. static FromVector3(source: Vector3, w?: number): Vector4;
  4335. }
  4336. /**
  4337. * Class used to store quaternion data
  4338. * @see https://en.wikipedia.org/wiki/Quaternion
  4339. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4340. */
  4341. export class Quaternion {
  4342. /** @hidden */
  4343. _x: number;
  4344. /** @hidden */
  4345. _y: number;
  4346. /** @hidden */
  4347. _z: number;
  4348. /** @hidden */
  4349. _w: number;
  4350. /** @hidden */
  4351. _isDirty: boolean;
  4352. /** Gets or sets the x coordinate */
  4353. get x(): number;
  4354. set x(value: number);
  4355. /** Gets or sets the y coordinate */
  4356. get y(): number;
  4357. set y(value: number);
  4358. /** Gets or sets the z coordinate */
  4359. get z(): number;
  4360. set z(value: number);
  4361. /** Gets or sets the w coordinate */
  4362. get w(): number;
  4363. set w(value: number);
  4364. /**
  4365. * Creates a new Quaternion from the given floats
  4366. * @param x defines the first component (0 by default)
  4367. * @param y defines the second component (0 by default)
  4368. * @param z defines the third component (0 by default)
  4369. * @param w defines the fourth component (1.0 by default)
  4370. */
  4371. constructor(x?: number, y?: number, z?: number, w?: number);
  4372. /**
  4373. * Gets a string representation for the current quaternion
  4374. * @returns a string with the Quaternion coordinates
  4375. */
  4376. toString(): string;
  4377. /**
  4378. * Gets the class name of the quaternion
  4379. * @returns the string "Quaternion"
  4380. */
  4381. getClassName(): string;
  4382. /**
  4383. * Gets a hash code for this quaternion
  4384. * @returns the quaternion hash code
  4385. */
  4386. getHashCode(): number;
  4387. /**
  4388. * Copy the quaternion to an array
  4389. * @returns a new array populated with 4 elements from the quaternion coordinates
  4390. */
  4391. asArray(): number[];
  4392. /**
  4393. * Check if two quaternions are equals
  4394. * @param otherQuaternion defines the second operand
  4395. * @return true if the current quaternion and the given one coordinates are strictly equals
  4396. */
  4397. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4398. /**
  4399. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4400. * @param otherQuaternion defines the other quaternion
  4401. * @param epsilon defines the minimal distance to consider equality
  4402. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4403. */
  4404. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4405. /**
  4406. * Clone the current quaternion
  4407. * @returns a new quaternion copied from the current one
  4408. */
  4409. clone(): Quaternion;
  4410. /**
  4411. * Copy a quaternion to the current one
  4412. * @param other defines the other quaternion
  4413. * @returns the updated current quaternion
  4414. */
  4415. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4416. /**
  4417. * Updates the current quaternion with the given float coordinates
  4418. * @param x defines the x coordinate
  4419. * @param y defines the y coordinate
  4420. * @param z defines the z coordinate
  4421. * @param w defines the w coordinate
  4422. * @returns the updated current quaternion
  4423. */
  4424. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4425. /**
  4426. * Updates the current quaternion from the given float coordinates
  4427. * @param x defines the x coordinate
  4428. * @param y defines the y coordinate
  4429. * @param z defines the z coordinate
  4430. * @param w defines the w coordinate
  4431. * @returns the updated current quaternion
  4432. */
  4433. set(x: number, y: number, z: number, w: number): Quaternion;
  4434. /**
  4435. * Adds two quaternions
  4436. * @param other defines the second operand
  4437. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4438. */
  4439. add(other: DeepImmutable<Quaternion>): Quaternion;
  4440. /**
  4441. * Add a quaternion to the current one
  4442. * @param other defines the quaternion to add
  4443. * @returns the current quaternion
  4444. */
  4445. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4446. /**
  4447. * Subtract two quaternions
  4448. * @param other defines the second operand
  4449. * @returns a new quaternion as the subtraction result of the given one from the current one
  4450. */
  4451. subtract(other: Quaternion): Quaternion;
  4452. /**
  4453. * Multiplies the current quaternion by a scale factor
  4454. * @param value defines the scale factor
  4455. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4456. */
  4457. scale(value: number): Quaternion;
  4458. /**
  4459. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4460. * @param scale defines the scale factor
  4461. * @param result defines the Quaternion object where to store the result
  4462. * @returns the unmodified current quaternion
  4463. */
  4464. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4465. /**
  4466. * Multiplies in place the current quaternion by a scale factor
  4467. * @param value defines the scale factor
  4468. * @returns the current modified quaternion
  4469. */
  4470. scaleInPlace(value: number): Quaternion;
  4471. /**
  4472. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4473. * @param scale defines the scale factor
  4474. * @param result defines the Quaternion object where to store the result
  4475. * @returns the unmodified current quaternion
  4476. */
  4477. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4478. /**
  4479. * Multiplies two quaternions
  4480. * @param q1 defines the second operand
  4481. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4482. */
  4483. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4484. /**
  4485. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4486. * @param q1 defines the second operand
  4487. * @param result defines the target quaternion
  4488. * @returns the current quaternion
  4489. */
  4490. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4491. /**
  4492. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4493. * @param q1 defines the second operand
  4494. * @returns the currentupdated quaternion
  4495. */
  4496. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4497. /**
  4498. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4499. * @param ref defines the target quaternion
  4500. * @returns the current quaternion
  4501. */
  4502. conjugateToRef(ref: Quaternion): Quaternion;
  4503. /**
  4504. * Conjugates in place (1-q) the current quaternion
  4505. * @returns the current updated quaternion
  4506. */
  4507. conjugateInPlace(): Quaternion;
  4508. /**
  4509. * Conjugates in place (1-q) the current quaternion
  4510. * @returns a new quaternion
  4511. */
  4512. conjugate(): Quaternion;
  4513. /**
  4514. * Gets length of current quaternion
  4515. * @returns the quaternion length (float)
  4516. */
  4517. length(): number;
  4518. /**
  4519. * Normalize in place the current quaternion
  4520. * @returns the current updated quaternion
  4521. */
  4522. normalize(): Quaternion;
  4523. /**
  4524. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4525. * @param order is a reserved parameter and is ignored for now
  4526. * @returns a new Vector3 containing the Euler angles
  4527. */
  4528. toEulerAngles(order?: string): Vector3;
  4529. /**
  4530. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4531. * @param result defines the vector which will be filled with the Euler angles
  4532. * @returns the current unchanged quaternion
  4533. */
  4534. toEulerAnglesToRef(result: Vector3): Quaternion;
  4535. /**
  4536. * Updates the given rotation matrix with the current quaternion values
  4537. * @param result defines the target matrix
  4538. * @returns the current unchanged quaternion
  4539. */
  4540. toRotationMatrix(result: Matrix): Quaternion;
  4541. /**
  4542. * Updates the current quaternion from the given rotation matrix values
  4543. * @param matrix defines the source matrix
  4544. * @returns the current updated quaternion
  4545. */
  4546. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4547. /**
  4548. * Creates a new quaternion from a rotation matrix
  4549. * @param matrix defines the source matrix
  4550. * @returns a new quaternion created from the given rotation matrix values
  4551. */
  4552. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4553. /**
  4554. * Updates the given quaternion with the given rotation matrix values
  4555. * @param matrix defines the source matrix
  4556. * @param result defines the target quaternion
  4557. */
  4558. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4559. /**
  4560. * Returns the dot product (float) between the quaternions "left" and "right"
  4561. * @param left defines the left operand
  4562. * @param right defines the right operand
  4563. * @returns the dot product
  4564. */
  4565. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4566. /**
  4567. * Checks if the two quaternions are close to each other
  4568. * @param quat0 defines the first quaternion to check
  4569. * @param quat1 defines the second quaternion to check
  4570. * @returns true if the two quaternions are close to each other
  4571. */
  4572. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4573. /**
  4574. * Creates an empty quaternion
  4575. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4576. */
  4577. static Zero(): Quaternion;
  4578. /**
  4579. * Inverse a given quaternion
  4580. * @param q defines the source quaternion
  4581. * @returns a new quaternion as the inverted current quaternion
  4582. */
  4583. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4584. /**
  4585. * Inverse a given quaternion
  4586. * @param q defines the source quaternion
  4587. * @param result the quaternion the result will be stored in
  4588. * @returns the result quaternion
  4589. */
  4590. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4591. /**
  4592. * Creates an identity quaternion
  4593. * @returns the identity quaternion
  4594. */
  4595. static Identity(): Quaternion;
  4596. /**
  4597. * Gets a boolean indicating if the given quaternion is identity
  4598. * @param quaternion defines the quaternion to check
  4599. * @returns true if the quaternion is identity
  4600. */
  4601. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4602. /**
  4603. * Creates a quaternion from a rotation around an axis
  4604. * @param axis defines the axis to use
  4605. * @param angle defines the angle to use
  4606. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4607. */
  4608. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4609. /**
  4610. * Creates a rotation around an axis and stores it into the given quaternion
  4611. * @param axis defines the axis to use
  4612. * @param angle defines the angle to use
  4613. * @param result defines the target quaternion
  4614. * @returns the target quaternion
  4615. */
  4616. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4617. /**
  4618. * Creates a new quaternion from data stored into an array
  4619. * @param array defines the data source
  4620. * @param offset defines the offset in the source array where the data starts
  4621. * @returns a new quaternion
  4622. */
  4623. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4624. /**
  4625. * Updates the given quaternion "result" from the starting index of the given array.
  4626. * @param array the array to pull values from
  4627. * @param offset the offset into the array to start at
  4628. * @param result the quaternion to store the result in
  4629. */
  4630. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4631. /**
  4632. * Create a quaternion from Euler rotation angles
  4633. * @param x Pitch
  4634. * @param y Yaw
  4635. * @param z Roll
  4636. * @returns the new Quaternion
  4637. */
  4638. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4639. /**
  4640. * Updates a quaternion from Euler rotation angles
  4641. * @param x Pitch
  4642. * @param y Yaw
  4643. * @param z Roll
  4644. * @param result the quaternion to store the result
  4645. * @returns the updated quaternion
  4646. */
  4647. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4648. /**
  4649. * Create a quaternion from Euler rotation vector
  4650. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4651. * @returns the new Quaternion
  4652. */
  4653. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4654. /**
  4655. * Updates a quaternion from Euler rotation vector
  4656. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4657. * @param result the quaternion to store the result
  4658. * @returns the updated quaternion
  4659. */
  4660. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4661. /**
  4662. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4663. * @param vecFrom defines the direction vector from which to rotate
  4664. * @param vecTo defines the direction vector to which to rotate
  4665. * @param result the quaternion to store the result
  4666. * @returns the updated quaternion
  4667. */
  4668. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4669. /**
  4670. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4671. * @param yaw defines the rotation around Y axis
  4672. * @param pitch defines the rotation around X axis
  4673. * @param roll defines the rotation around Z axis
  4674. * @returns the new quaternion
  4675. */
  4676. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4677. /**
  4678. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4679. * @param yaw defines the rotation around Y axis
  4680. * @param pitch defines the rotation around X axis
  4681. * @param roll defines the rotation around Z axis
  4682. * @param result defines the target quaternion
  4683. */
  4684. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4685. /**
  4686. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4687. * @param alpha defines the rotation around first axis
  4688. * @param beta defines the rotation around second axis
  4689. * @param gamma defines the rotation around third axis
  4690. * @returns the new quaternion
  4691. */
  4692. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4693. /**
  4694. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4695. * @param alpha defines the rotation around first axis
  4696. * @param beta defines the rotation around second axis
  4697. * @param gamma defines the rotation around third axis
  4698. * @param result defines the target quaternion
  4699. */
  4700. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4701. /**
  4702. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4703. * @param axis1 defines the first axis
  4704. * @param axis2 defines the second axis
  4705. * @param axis3 defines the third axis
  4706. * @returns the new quaternion
  4707. */
  4708. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4709. /**
  4710. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4711. * @param axis1 defines the first axis
  4712. * @param axis2 defines the second axis
  4713. * @param axis3 defines the third axis
  4714. * @param ref defines the target quaternion
  4715. */
  4716. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4717. /**
  4718. * Interpolates between two quaternions
  4719. * @param left defines first quaternion
  4720. * @param right defines second quaternion
  4721. * @param amount defines the gradient to use
  4722. * @returns the new interpolated quaternion
  4723. */
  4724. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4725. /**
  4726. * Interpolates between two quaternions and stores it into a target quaternion
  4727. * @param left defines first quaternion
  4728. * @param right defines second quaternion
  4729. * @param amount defines the gradient to use
  4730. * @param result defines the target quaternion
  4731. */
  4732. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4733. /**
  4734. * Interpolate between two quaternions using Hermite interpolation
  4735. * @param value1 defines first quaternion
  4736. * @param tangent1 defines the incoming tangent
  4737. * @param value2 defines second quaternion
  4738. * @param tangent2 defines the outgoing tangent
  4739. * @param amount defines the target quaternion
  4740. * @returns the new interpolated quaternion
  4741. */
  4742. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4743. }
  4744. /**
  4745. * Class used to store matrix data (4x4)
  4746. */
  4747. export class Matrix {
  4748. /**
  4749. * Gets the precision of matrix computations
  4750. */
  4751. static get Use64Bits(): boolean;
  4752. private static _updateFlagSeed;
  4753. private static _identityReadOnly;
  4754. private _isIdentity;
  4755. private _isIdentityDirty;
  4756. private _isIdentity3x2;
  4757. private _isIdentity3x2Dirty;
  4758. /**
  4759. * Gets the update flag of the matrix which is an unique number for the matrix.
  4760. * It will be incremented every time the matrix data change.
  4761. * You can use it to speed the comparison between two versions of the same matrix.
  4762. */
  4763. updateFlag: number;
  4764. private readonly _m;
  4765. /**
  4766. * Gets the internal data of the matrix
  4767. */
  4768. get m(): DeepImmutable<Float32Array | Array<number>>;
  4769. /** @hidden */
  4770. _markAsUpdated(): void;
  4771. /** @hidden */
  4772. private _updateIdentityStatus;
  4773. /**
  4774. * Creates an empty matrix (filled with zeros)
  4775. */
  4776. constructor();
  4777. /**
  4778. * Check if the current matrix is identity
  4779. * @returns true is the matrix is the identity matrix
  4780. */
  4781. isIdentity(): boolean;
  4782. /**
  4783. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4784. * @returns true is the matrix is the identity matrix
  4785. */
  4786. isIdentityAs3x2(): boolean;
  4787. /**
  4788. * Gets the determinant of the matrix
  4789. * @returns the matrix determinant
  4790. */
  4791. determinant(): number;
  4792. /**
  4793. * Returns the matrix as a Float32Array or Array<number>
  4794. * @returns the matrix underlying array
  4795. */
  4796. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4797. /**
  4798. * Returns the matrix as a Float32Array or Array<number>
  4799. * @returns the matrix underlying array.
  4800. */
  4801. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4802. /**
  4803. * Inverts the current matrix in place
  4804. * @returns the current inverted matrix
  4805. */
  4806. invert(): Matrix;
  4807. /**
  4808. * Sets all the matrix elements to zero
  4809. * @returns the current matrix
  4810. */
  4811. reset(): Matrix;
  4812. /**
  4813. * Adds the current matrix with a second one
  4814. * @param other defines the matrix to add
  4815. * @returns a new matrix as the addition of the current matrix and the given one
  4816. */
  4817. add(other: DeepImmutable<Matrix>): Matrix;
  4818. /**
  4819. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4820. * @param other defines the matrix to add
  4821. * @param result defines the target matrix
  4822. * @returns the current matrix
  4823. */
  4824. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4825. /**
  4826. * Adds in place the given matrix to the current matrix
  4827. * @param other defines the second operand
  4828. * @returns the current updated matrix
  4829. */
  4830. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4831. /**
  4832. * Sets the given matrix to the current inverted Matrix
  4833. * @param other defines the target matrix
  4834. * @returns the unmodified current matrix
  4835. */
  4836. invertToRef(other: Matrix): Matrix;
  4837. /**
  4838. * add a value at the specified position in the current Matrix
  4839. * @param index the index of the value within the matrix. between 0 and 15.
  4840. * @param value the value to be added
  4841. * @returns the current updated matrix
  4842. */
  4843. addAtIndex(index: number, value: number): Matrix;
  4844. /**
  4845. * mutiply the specified position in the current Matrix by a value
  4846. * @param index the index of the value within the matrix. between 0 and 15.
  4847. * @param value the value to be added
  4848. * @returns the current updated matrix
  4849. */
  4850. multiplyAtIndex(index: number, value: number): Matrix;
  4851. /**
  4852. * Inserts the translation vector (using 3 floats) in the current matrix
  4853. * @param x defines the 1st component of the translation
  4854. * @param y defines the 2nd component of the translation
  4855. * @param z defines the 3rd component of the translation
  4856. * @returns the current updated matrix
  4857. */
  4858. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4859. /**
  4860. * Adds the translation vector (using 3 floats) in the current matrix
  4861. * @param x defines the 1st component of the translation
  4862. * @param y defines the 2nd component of the translation
  4863. * @param z defines the 3rd component of the translation
  4864. * @returns the current updated matrix
  4865. */
  4866. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4867. /**
  4868. * Inserts the translation vector in the current matrix
  4869. * @param vector3 defines the translation to insert
  4870. * @returns the current updated matrix
  4871. */
  4872. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4873. /**
  4874. * Gets the translation value of the current matrix
  4875. * @returns a new Vector3 as the extracted translation from the matrix
  4876. */
  4877. getTranslation(): Vector3;
  4878. /**
  4879. * Fill a Vector3 with the extracted translation from the matrix
  4880. * @param result defines the Vector3 where to store the translation
  4881. * @returns the current matrix
  4882. */
  4883. getTranslationToRef(result: Vector3): Matrix;
  4884. /**
  4885. * Remove rotation and scaling part from the matrix
  4886. * @returns the updated matrix
  4887. */
  4888. removeRotationAndScaling(): Matrix;
  4889. /**
  4890. * Multiply two matrices
  4891. * @param other defines the second operand
  4892. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4893. */
  4894. multiply(other: DeepImmutable<Matrix>): Matrix;
  4895. /**
  4896. * Copy the current matrix from the given one
  4897. * @param other defines the source matrix
  4898. * @returns the current updated matrix
  4899. */
  4900. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4901. /**
  4902. * Populates the given array from the starting index with the current matrix values
  4903. * @param array defines the target array
  4904. * @param offset defines the offset in the target array where to start storing values
  4905. * @returns the current matrix
  4906. */
  4907. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4908. /**
  4909. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4910. * @param other defines the second operand
  4911. * @param result defines the matrix where to store the multiplication
  4912. * @returns the current matrix
  4913. */
  4914. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4915. /**
  4916. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4917. * @param other defines the second operand
  4918. * @param result defines the array where to store the multiplication
  4919. * @param offset defines the offset in the target array where to start storing values
  4920. * @returns the current matrix
  4921. */
  4922. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4923. /**
  4924. * Check equality between this matrix and a second one
  4925. * @param value defines the second matrix to compare
  4926. * @returns true is the current matrix and the given one values are strictly equal
  4927. */
  4928. equals(value: DeepImmutable<Matrix>): boolean;
  4929. /**
  4930. * Clone the current matrix
  4931. * @returns a new matrix from the current matrix
  4932. */
  4933. clone(): Matrix;
  4934. /**
  4935. * Returns the name of the current matrix class
  4936. * @returns the string "Matrix"
  4937. */
  4938. getClassName(): string;
  4939. /**
  4940. * Gets the hash code of the current matrix
  4941. * @returns the hash code
  4942. */
  4943. getHashCode(): number;
  4944. /**
  4945. * Decomposes the current Matrix into a translation, rotation and scaling components
  4946. * @param scale defines the scale vector3 given as a reference to update
  4947. * @param rotation defines the rotation quaternion given as a reference to update
  4948. * @param translation defines the translation vector3 given as a reference to update
  4949. * @returns true if operation was successful
  4950. */
  4951. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4952. /**
  4953. * Gets specific row of the matrix
  4954. * @param index defines the number of the row to get
  4955. * @returns the index-th row of the current matrix as a new Vector4
  4956. */
  4957. getRow(index: number): Nullable<Vector4>;
  4958. /**
  4959. * Sets the index-th row of the current matrix to the vector4 values
  4960. * @param index defines the number of the row to set
  4961. * @param row defines the target vector4
  4962. * @returns the updated current matrix
  4963. */
  4964. setRow(index: number, row: Vector4): Matrix;
  4965. /**
  4966. * Compute the transpose of the matrix
  4967. * @returns the new transposed matrix
  4968. */
  4969. transpose(): Matrix;
  4970. /**
  4971. * Compute the transpose of the matrix and store it in a given matrix
  4972. * @param result defines the target matrix
  4973. * @returns the current matrix
  4974. */
  4975. transposeToRef(result: Matrix): Matrix;
  4976. /**
  4977. * Sets the index-th row of the current matrix with the given 4 x float values
  4978. * @param index defines the row index
  4979. * @param x defines the x component to set
  4980. * @param y defines the y component to set
  4981. * @param z defines the z component to set
  4982. * @param w defines the w component to set
  4983. * @returns the updated current matrix
  4984. */
  4985. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4986. /**
  4987. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4988. * @param scale defines the scale factor
  4989. * @returns a new matrix
  4990. */
  4991. scale(scale: number): Matrix;
  4992. /**
  4993. * Scale the current matrix values by a factor to a given result matrix
  4994. * @param scale defines the scale factor
  4995. * @param result defines the matrix to store the result
  4996. * @returns the current matrix
  4997. */
  4998. scaleToRef(scale: number, result: Matrix): Matrix;
  4999. /**
  5000. * Scale the current matrix values by a factor and add the result to a given matrix
  5001. * @param scale defines the scale factor
  5002. * @param result defines the Matrix to store the result
  5003. * @returns the current matrix
  5004. */
  5005. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5006. /**
  5007. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5008. * @param ref matrix to store the result
  5009. */
  5010. toNormalMatrix(ref: Matrix): void;
  5011. /**
  5012. * Gets only rotation part of the current matrix
  5013. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5014. */
  5015. getRotationMatrix(): Matrix;
  5016. /**
  5017. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5018. * @param result defines the target matrix to store data to
  5019. * @returns the current matrix
  5020. */
  5021. getRotationMatrixToRef(result: Matrix): Matrix;
  5022. /**
  5023. * Toggles model matrix from being right handed to left handed in place and vice versa
  5024. */
  5025. toggleModelMatrixHandInPlace(): void;
  5026. /**
  5027. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5028. */
  5029. toggleProjectionMatrixHandInPlace(): void;
  5030. /**
  5031. * Creates a matrix from an array
  5032. * @param array defines the source array
  5033. * @param offset defines an offset in the source array
  5034. * @returns a new Matrix set from the starting index of the given array
  5035. */
  5036. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5037. /**
  5038. * Copy the content of an array into a given matrix
  5039. * @param array defines the source array
  5040. * @param offset defines an offset in the source array
  5041. * @param result defines the target matrix
  5042. */
  5043. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5044. /**
  5045. * Stores an array into a matrix after having multiplied each component by a given factor
  5046. * @param array defines the source array
  5047. * @param offset defines the offset in the source array
  5048. * @param scale defines the scaling factor
  5049. * @param result defines the target matrix
  5050. */
  5051. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5052. /**
  5053. * Gets an identity matrix that must not be updated
  5054. */
  5055. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5056. /**
  5057. * Stores a list of values (16) inside a given matrix
  5058. * @param initialM11 defines 1st value of 1st row
  5059. * @param initialM12 defines 2nd value of 1st row
  5060. * @param initialM13 defines 3rd value of 1st row
  5061. * @param initialM14 defines 4th value of 1st row
  5062. * @param initialM21 defines 1st value of 2nd row
  5063. * @param initialM22 defines 2nd value of 2nd row
  5064. * @param initialM23 defines 3rd value of 2nd row
  5065. * @param initialM24 defines 4th value of 2nd row
  5066. * @param initialM31 defines 1st value of 3rd row
  5067. * @param initialM32 defines 2nd value of 3rd row
  5068. * @param initialM33 defines 3rd value of 3rd row
  5069. * @param initialM34 defines 4th value of 3rd row
  5070. * @param initialM41 defines 1st value of 4th row
  5071. * @param initialM42 defines 2nd value of 4th row
  5072. * @param initialM43 defines 3rd value of 4th row
  5073. * @param initialM44 defines 4th value of 4th row
  5074. * @param result defines the target matrix
  5075. */
  5076. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  5077. /**
  5078. * Creates new matrix from a list of values (16)
  5079. * @param initialM11 defines 1st value of 1st row
  5080. * @param initialM12 defines 2nd value of 1st row
  5081. * @param initialM13 defines 3rd value of 1st row
  5082. * @param initialM14 defines 4th value of 1st row
  5083. * @param initialM21 defines 1st value of 2nd row
  5084. * @param initialM22 defines 2nd value of 2nd row
  5085. * @param initialM23 defines 3rd value of 2nd row
  5086. * @param initialM24 defines 4th value of 2nd row
  5087. * @param initialM31 defines 1st value of 3rd row
  5088. * @param initialM32 defines 2nd value of 3rd row
  5089. * @param initialM33 defines 3rd value of 3rd row
  5090. * @param initialM34 defines 4th value of 3rd row
  5091. * @param initialM41 defines 1st value of 4th row
  5092. * @param initialM42 defines 2nd value of 4th row
  5093. * @param initialM43 defines 3rd value of 4th row
  5094. * @param initialM44 defines 4th value of 4th row
  5095. * @returns the new matrix
  5096. */
  5097. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  5098. /**
  5099. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5100. * @param scale defines the scale vector3
  5101. * @param rotation defines the rotation quaternion
  5102. * @param translation defines the translation vector3
  5103. * @returns a new matrix
  5104. */
  5105. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5106. /**
  5107. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5108. * @param scale defines the scale vector3
  5109. * @param rotation defines the rotation quaternion
  5110. * @param translation defines the translation vector3
  5111. * @param result defines the target matrix
  5112. */
  5113. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5114. /**
  5115. * Creates a new identity matrix
  5116. * @returns a new identity matrix
  5117. */
  5118. static Identity(): Matrix;
  5119. /**
  5120. * Creates a new identity matrix and stores the result in a given matrix
  5121. * @param result defines the target matrix
  5122. */
  5123. static IdentityToRef(result: Matrix): void;
  5124. /**
  5125. * Creates a new zero matrix
  5126. * @returns a new zero matrix
  5127. */
  5128. static Zero(): Matrix;
  5129. /**
  5130. * Creates a new rotation matrix for "angle" radians around the X axis
  5131. * @param angle defines the angle (in radians) to use
  5132. * @return the new matrix
  5133. */
  5134. static RotationX(angle: number): Matrix;
  5135. /**
  5136. * Creates a new matrix as the invert of a given matrix
  5137. * @param source defines the source matrix
  5138. * @returns the new matrix
  5139. */
  5140. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5141. /**
  5142. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5143. * @param angle defines the angle (in radians) to use
  5144. * @param result defines the target matrix
  5145. */
  5146. static RotationXToRef(angle: number, result: Matrix): void;
  5147. /**
  5148. * Creates a new rotation matrix for "angle" radians around the Y axis
  5149. * @param angle defines the angle (in radians) to use
  5150. * @return the new matrix
  5151. */
  5152. static RotationY(angle: number): Matrix;
  5153. /**
  5154. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5155. * @param angle defines the angle (in radians) to use
  5156. * @param result defines the target matrix
  5157. */
  5158. static RotationYToRef(angle: number, result: Matrix): void;
  5159. /**
  5160. * Creates a new rotation matrix for "angle" radians around the Z axis
  5161. * @param angle defines the angle (in radians) to use
  5162. * @return the new matrix
  5163. */
  5164. static RotationZ(angle: number): Matrix;
  5165. /**
  5166. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5167. * @param angle defines the angle (in radians) to use
  5168. * @param result defines the target matrix
  5169. */
  5170. static RotationZToRef(angle: number, result: Matrix): void;
  5171. /**
  5172. * Creates a new rotation matrix for "angle" radians around the given axis
  5173. * @param axis defines the axis to use
  5174. * @param angle defines the angle (in radians) to use
  5175. * @return the new matrix
  5176. */
  5177. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5178. /**
  5179. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5180. * @param axis defines the axis to use
  5181. * @param angle defines the angle (in radians) to use
  5182. * @param result defines the target matrix
  5183. */
  5184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5185. /**
  5186. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5187. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5188. * @param from defines the vector to align
  5189. * @param to defines the vector to align to
  5190. * @param result defines the target matrix
  5191. */
  5192. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5193. /**
  5194. * Creates a rotation matrix
  5195. * @param yaw defines the yaw angle in radians (Y axis)
  5196. * @param pitch defines the pitch angle in radians (X axis)
  5197. * @param roll defines the roll angle in radians (Z axis)
  5198. * @returns the new rotation matrix
  5199. */
  5200. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5201. /**
  5202. * Creates a rotation matrix and stores it in a given matrix
  5203. * @param yaw defines the yaw angle in radians (Y axis)
  5204. * @param pitch defines the pitch angle in radians (X axis)
  5205. * @param roll defines the roll angle in radians (Z axis)
  5206. * @param result defines the target matrix
  5207. */
  5208. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5209. /**
  5210. * Creates a scaling matrix
  5211. * @param x defines the scale factor on X axis
  5212. * @param y defines the scale factor on Y axis
  5213. * @param z defines the scale factor on Z axis
  5214. * @returns the new matrix
  5215. */
  5216. static Scaling(x: number, y: number, z: number): Matrix;
  5217. /**
  5218. * Creates a scaling matrix and stores it in a given matrix
  5219. * @param x defines the scale factor on X axis
  5220. * @param y defines the scale factor on Y axis
  5221. * @param z defines the scale factor on Z axis
  5222. * @param result defines the target matrix
  5223. */
  5224. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5225. /**
  5226. * Creates a translation matrix
  5227. * @param x defines the translation on X axis
  5228. * @param y defines the translation on Y axis
  5229. * @param z defines the translationon Z axis
  5230. * @returns the new matrix
  5231. */
  5232. static Translation(x: number, y: number, z: number): Matrix;
  5233. /**
  5234. * Creates a translation matrix and stores it in a given matrix
  5235. * @param x defines the translation on X axis
  5236. * @param y defines the translation on Y axis
  5237. * @param z defines the translationon Z axis
  5238. * @param result defines the target matrix
  5239. */
  5240. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5241. /**
  5242. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5243. * @param startValue defines the start value
  5244. * @param endValue defines the end value
  5245. * @param gradient defines the gradient factor
  5246. * @returns the new matrix
  5247. */
  5248. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5249. /**
  5250. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5251. * @param startValue defines the start value
  5252. * @param endValue defines the end value
  5253. * @param gradient defines the gradient factor
  5254. * @param result defines the Matrix object where to store data
  5255. */
  5256. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5257. /**
  5258. * Builds a new matrix whose values are computed by:
  5259. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5260. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5261. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5262. * @param startValue defines the first matrix
  5263. * @param endValue defines the second matrix
  5264. * @param gradient defines the gradient between the two matrices
  5265. * @returns the new matrix
  5266. */
  5267. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5268. /**
  5269. * Update a matrix to values which are computed by:
  5270. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5271. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5272. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5273. * @param startValue defines the first matrix
  5274. * @param endValue defines the second matrix
  5275. * @param gradient defines the gradient between the two matrices
  5276. * @param result defines the target matrix
  5277. */
  5278. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5279. /**
  5280. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5281. * This function works in left handed mode
  5282. * @param eye defines the final position of the entity
  5283. * @param target defines where the entity should look at
  5284. * @param up defines the up vector for the entity
  5285. * @returns the new matrix
  5286. */
  5287. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5288. /**
  5289. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5290. * This function works in left handed mode
  5291. * @param eye defines the final position of the entity
  5292. * @param target defines where the entity should look at
  5293. * @param up defines the up vector for the entity
  5294. * @param result defines the target matrix
  5295. */
  5296. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5297. /**
  5298. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5299. * This function works in right handed mode
  5300. * @param eye defines the final position of the entity
  5301. * @param target defines where the entity should look at
  5302. * @param up defines the up vector for the entity
  5303. * @returns the new matrix
  5304. */
  5305. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5306. /**
  5307. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5308. * This function works in right handed mode
  5309. * @param eye defines the final position of the entity
  5310. * @param target defines where the entity should look at
  5311. * @param up defines the up vector for the entity
  5312. * @param result defines the target matrix
  5313. */
  5314. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5315. /**
  5316. * Create a left-handed orthographic projection matrix
  5317. * @param width defines the viewport width
  5318. * @param height defines the viewport height
  5319. * @param znear defines the near clip plane
  5320. * @param zfar defines the far clip plane
  5321. * @returns a new matrix as a left-handed orthographic projection matrix
  5322. */
  5323. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5324. /**
  5325. * Store a left-handed orthographic projection to a given matrix
  5326. * @param width defines the viewport width
  5327. * @param height defines the viewport height
  5328. * @param znear defines the near clip plane
  5329. * @param zfar defines the far clip plane
  5330. * @param result defines the target matrix
  5331. */
  5332. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5333. /**
  5334. * Create a left-handed orthographic projection matrix
  5335. * @param left defines the viewport left coordinate
  5336. * @param right defines the viewport right coordinate
  5337. * @param bottom defines the viewport bottom coordinate
  5338. * @param top defines the viewport top coordinate
  5339. * @param znear defines the near clip plane
  5340. * @param zfar defines the far clip plane
  5341. * @returns a new matrix as a left-handed orthographic projection matrix
  5342. */
  5343. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5344. /**
  5345. * Stores a left-handed orthographic projection into a given matrix
  5346. * @param left defines the viewport left coordinate
  5347. * @param right defines the viewport right coordinate
  5348. * @param bottom defines the viewport bottom coordinate
  5349. * @param top defines the viewport top coordinate
  5350. * @param znear defines the near clip plane
  5351. * @param zfar defines the far clip plane
  5352. * @param result defines the target matrix
  5353. */
  5354. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5355. /**
  5356. * Creates a right-handed orthographic projection matrix
  5357. * @param left defines the viewport left coordinate
  5358. * @param right defines the viewport right coordinate
  5359. * @param bottom defines the viewport bottom coordinate
  5360. * @param top defines the viewport top coordinate
  5361. * @param znear defines the near clip plane
  5362. * @param zfar defines the far clip plane
  5363. * @returns a new matrix as a right-handed orthographic projection matrix
  5364. */
  5365. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5366. /**
  5367. * Stores a right-handed orthographic projection into a given matrix
  5368. * @param left defines the viewport left coordinate
  5369. * @param right defines the viewport right coordinate
  5370. * @param bottom defines the viewport bottom coordinate
  5371. * @param top defines the viewport top coordinate
  5372. * @param znear defines the near clip plane
  5373. * @param zfar defines the far clip plane
  5374. * @param result defines the target matrix
  5375. */
  5376. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5377. /**
  5378. * Creates a left-handed perspective projection matrix
  5379. * @param width defines the viewport width
  5380. * @param height defines the viewport height
  5381. * @param znear defines the near clip plane
  5382. * @param zfar defines the far clip plane
  5383. * @returns a new matrix as a left-handed perspective projection matrix
  5384. */
  5385. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5386. /**
  5387. * Creates a left-handed perspective projection matrix
  5388. * @param fov defines the horizontal field of view
  5389. * @param aspect defines the aspect ratio
  5390. * @param znear defines the near clip plane
  5391. * @param zfar defines the far clip plane
  5392. * @returns a new matrix as a left-handed perspective projection matrix
  5393. */
  5394. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5395. /**
  5396. * Stores a left-handed perspective projection into a given matrix
  5397. * @param fov defines the horizontal field of view
  5398. * @param aspect defines the aspect ratio
  5399. * @param znear defines the near clip plane
  5400. * @param zfar defines the far clip plane
  5401. * @param result defines the target matrix
  5402. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5403. */
  5404. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5405. /**
  5406. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5407. * @param fov defines the horizontal field of view
  5408. * @param aspect defines the aspect ratio
  5409. * @param znear defines the near clip plane
  5410. * @param zfar not used as infinity is used as far clip
  5411. * @param result defines the target matrix
  5412. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5413. */
  5414. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5415. /**
  5416. * Creates a right-handed perspective projection matrix
  5417. * @param fov defines the horizontal field of view
  5418. * @param aspect defines the aspect ratio
  5419. * @param znear defines the near clip plane
  5420. * @param zfar defines the far clip plane
  5421. * @returns a new matrix as a right-handed perspective projection matrix
  5422. */
  5423. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5424. /**
  5425. * Stores a right-handed perspective projection into a given matrix
  5426. * @param fov defines the horizontal field of view
  5427. * @param aspect defines the aspect ratio
  5428. * @param znear defines the near clip plane
  5429. * @param zfar defines the far clip plane
  5430. * @param result defines the target matrix
  5431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5432. */
  5433. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5434. /**
  5435. * Stores a right-handed perspective projection into a given matrix
  5436. * @param fov defines the horizontal field of view
  5437. * @param aspect defines the aspect ratio
  5438. * @param znear defines the near clip plane
  5439. * @param zfar not used as infinity is used as far clip
  5440. * @param result defines the target matrix
  5441. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5442. */
  5443. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5444. /**
  5445. * Stores a perspective projection for WebVR info a given matrix
  5446. * @param fov defines the field of view
  5447. * @param znear defines the near clip plane
  5448. * @param zfar defines the far clip plane
  5449. * @param result defines the target matrix
  5450. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5451. */
  5452. static PerspectiveFovWebVRToRef(fov: {
  5453. upDegrees: number;
  5454. downDegrees: number;
  5455. leftDegrees: number;
  5456. rightDegrees: number;
  5457. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5458. /**
  5459. * Computes a complete transformation matrix
  5460. * @param viewport defines the viewport to use
  5461. * @param world defines the world matrix
  5462. * @param view defines the view matrix
  5463. * @param projection defines the projection matrix
  5464. * @param zmin defines the near clip plane
  5465. * @param zmax defines the far clip plane
  5466. * @returns the transformation matrix
  5467. */
  5468. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5469. /**
  5470. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5471. * @param matrix defines the matrix to use
  5472. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5473. */
  5474. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5475. /**
  5476. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5477. * @param matrix defines the matrix to use
  5478. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5479. */
  5480. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5481. /**
  5482. * Compute the transpose of a given matrix
  5483. * @param matrix defines the matrix to transpose
  5484. * @returns the new matrix
  5485. */
  5486. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5487. /**
  5488. * Compute the transpose of a matrix and store it in a target matrix
  5489. * @param matrix defines the matrix to transpose
  5490. * @param result defines the target matrix
  5491. */
  5492. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5493. /**
  5494. * Computes a reflection matrix from a plane
  5495. * @param plane defines the reflection plane
  5496. * @returns a new matrix
  5497. */
  5498. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5499. /**
  5500. * Computes a reflection matrix from a plane
  5501. * @param plane defines the reflection plane
  5502. * @param result defines the target matrix
  5503. */
  5504. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5505. /**
  5506. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5507. * @param xaxis defines the value of the 1st axis
  5508. * @param yaxis defines the value of the 2nd axis
  5509. * @param zaxis defines the value of the 3rd axis
  5510. * @param result defines the target matrix
  5511. */
  5512. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5513. /**
  5514. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5515. * @param quat defines the quaternion to use
  5516. * @param result defines the target matrix
  5517. */
  5518. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5519. }
  5520. /**
  5521. * @hidden
  5522. */
  5523. export class TmpVectors {
  5524. static Vector2: Vector2[];
  5525. static Vector3: Vector3[];
  5526. static Vector4: Vector4[];
  5527. static Quaternion: Quaternion[];
  5528. static Matrix: Matrix[];
  5529. }
  5530. }
  5531. declare module BABYLON {
  5532. /**
  5533. * Defines potential orientation for back face culling
  5534. */
  5535. export enum Orientation {
  5536. /**
  5537. * Clockwise
  5538. */
  5539. CW = 0,
  5540. /** Counter clockwise */
  5541. CCW = 1
  5542. }
  5543. /** Class used to represent a Bezier curve */
  5544. export class BezierCurve {
  5545. /**
  5546. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5547. * @param t defines the time
  5548. * @param x1 defines the left coordinate on X axis
  5549. * @param y1 defines the left coordinate on Y axis
  5550. * @param x2 defines the right coordinate on X axis
  5551. * @param y2 defines the right coordinate on Y axis
  5552. * @returns the interpolated value
  5553. */
  5554. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5555. }
  5556. /**
  5557. * Defines angle representation
  5558. */
  5559. export class Angle {
  5560. private _radians;
  5561. /**
  5562. * Creates an Angle object of "radians" radians (float).
  5563. * @param radians the angle in radians
  5564. */
  5565. constructor(radians: number);
  5566. /**
  5567. * Get value in degrees
  5568. * @returns the Angle value in degrees (float)
  5569. */
  5570. degrees(): number;
  5571. /**
  5572. * Get value in radians
  5573. * @returns the Angle value in radians (float)
  5574. */
  5575. radians(): number;
  5576. /**
  5577. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5578. * @param a defines first point as the origin
  5579. * @param b defines point
  5580. * @returns a new Angle
  5581. */
  5582. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5583. /**
  5584. * Gets a new Angle object from the given float in radians
  5585. * @param radians defines the angle value in radians
  5586. * @returns a new Angle
  5587. */
  5588. static FromRadians(radians: number): Angle;
  5589. /**
  5590. * Gets a new Angle object from the given float in degrees
  5591. * @param degrees defines the angle value in degrees
  5592. * @returns a new Angle
  5593. */
  5594. static FromDegrees(degrees: number): Angle;
  5595. }
  5596. /**
  5597. * This represents an arc in a 2d space.
  5598. */
  5599. export class Arc2 {
  5600. /** Defines the start point of the arc */
  5601. startPoint: Vector2;
  5602. /** Defines the mid point of the arc */
  5603. midPoint: Vector2;
  5604. /** Defines the end point of the arc */
  5605. endPoint: Vector2;
  5606. /**
  5607. * Defines the center point of the arc.
  5608. */
  5609. centerPoint: Vector2;
  5610. /**
  5611. * Defines the radius of the arc.
  5612. */
  5613. radius: number;
  5614. /**
  5615. * Defines the angle of the arc (from mid point to end point).
  5616. */
  5617. angle: Angle;
  5618. /**
  5619. * Defines the start angle of the arc (from start point to middle point).
  5620. */
  5621. startAngle: Angle;
  5622. /**
  5623. * Defines the orientation of the arc (clock wise/counter clock wise).
  5624. */
  5625. orientation: Orientation;
  5626. /**
  5627. * Creates an Arc object from the three given points : start, middle and end.
  5628. * @param startPoint Defines the start point of the arc
  5629. * @param midPoint Defines the midlle point of the arc
  5630. * @param endPoint Defines the end point of the arc
  5631. */
  5632. constructor(
  5633. /** Defines the start point of the arc */
  5634. startPoint: Vector2,
  5635. /** Defines the mid point of the arc */
  5636. midPoint: Vector2,
  5637. /** Defines the end point of the arc */
  5638. endPoint: Vector2);
  5639. }
  5640. /**
  5641. * Represents a 2D path made up of multiple 2D points
  5642. */
  5643. export class Path2 {
  5644. private _points;
  5645. private _length;
  5646. /**
  5647. * If the path start and end point are the same
  5648. */
  5649. closed: boolean;
  5650. /**
  5651. * Creates a Path2 object from the starting 2D coordinates x and y.
  5652. * @param x the starting points x value
  5653. * @param y the starting points y value
  5654. */
  5655. constructor(x: number, y: number);
  5656. /**
  5657. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5658. * @param x the added points x value
  5659. * @param y the added points y value
  5660. * @returns the updated Path2.
  5661. */
  5662. addLineTo(x: number, y: number): Path2;
  5663. /**
  5664. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5665. * @param midX middle point x value
  5666. * @param midY middle point y value
  5667. * @param endX end point x value
  5668. * @param endY end point y value
  5669. * @param numberOfSegments (default: 36)
  5670. * @returns the updated Path2.
  5671. */
  5672. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5673. /**
  5674. * Closes the Path2.
  5675. * @returns the Path2.
  5676. */
  5677. close(): Path2;
  5678. /**
  5679. * Gets the sum of the distance between each sequential point in the path
  5680. * @returns the Path2 total length (float).
  5681. */
  5682. length(): number;
  5683. /**
  5684. * Gets the points which construct the path
  5685. * @returns the Path2 internal array of points.
  5686. */
  5687. getPoints(): Vector2[];
  5688. /**
  5689. * Retreives the point at the distance aways from the starting point
  5690. * @param normalizedLengthPosition the length along the path to retreive the point from
  5691. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5692. */
  5693. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5694. /**
  5695. * Creates a new path starting from an x and y position
  5696. * @param x starting x value
  5697. * @param y starting y value
  5698. * @returns a new Path2 starting at the coordinates (x, y).
  5699. */
  5700. static StartingAt(x: number, y: number): Path2;
  5701. }
  5702. /**
  5703. * Represents a 3D path made up of multiple 3D points
  5704. */
  5705. export class Path3D {
  5706. /**
  5707. * an array of Vector3, the curve axis of the Path3D
  5708. */
  5709. path: Vector3[];
  5710. private _curve;
  5711. private _distances;
  5712. private _tangents;
  5713. private _normals;
  5714. private _binormals;
  5715. private _raw;
  5716. private _alignTangentsWithPath;
  5717. private readonly _pointAtData;
  5718. /**
  5719. * new Path3D(path, normal, raw)
  5720. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5721. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5722. * @param path an array of Vector3, the curve axis of the Path3D
  5723. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5724. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5725. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5726. */
  5727. constructor(
  5728. /**
  5729. * an array of Vector3, the curve axis of the Path3D
  5730. */
  5731. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5732. /**
  5733. * Returns the Path3D array of successive Vector3 designing its curve.
  5734. * @returns the Path3D array of successive Vector3 designing its curve.
  5735. */
  5736. getCurve(): Vector3[];
  5737. /**
  5738. * Returns the Path3D array of successive Vector3 designing its curve.
  5739. * @returns the Path3D array of successive Vector3 designing its curve.
  5740. */
  5741. getPoints(): Vector3[];
  5742. /**
  5743. * @returns the computed length (float) of the path.
  5744. */
  5745. length(): number;
  5746. /**
  5747. * Returns an array populated with tangent vectors on each Path3D curve point.
  5748. * @returns an array populated with tangent vectors on each Path3D curve point.
  5749. */
  5750. getTangents(): Vector3[];
  5751. /**
  5752. * Returns an array populated with normal vectors on each Path3D curve point.
  5753. * @returns an array populated with normal vectors on each Path3D curve point.
  5754. */
  5755. getNormals(): Vector3[];
  5756. /**
  5757. * Returns an array populated with binormal vectors on each Path3D curve point.
  5758. * @returns an array populated with binormal vectors on each Path3D curve point.
  5759. */
  5760. getBinormals(): Vector3[];
  5761. /**
  5762. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5763. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5764. */
  5765. getDistances(): number[];
  5766. /**
  5767. * Returns an interpolated point along this path
  5768. * @param position the position of the point along this path, from 0.0 to 1.0
  5769. * @returns a new Vector3 as the point
  5770. */
  5771. getPointAt(position: number): Vector3;
  5772. /**
  5773. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5774. * @param position the position of the point along this path, from 0.0 to 1.0
  5775. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5776. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5777. */
  5778. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5779. /**
  5780. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5781. * @param position the position of the point along this path, from 0.0 to 1.0
  5782. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5783. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5784. */
  5785. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5786. /**
  5787. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5788. * @param position the position of the point along this path, from 0.0 to 1.0
  5789. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5790. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5791. */
  5792. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5793. /**
  5794. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5795. * @param position the position of the point along this path, from 0.0 to 1.0
  5796. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5797. */
  5798. getDistanceAt(position: number): number;
  5799. /**
  5800. * Returns the array index of the previous point of an interpolated point along this path
  5801. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5802. * @returns the array index
  5803. */
  5804. getPreviousPointIndexAt(position: number): number;
  5805. /**
  5806. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5807. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5808. * @returns the sub position
  5809. */
  5810. getSubPositionAt(position: number): number;
  5811. /**
  5812. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5813. * @param target the vector of which to get the closest position to
  5814. * @returns the position of the closest virtual point on this path to the target vector
  5815. */
  5816. getClosestPositionTo(target: Vector3): number;
  5817. /**
  5818. * Returns a sub path (slice) of this path
  5819. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5820. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5821. * @returns a sub path (slice) of this path
  5822. */
  5823. slice(start?: number, end?: number): Path3D;
  5824. /**
  5825. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5826. * @param path path which all values are copied into the curves points
  5827. * @param firstNormal which should be projected onto the curve
  5828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5829. * @returns the same object updated.
  5830. */
  5831. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5832. private _compute;
  5833. private _getFirstNonNullVector;
  5834. private _getLastNonNullVector;
  5835. private _normalVector;
  5836. /**
  5837. * Updates the point at data for an interpolated point along this curve
  5838. * @param position the position of the point along this curve, from 0.0 to 1.0
  5839. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5840. * @returns the (updated) point at data
  5841. */
  5842. private _updatePointAtData;
  5843. /**
  5844. * Updates the point at data from the specified parameters
  5845. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5846. * @param point the interpolated point
  5847. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5848. */
  5849. private _setPointAtData;
  5850. /**
  5851. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5852. */
  5853. private _updateInterpolationMatrix;
  5854. }
  5855. /**
  5856. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5857. * A Curve3 is designed from a series of successive Vector3.
  5858. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5859. */
  5860. export class Curve3 {
  5861. private _points;
  5862. private _length;
  5863. /**
  5864. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5865. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5866. * @param v1 (Vector3) the control point
  5867. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5868. * @param nbPoints (integer) the wanted number of points in the curve
  5869. * @returns the created Curve3
  5870. */
  5871. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5872. /**
  5873. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5874. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5875. * @param v1 (Vector3) the first control point
  5876. * @param v2 (Vector3) the second control point
  5877. * @param v3 (Vector3) the end point of the Cubic Bezier
  5878. * @param nbPoints (integer) the wanted number of points in the curve
  5879. * @returns the created Curve3
  5880. */
  5881. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5882. /**
  5883. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5884. * @param p1 (Vector3) the origin point of the Hermite Spline
  5885. * @param t1 (Vector3) the tangent vector at the origin point
  5886. * @param p2 (Vector3) the end point of the Hermite Spline
  5887. * @param t2 (Vector3) the tangent vector at the end point
  5888. * @param nbPoints (integer) the wanted number of points in the curve
  5889. * @returns the created Curve3
  5890. */
  5891. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5892. /**
  5893. * Returns a Curve3 object along a CatmullRom Spline curve :
  5894. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5895. * @param nbPoints (integer) the wanted number of points between each curve control points
  5896. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5897. * @returns the created Curve3
  5898. */
  5899. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5900. /**
  5901. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5902. * A Curve3 is designed from a series of successive Vector3.
  5903. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5904. * @param points points which make up the curve
  5905. */
  5906. constructor(points: Vector3[]);
  5907. /**
  5908. * @returns the Curve3 stored array of successive Vector3
  5909. */
  5910. getPoints(): Vector3[];
  5911. /**
  5912. * @returns the computed length (float) of the curve.
  5913. */
  5914. length(): number;
  5915. /**
  5916. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5917. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5918. * curveA and curveB keep unchanged.
  5919. * @param curve the curve to continue from this curve
  5920. * @returns the newly constructed curve
  5921. */
  5922. continue(curve: DeepImmutable<Curve3>): Curve3;
  5923. private _computeLength;
  5924. }
  5925. }
  5926. declare module BABYLON {
  5927. /**
  5928. * This represents the main contract an easing function should follow.
  5929. * Easing functions are used throughout the animation system.
  5930. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5931. */
  5932. export interface IEasingFunction {
  5933. /**
  5934. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5935. * of the easing function.
  5936. * The link below provides some of the most common examples of easing functions.
  5937. * @see https://easings.net/
  5938. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5939. * @returns the corresponding value on the curve defined by the easing function
  5940. */
  5941. ease(gradient: number): number;
  5942. }
  5943. /**
  5944. * Base class used for every default easing function.
  5945. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5946. */
  5947. export class EasingFunction implements IEasingFunction {
  5948. /**
  5949. * Interpolation follows the mathematical formula associated with the easing function.
  5950. */
  5951. static readonly EASINGMODE_EASEIN: number;
  5952. /**
  5953. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5954. */
  5955. static readonly EASINGMODE_EASEOUT: number;
  5956. /**
  5957. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5958. */
  5959. static readonly EASINGMODE_EASEINOUT: number;
  5960. private _easingMode;
  5961. /**
  5962. * Sets the easing mode of the current function.
  5963. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5964. */
  5965. setEasingMode(easingMode: number): void;
  5966. /**
  5967. * Gets the current easing mode.
  5968. * @returns the easing mode
  5969. */
  5970. getEasingMode(): number;
  5971. /**
  5972. * @hidden
  5973. */
  5974. easeInCore(gradient: number): number;
  5975. /**
  5976. * Given an input gradient between 0 and 1, this returns the corresponding value
  5977. * of the easing function.
  5978. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5979. * @returns the corresponding value on the curve defined by the easing function
  5980. */
  5981. ease(gradient: number): number;
  5982. }
  5983. /**
  5984. * Easing function with a circle shape (see link below).
  5985. * @see https://easings.net/#easeInCirc
  5986. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5987. */
  5988. export class CircleEase extends EasingFunction implements IEasingFunction {
  5989. /** @hidden */
  5990. easeInCore(gradient: number): number;
  5991. }
  5992. /**
  5993. * Easing function with a ease back shape (see link below).
  5994. * @see https://easings.net/#easeInBack
  5995. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5996. */
  5997. export class BackEase extends EasingFunction implements IEasingFunction {
  5998. /** Defines the amplitude of the function */
  5999. amplitude: number;
  6000. /**
  6001. * Instantiates a back ease easing
  6002. * @see https://easings.net/#easeInBack
  6003. * @param amplitude Defines the amplitude of the function
  6004. */
  6005. constructor(
  6006. /** Defines the amplitude of the function */
  6007. amplitude?: number);
  6008. /** @hidden */
  6009. easeInCore(gradient: number): number;
  6010. }
  6011. /**
  6012. * Easing function with a bouncing shape (see link below).
  6013. * @see https://easings.net/#easeInBounce
  6014. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6015. */
  6016. export class BounceEase extends EasingFunction implements IEasingFunction {
  6017. /** Defines the number of bounces */
  6018. bounces: number;
  6019. /** Defines the amplitude of the bounce */
  6020. bounciness: number;
  6021. /**
  6022. * Instantiates a bounce easing
  6023. * @see https://easings.net/#easeInBounce
  6024. * @param bounces Defines the number of bounces
  6025. * @param bounciness Defines the amplitude of the bounce
  6026. */
  6027. constructor(
  6028. /** Defines the number of bounces */
  6029. bounces?: number,
  6030. /** Defines the amplitude of the bounce */
  6031. bounciness?: number);
  6032. /** @hidden */
  6033. easeInCore(gradient: number): number;
  6034. }
  6035. /**
  6036. * Easing function with a power of 3 shape (see link below).
  6037. * @see https://easings.net/#easeInCubic
  6038. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6039. */
  6040. export class CubicEase extends EasingFunction implements IEasingFunction {
  6041. /** @hidden */
  6042. easeInCore(gradient: number): number;
  6043. }
  6044. /**
  6045. * Easing function with an elastic shape (see link below).
  6046. * @see https://easings.net/#easeInElastic
  6047. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6048. */
  6049. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6050. /** Defines the number of oscillations*/
  6051. oscillations: number;
  6052. /** Defines the amplitude of the oscillations*/
  6053. springiness: number;
  6054. /**
  6055. * Instantiates an elastic easing function
  6056. * @see https://easings.net/#easeInElastic
  6057. * @param oscillations Defines the number of oscillations
  6058. * @param springiness Defines the amplitude of the oscillations
  6059. */
  6060. constructor(
  6061. /** Defines the number of oscillations*/
  6062. oscillations?: number,
  6063. /** Defines the amplitude of the oscillations*/
  6064. springiness?: number);
  6065. /** @hidden */
  6066. easeInCore(gradient: number): number;
  6067. }
  6068. /**
  6069. * Easing function with an exponential shape (see link below).
  6070. * @see https://easings.net/#easeInExpo
  6071. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6072. */
  6073. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6074. /** Defines the exponent of the function */
  6075. exponent: number;
  6076. /**
  6077. * Instantiates an exponential easing function
  6078. * @see https://easings.net/#easeInExpo
  6079. * @param exponent Defines the exponent of the function
  6080. */
  6081. constructor(
  6082. /** Defines the exponent of the function */
  6083. exponent?: number);
  6084. /** @hidden */
  6085. easeInCore(gradient: number): number;
  6086. }
  6087. /**
  6088. * Easing function with a power shape (see link below).
  6089. * @see https://easings.net/#easeInQuad
  6090. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6091. */
  6092. export class PowerEase extends EasingFunction implements IEasingFunction {
  6093. /** Defines the power of the function */
  6094. power: number;
  6095. /**
  6096. * Instantiates an power base easing function
  6097. * @see https://easings.net/#easeInQuad
  6098. * @param power Defines the power of the function
  6099. */
  6100. constructor(
  6101. /** Defines the power of the function */
  6102. power?: number);
  6103. /** @hidden */
  6104. easeInCore(gradient: number): number;
  6105. }
  6106. /**
  6107. * Easing function with a power of 2 shape (see link below).
  6108. * @see https://easings.net/#easeInQuad
  6109. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6112. /** @hidden */
  6113. easeInCore(gradient: number): number;
  6114. }
  6115. /**
  6116. * Easing function with a power of 4 shape (see link below).
  6117. * @see https://easings.net/#easeInQuart
  6118. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6119. */
  6120. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6121. /** @hidden */
  6122. easeInCore(gradient: number): number;
  6123. }
  6124. /**
  6125. * Easing function with a power of 5 shape (see link below).
  6126. * @see https://easings.net/#easeInQuint
  6127. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6128. */
  6129. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6130. /** @hidden */
  6131. easeInCore(gradient: number): number;
  6132. }
  6133. /**
  6134. * Easing function with a sin shape (see link below).
  6135. * @see https://easings.net/#easeInSine
  6136. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6137. */
  6138. export class SineEase extends EasingFunction implements IEasingFunction {
  6139. /** @hidden */
  6140. easeInCore(gradient: number): number;
  6141. }
  6142. /**
  6143. * Easing function with a bezier shape (see link below).
  6144. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6145. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6146. */
  6147. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6148. /** Defines the x component of the start tangent in the bezier curve */
  6149. x1: number;
  6150. /** Defines the y component of the start tangent in the bezier curve */
  6151. y1: number;
  6152. /** Defines the x component of the end tangent in the bezier curve */
  6153. x2: number;
  6154. /** Defines the y component of the end tangent in the bezier curve */
  6155. y2: number;
  6156. /**
  6157. * Instantiates a bezier function
  6158. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6159. * @param x1 Defines the x component of the start tangent in the bezier curve
  6160. * @param y1 Defines the y component of the start tangent in the bezier curve
  6161. * @param x2 Defines the x component of the end tangent in the bezier curve
  6162. * @param y2 Defines the y component of the end tangent in the bezier curve
  6163. */
  6164. constructor(
  6165. /** Defines the x component of the start tangent in the bezier curve */
  6166. x1?: number,
  6167. /** Defines the y component of the start tangent in the bezier curve */
  6168. y1?: number,
  6169. /** Defines the x component of the end tangent in the bezier curve */
  6170. x2?: number,
  6171. /** Defines the y component of the end tangent in the bezier curve */
  6172. y2?: number);
  6173. /** @hidden */
  6174. easeInCore(gradient: number): number;
  6175. }
  6176. }
  6177. declare module BABYLON {
  6178. /**
  6179. * Class used to hold a RGB color
  6180. */
  6181. export class Color3 {
  6182. /**
  6183. * Defines the red component (between 0 and 1, default is 0)
  6184. */
  6185. r: number;
  6186. /**
  6187. * Defines the green component (between 0 and 1, default is 0)
  6188. */
  6189. g: number;
  6190. /**
  6191. * Defines the blue component (between 0 and 1, default is 0)
  6192. */
  6193. b: number;
  6194. /**
  6195. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6196. * @param r defines the red component (between 0 and 1, default is 0)
  6197. * @param g defines the green component (between 0 and 1, default is 0)
  6198. * @param b defines the blue component (between 0 and 1, default is 0)
  6199. */
  6200. constructor(
  6201. /**
  6202. * Defines the red component (between 0 and 1, default is 0)
  6203. */
  6204. r?: number,
  6205. /**
  6206. * Defines the green component (between 0 and 1, default is 0)
  6207. */
  6208. g?: number,
  6209. /**
  6210. * Defines the blue component (between 0 and 1, default is 0)
  6211. */
  6212. b?: number);
  6213. /**
  6214. * Creates a string with the Color3 current values
  6215. * @returns the string representation of the Color3 object
  6216. */
  6217. toString(): string;
  6218. /**
  6219. * Returns the string "Color3"
  6220. * @returns "Color3"
  6221. */
  6222. getClassName(): string;
  6223. /**
  6224. * Compute the Color3 hash code
  6225. * @returns an unique number that can be used to hash Color3 objects
  6226. */
  6227. getHashCode(): number;
  6228. /**
  6229. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6230. * @param array defines the array where to store the r,g,b components
  6231. * @param index defines an optional index in the target array to define where to start storing values
  6232. * @returns the current Color3 object
  6233. */
  6234. toArray(array: FloatArray, index?: number): Color3;
  6235. /**
  6236. * Update the current color with values stored in an array from the starting index of the given array
  6237. * @param array defines the source array
  6238. * @param offset defines an offset in the source array
  6239. * @returns the current Color3 object
  6240. */
  6241. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6242. /**
  6243. * Returns a new Color4 object from the current Color3 and the given alpha
  6244. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6245. * @returns a new Color4 object
  6246. */
  6247. toColor4(alpha?: number): Color4;
  6248. /**
  6249. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6250. * @returns the new array
  6251. */
  6252. asArray(): number[];
  6253. /**
  6254. * Returns the luminance value
  6255. * @returns a float value
  6256. */
  6257. toLuminance(): number;
  6258. /**
  6259. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6260. * @param otherColor defines the second operand
  6261. * @returns the new Color3 object
  6262. */
  6263. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6264. /**
  6265. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6266. * @param otherColor defines the second operand
  6267. * @param result defines the Color3 object where to store the result
  6268. * @returns the current Color3
  6269. */
  6270. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6271. /**
  6272. * Determines equality between Color3 objects
  6273. * @param otherColor defines the second operand
  6274. * @returns true if the rgb values are equal to the given ones
  6275. */
  6276. equals(otherColor: DeepImmutable<Color3>): boolean;
  6277. /**
  6278. * Determines equality between the current Color3 object and a set of r,b,g values
  6279. * @param r defines the red component to check
  6280. * @param g defines the green component to check
  6281. * @param b defines the blue component to check
  6282. * @returns true if the rgb values are equal to the given ones
  6283. */
  6284. equalsFloats(r: number, g: number, b: number): boolean;
  6285. /**
  6286. * Multiplies in place each rgb value by scale
  6287. * @param scale defines the scaling factor
  6288. * @returns the updated Color3
  6289. */
  6290. scale(scale: number): Color3;
  6291. /**
  6292. * Multiplies the rgb values by scale and stores the result into "result"
  6293. * @param scale defines the scaling factor
  6294. * @param result defines the Color3 object where to store the result
  6295. * @returns the unmodified current Color3
  6296. */
  6297. scaleToRef(scale: number, result: Color3): Color3;
  6298. /**
  6299. * Scale the current Color3 values by a factor and add the result to a given Color3
  6300. * @param scale defines the scale factor
  6301. * @param result defines color to store the result into
  6302. * @returns the unmodified current Color3
  6303. */
  6304. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6305. /**
  6306. * Clamps the rgb values by the min and max values and stores the result into "result"
  6307. * @param min defines minimum clamping value (default is 0)
  6308. * @param max defines maximum clamping value (default is 1)
  6309. * @param result defines color to store the result into
  6310. * @returns the original Color3
  6311. */
  6312. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6313. /**
  6314. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6315. * @param otherColor defines the second operand
  6316. * @returns the new Color3
  6317. */
  6318. add(otherColor: DeepImmutable<Color3>): Color3;
  6319. /**
  6320. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6321. * @param otherColor defines the second operand
  6322. * @param result defines Color3 object to store the result into
  6323. * @returns the unmodified current Color3
  6324. */
  6325. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6326. /**
  6327. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6328. * @param otherColor defines the second operand
  6329. * @returns the new Color3
  6330. */
  6331. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6332. /**
  6333. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6334. * @param otherColor defines the second operand
  6335. * @param result defines Color3 object to store the result into
  6336. * @returns the unmodified current Color3
  6337. */
  6338. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6339. /**
  6340. * Copy the current object
  6341. * @returns a new Color3 copied the current one
  6342. */
  6343. clone(): Color3;
  6344. /**
  6345. * Copies the rgb values from the source in the current Color3
  6346. * @param source defines the source Color3 object
  6347. * @returns the updated Color3 object
  6348. */
  6349. copyFrom(source: DeepImmutable<Color3>): Color3;
  6350. /**
  6351. * Updates the Color3 rgb values from the given floats
  6352. * @param r defines the red component to read from
  6353. * @param g defines the green component to read from
  6354. * @param b defines the blue component to read from
  6355. * @returns the current Color3 object
  6356. */
  6357. copyFromFloats(r: number, g: number, b: number): Color3;
  6358. /**
  6359. * Updates the Color3 rgb values from the given floats
  6360. * @param r defines the red component to read from
  6361. * @param g defines the green component to read from
  6362. * @param b defines the blue component to read from
  6363. * @returns the current Color3 object
  6364. */
  6365. set(r: number, g: number, b: number): Color3;
  6366. /**
  6367. * Compute the Color3 hexadecimal code as a string
  6368. * @returns a string containing the hexadecimal representation of the Color3 object
  6369. */
  6370. toHexString(): string;
  6371. /**
  6372. * Computes a new Color3 converted from the current one to linear space
  6373. * @returns a new Color3 object
  6374. */
  6375. toLinearSpace(): Color3;
  6376. /**
  6377. * Converts current color in rgb space to HSV values
  6378. * @returns a new color3 representing the HSV values
  6379. */
  6380. toHSV(): Color3;
  6381. /**
  6382. * Converts current color in rgb space to HSV values
  6383. * @param result defines the Color3 where to store the HSV values
  6384. */
  6385. toHSVToRef(result: Color3): void;
  6386. /**
  6387. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6388. * @param convertedColor defines the Color3 object where to store the linear space version
  6389. * @returns the unmodified Color3
  6390. */
  6391. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6392. /**
  6393. * Computes a new Color3 converted from the current one to gamma space
  6394. * @returns a new Color3 object
  6395. */
  6396. toGammaSpace(): Color3;
  6397. /**
  6398. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6399. * @param convertedColor defines the Color3 object where to store the gamma space version
  6400. * @returns the unmodified Color3
  6401. */
  6402. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6403. private static _BlackReadOnly;
  6404. /**
  6405. * Convert Hue, saturation and value to a Color3 (RGB)
  6406. * @param hue defines the hue
  6407. * @param saturation defines the saturation
  6408. * @param value defines the value
  6409. * @param result defines the Color3 where to store the RGB values
  6410. */
  6411. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6412. /**
  6413. * Creates a new Color3 from the string containing valid hexadecimal values
  6414. * @param hex defines a string containing valid hexadecimal values
  6415. * @returns a new Color3 object
  6416. */
  6417. static FromHexString(hex: string): Color3;
  6418. /**
  6419. * Creates a new Color3 from the starting index of the given array
  6420. * @param array defines the source array
  6421. * @param offset defines an offset in the source array
  6422. * @returns a new Color3 object
  6423. */
  6424. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6425. /**
  6426. * Creates a new Color3 from the starting index element of the given array
  6427. * @param array defines the source array to read from
  6428. * @param offset defines the offset in the source array
  6429. * @param result defines the target Color3 object
  6430. */
  6431. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6432. /**
  6433. * Creates a new Color3 from integer values (< 256)
  6434. * @param r defines the red component to read from (value between 0 and 255)
  6435. * @param g defines the green component to read from (value between 0 and 255)
  6436. * @param b defines the blue component to read from (value between 0 and 255)
  6437. * @returns a new Color3 object
  6438. */
  6439. static FromInts(r: number, g: number, b: number): Color3;
  6440. /**
  6441. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6442. * @param start defines the start Color3 value
  6443. * @param end defines the end Color3 value
  6444. * @param amount defines the gradient value between start and end
  6445. * @returns a new Color3 object
  6446. */
  6447. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6448. /**
  6449. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6450. * @param left defines the start value
  6451. * @param right defines the end value
  6452. * @param amount defines the gradient factor
  6453. * @param result defines the Color3 object where to store the result
  6454. */
  6455. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6456. /**
  6457. * Returns a Color3 value containing a red color
  6458. * @returns a new Color3 object
  6459. */
  6460. static Red(): Color3;
  6461. /**
  6462. * Returns a Color3 value containing a green color
  6463. * @returns a new Color3 object
  6464. */
  6465. static Green(): Color3;
  6466. /**
  6467. * Returns a Color3 value containing a blue color
  6468. * @returns a new Color3 object
  6469. */
  6470. static Blue(): Color3;
  6471. /**
  6472. * Returns a Color3 value containing a black color
  6473. * @returns a new Color3 object
  6474. */
  6475. static Black(): Color3;
  6476. /**
  6477. * Gets a Color3 value containing a black color that must not be updated
  6478. */
  6479. static get BlackReadOnly(): DeepImmutable<Color3>;
  6480. /**
  6481. * Returns a Color3 value containing a white color
  6482. * @returns a new Color3 object
  6483. */
  6484. static White(): Color3;
  6485. /**
  6486. * Returns a Color3 value containing a purple color
  6487. * @returns a new Color3 object
  6488. */
  6489. static Purple(): Color3;
  6490. /**
  6491. * Returns a Color3 value containing a magenta color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Magenta(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a yellow color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Yellow(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a gray color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Gray(): Color3;
  6505. /**
  6506. * Returns a Color3 value containing a teal color
  6507. * @returns a new Color3 object
  6508. */
  6509. static Teal(): Color3;
  6510. /**
  6511. * Returns a Color3 value containing a random color
  6512. * @returns a new Color3 object
  6513. */
  6514. static Random(): Color3;
  6515. }
  6516. /**
  6517. * Class used to hold a RBGA color
  6518. */
  6519. export class Color4 {
  6520. /**
  6521. * Defines the red component (between 0 and 1, default is 0)
  6522. */
  6523. r: number;
  6524. /**
  6525. * Defines the green component (between 0 and 1, default is 0)
  6526. */
  6527. g: number;
  6528. /**
  6529. * Defines the blue component (between 0 and 1, default is 0)
  6530. */
  6531. b: number;
  6532. /**
  6533. * Defines the alpha component (between 0 and 1, default is 1)
  6534. */
  6535. a: number;
  6536. /**
  6537. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6538. * @param r defines the red component (between 0 and 1, default is 0)
  6539. * @param g defines the green component (between 0 and 1, default is 0)
  6540. * @param b defines the blue component (between 0 and 1, default is 0)
  6541. * @param a defines the alpha component (between 0 and 1, default is 1)
  6542. */
  6543. constructor(
  6544. /**
  6545. * Defines the red component (between 0 and 1, default is 0)
  6546. */
  6547. r?: number,
  6548. /**
  6549. * Defines the green component (between 0 and 1, default is 0)
  6550. */
  6551. g?: number,
  6552. /**
  6553. * Defines the blue component (between 0 and 1, default is 0)
  6554. */
  6555. b?: number,
  6556. /**
  6557. * Defines the alpha component (between 0 and 1, default is 1)
  6558. */
  6559. a?: number);
  6560. /**
  6561. * Adds in place the given Color4 values to the current Color4 object
  6562. * @param right defines the second operand
  6563. * @returns the current updated Color4 object
  6564. */
  6565. addInPlace(right: DeepImmutable<Color4>): Color4;
  6566. /**
  6567. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6568. * @returns the new array
  6569. */
  6570. asArray(): number[];
  6571. /**
  6572. * Stores from the starting index in the given array the Color4 successive values
  6573. * @param array defines the array where to store the r,g,b components
  6574. * @param index defines an optional index in the target array to define where to start storing values
  6575. * @returns the current Color4 object
  6576. */
  6577. toArray(array: number[], index?: number): Color4;
  6578. /**
  6579. * Update the current color with values stored in an array from the starting index of the given array
  6580. * @param array defines the source array
  6581. * @param offset defines an offset in the source array
  6582. * @returns the current Color4 object
  6583. */
  6584. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6585. /**
  6586. * Determines equality between Color4 objects
  6587. * @param otherColor defines the second operand
  6588. * @returns true if the rgba values are equal to the given ones
  6589. */
  6590. equals(otherColor: DeepImmutable<Color4>): boolean;
  6591. /**
  6592. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6593. * @param right defines the second operand
  6594. * @returns a new Color4 object
  6595. */
  6596. add(right: DeepImmutable<Color4>): Color4;
  6597. /**
  6598. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6599. * @param right defines the second operand
  6600. * @returns a new Color4 object
  6601. */
  6602. subtract(right: DeepImmutable<Color4>): Color4;
  6603. /**
  6604. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6605. * @param right defines the second operand
  6606. * @param result defines the Color4 object where to store the result
  6607. * @returns the current Color4 object
  6608. */
  6609. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6610. /**
  6611. * Creates a new Color4 with the current Color4 values multiplied by scale
  6612. * @param scale defines the scaling factor to apply
  6613. * @returns a new Color4 object
  6614. */
  6615. scale(scale: number): Color4;
  6616. /**
  6617. * Multiplies the current Color4 values by scale and stores the result in "result"
  6618. * @param scale defines the scaling factor to apply
  6619. * @param result defines the Color4 object where to store the result
  6620. * @returns the current unmodified Color4
  6621. */
  6622. scaleToRef(scale: number, result: Color4): Color4;
  6623. /**
  6624. * Scale the current Color4 values by a factor and add the result to a given Color4
  6625. * @param scale defines the scale factor
  6626. * @param result defines the Color4 object where to store the result
  6627. * @returns the unmodified current Color4
  6628. */
  6629. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6630. /**
  6631. * Clamps the rgb values by the min and max values and stores the result into "result"
  6632. * @param min defines minimum clamping value (default is 0)
  6633. * @param max defines maximum clamping value (default is 1)
  6634. * @param result defines color to store the result into.
  6635. * @returns the cuurent Color4
  6636. */
  6637. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6638. /**
  6639. * Multipy an Color4 value by another and return a new Color4 object
  6640. * @param color defines the Color4 value to multiply by
  6641. * @returns a new Color4 object
  6642. */
  6643. multiply(color: Color4): Color4;
  6644. /**
  6645. * Multipy a Color4 value by another and push the result in a reference value
  6646. * @param color defines the Color4 value to multiply by
  6647. * @param result defines the Color4 to fill the result in
  6648. * @returns the result Color4
  6649. */
  6650. multiplyToRef(color: Color4, result: Color4): Color4;
  6651. /**
  6652. * Creates a string with the Color4 current values
  6653. * @returns the string representation of the Color4 object
  6654. */
  6655. toString(): string;
  6656. /**
  6657. * Returns the string "Color4"
  6658. * @returns "Color4"
  6659. */
  6660. getClassName(): string;
  6661. /**
  6662. * Compute the Color4 hash code
  6663. * @returns an unique number that can be used to hash Color4 objects
  6664. */
  6665. getHashCode(): number;
  6666. /**
  6667. * Creates a new Color4 copied from the current one
  6668. * @returns a new Color4 object
  6669. */
  6670. clone(): Color4;
  6671. /**
  6672. * Copies the given Color4 values into the current one
  6673. * @param source defines the source Color4 object
  6674. * @returns the current updated Color4 object
  6675. */
  6676. copyFrom(source: Color4): Color4;
  6677. /**
  6678. * Copies the given float values into the current one
  6679. * @param r defines the red component to read from
  6680. * @param g defines the green component to read from
  6681. * @param b defines the blue component to read from
  6682. * @param a defines the alpha component to read from
  6683. * @returns the current updated Color4 object
  6684. */
  6685. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6686. /**
  6687. * Copies the given float values into the current one
  6688. * @param r defines the red component to read from
  6689. * @param g defines the green component to read from
  6690. * @param b defines the blue component to read from
  6691. * @param a defines the alpha component to read from
  6692. * @returns the current updated Color4 object
  6693. */
  6694. set(r: number, g: number, b: number, a: number): Color4;
  6695. /**
  6696. * Compute the Color4 hexadecimal code as a string
  6697. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6698. * @returns a string containing the hexadecimal representation of the Color4 object
  6699. */
  6700. toHexString(returnAsColor3?: boolean): string;
  6701. /**
  6702. * Computes a new Color4 converted from the current one to linear space
  6703. * @returns a new Color4 object
  6704. */
  6705. toLinearSpace(): Color4;
  6706. /**
  6707. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6708. * @param convertedColor defines the Color4 object where to store the linear space version
  6709. * @returns the unmodified Color4
  6710. */
  6711. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6712. /**
  6713. * Computes a new Color4 converted from the current one to gamma space
  6714. * @returns a new Color4 object
  6715. */
  6716. toGammaSpace(): Color4;
  6717. /**
  6718. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6719. * @param convertedColor defines the Color4 object where to store the gamma space version
  6720. * @returns the unmodified Color4
  6721. */
  6722. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6723. /**
  6724. * Creates a new Color4 from the string containing valid hexadecimal values
  6725. * @param hex defines a string containing valid hexadecimal values
  6726. * @returns a new Color4 object
  6727. */
  6728. static FromHexString(hex: string): Color4;
  6729. /**
  6730. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6731. * @param left defines the start value
  6732. * @param right defines the end value
  6733. * @param amount defines the gradient factor
  6734. * @returns a new Color4 object
  6735. */
  6736. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6737. /**
  6738. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6739. * @param left defines the start value
  6740. * @param right defines the end value
  6741. * @param amount defines the gradient factor
  6742. * @param result defines the Color4 object where to store data
  6743. */
  6744. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6745. /**
  6746. * Creates a new Color4 from a Color3 and an alpha value
  6747. * @param color3 defines the source Color3 to read from
  6748. * @param alpha defines the alpha component (1.0 by default)
  6749. * @returns a new Color4 object
  6750. */
  6751. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6752. /**
  6753. * Creates a new Color4 from the starting index element of the given array
  6754. * @param array defines the source array to read from
  6755. * @param offset defines the offset in the source array
  6756. * @returns a new Color4 object
  6757. */
  6758. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6759. /**
  6760. * Creates a new Color4 from the starting index element of the given array
  6761. * @param array defines the source array to read from
  6762. * @param offset defines the offset in the source array
  6763. * @param result defines the target Color4 object
  6764. */
  6765. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6766. /**
  6767. * Creates a new Color3 from integer values (< 256)
  6768. * @param r defines the red component to read from (value between 0 and 255)
  6769. * @param g defines the green component to read from (value between 0 and 255)
  6770. * @param b defines the blue component to read from (value between 0 and 255)
  6771. * @param a defines the alpha component to read from (value between 0 and 255)
  6772. * @returns a new Color3 object
  6773. */
  6774. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6775. /**
  6776. * Check the content of a given array and convert it to an array containing RGBA data
  6777. * If the original array was already containing count * 4 values then it is returned directly
  6778. * @param colors defines the array to check
  6779. * @param count defines the number of RGBA data to expect
  6780. * @returns an array containing count * 4 values (RGBA)
  6781. */
  6782. static CheckColors4(colors: number[], count: number): number[];
  6783. }
  6784. /**
  6785. * @hidden
  6786. */
  6787. export class TmpColors {
  6788. static Color3: Color3[];
  6789. static Color4: Color4[];
  6790. }
  6791. }
  6792. declare module BABYLON {
  6793. /**
  6794. * Defines an interface which represents an animation key frame
  6795. */
  6796. export interface IAnimationKey {
  6797. /**
  6798. * Frame of the key frame
  6799. */
  6800. frame: number;
  6801. /**
  6802. * Value at the specifies key frame
  6803. */
  6804. value: any;
  6805. /**
  6806. * The input tangent for the cubic hermite spline
  6807. */
  6808. inTangent?: any;
  6809. /**
  6810. * The output tangent for the cubic hermite spline
  6811. */
  6812. outTangent?: any;
  6813. /**
  6814. * The animation interpolation type
  6815. */
  6816. interpolation?: AnimationKeyInterpolation;
  6817. }
  6818. /**
  6819. * Enum for the animation key frame interpolation type
  6820. */
  6821. export enum AnimationKeyInterpolation {
  6822. /**
  6823. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6824. */
  6825. STEP = 1
  6826. }
  6827. }
  6828. declare module BABYLON {
  6829. /**
  6830. * Represents the range of an animation
  6831. */
  6832. export class AnimationRange {
  6833. /**The name of the animation range**/
  6834. name: string;
  6835. /**The starting frame of the animation */
  6836. from: number;
  6837. /**The ending frame of the animation*/
  6838. to: number;
  6839. /**
  6840. * Initializes the range of an animation
  6841. * @param name The name of the animation range
  6842. * @param from The starting frame of the animation
  6843. * @param to The ending frame of the animation
  6844. */
  6845. constructor(
  6846. /**The name of the animation range**/
  6847. name: string,
  6848. /**The starting frame of the animation */
  6849. from: number,
  6850. /**The ending frame of the animation*/
  6851. to: number);
  6852. /**
  6853. * Makes a copy of the animation range
  6854. * @returns A copy of the animation range
  6855. */
  6856. clone(): AnimationRange;
  6857. }
  6858. }
  6859. declare module BABYLON {
  6860. /**
  6861. * Composed of a frame, and an action function
  6862. */
  6863. export class AnimationEvent {
  6864. /** The frame for which the event is triggered **/
  6865. frame: number;
  6866. /** The event to perform when triggered **/
  6867. action: (currentFrame: number) => void;
  6868. /** Specifies if the event should be triggered only once**/
  6869. onlyOnce?: boolean | undefined;
  6870. /**
  6871. * Specifies if the animation event is done
  6872. */
  6873. isDone: boolean;
  6874. /**
  6875. * Initializes the animation event
  6876. * @param frame The frame for which the event is triggered
  6877. * @param action The event to perform when triggered
  6878. * @param onlyOnce Specifies if the event should be triggered only once
  6879. */
  6880. constructor(
  6881. /** The frame for which the event is triggered **/
  6882. frame: number,
  6883. /** The event to perform when triggered **/
  6884. action: (currentFrame: number) => void,
  6885. /** Specifies if the event should be triggered only once**/
  6886. onlyOnce?: boolean | undefined);
  6887. /** @hidden */
  6888. _clone(): AnimationEvent;
  6889. }
  6890. }
  6891. declare module BABYLON {
  6892. /**
  6893. * Interface used to define a behavior
  6894. */
  6895. export interface Behavior<T> {
  6896. /** gets or sets behavior's name */
  6897. name: string;
  6898. /**
  6899. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6900. */
  6901. init(): void;
  6902. /**
  6903. * Called when the behavior is attached to a target
  6904. * @param target defines the target where the behavior is attached to
  6905. */
  6906. attach(target: T): void;
  6907. /**
  6908. * Called when the behavior is detached from its target
  6909. */
  6910. detach(): void;
  6911. }
  6912. /**
  6913. * Interface implemented by classes supporting behaviors
  6914. */
  6915. export interface IBehaviorAware<T> {
  6916. /**
  6917. * Attach a behavior
  6918. * @param behavior defines the behavior to attach
  6919. * @returns the current host
  6920. */
  6921. addBehavior(behavior: Behavior<T>): T;
  6922. /**
  6923. * Remove a behavior from the current object
  6924. * @param behavior defines the behavior to detach
  6925. * @returns the current host
  6926. */
  6927. removeBehavior(behavior: Behavior<T>): T;
  6928. /**
  6929. * Gets a behavior using its name to search
  6930. * @param name defines the name to search
  6931. * @returns the behavior or null if not found
  6932. */
  6933. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6934. }
  6935. }
  6936. declare module BABYLON {
  6937. /**
  6938. * Class used to store data that will be store in GPU memory
  6939. */
  6940. export class Buffer {
  6941. private _engine;
  6942. private _buffer;
  6943. /** @hidden */
  6944. _data: Nullable<DataArray>;
  6945. private _updatable;
  6946. private _instanced;
  6947. private _divisor;
  6948. private _isAlreadyOwned;
  6949. /**
  6950. * Gets the byte stride.
  6951. */
  6952. readonly byteStride: number;
  6953. /**
  6954. * Constructor
  6955. * @param engine the engine
  6956. * @param data the data to use for this buffer
  6957. * @param updatable whether the data is updatable
  6958. * @param stride the stride (optional)
  6959. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6960. * @param instanced whether the buffer is instanced (optional)
  6961. * @param useBytes set to true if the stride in in bytes (optional)
  6962. * @param divisor sets an optional divisor for instances (1 by default)
  6963. */
  6964. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6965. /**
  6966. * Create a new VertexBuffer based on the current buffer
  6967. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6968. * @param offset defines offset in the buffer (0 by default)
  6969. * @param size defines the size in floats of attributes (position is 3 for instance)
  6970. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6971. * @param instanced defines if the vertex buffer contains indexed data
  6972. * @param useBytes defines if the offset and stride are in bytes *
  6973. * @param divisor sets an optional divisor for instances (1 by default)
  6974. * @returns the new vertex buffer
  6975. */
  6976. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6977. /**
  6978. * Gets a boolean indicating if the Buffer is updatable?
  6979. * @returns true if the buffer is updatable
  6980. */
  6981. isUpdatable(): boolean;
  6982. /**
  6983. * Gets current buffer's data
  6984. * @returns a DataArray or null
  6985. */
  6986. getData(): Nullable<DataArray>;
  6987. /**
  6988. * Gets underlying native buffer
  6989. * @returns underlying native buffer
  6990. */
  6991. getBuffer(): Nullable<DataBuffer>;
  6992. /**
  6993. * Gets the stride in float32 units (i.e. byte stride / 4).
  6994. * May not be an integer if the byte stride is not divisible by 4.
  6995. * @returns the stride in float32 units
  6996. * @deprecated Please use byteStride instead.
  6997. */
  6998. getStrideSize(): number;
  6999. /**
  7000. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7001. * @param data defines the data to store
  7002. */
  7003. create(data?: Nullable<DataArray>): void;
  7004. /** @hidden */
  7005. _rebuild(): void;
  7006. /**
  7007. * Update current buffer data
  7008. * @param data defines the data to store
  7009. */
  7010. update(data: DataArray): void;
  7011. /**
  7012. * Updates the data directly.
  7013. * @param data the new data
  7014. * @param offset the new offset
  7015. * @param vertexCount the vertex count (optional)
  7016. * @param useBytes set to true if the offset is in bytes
  7017. */
  7018. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7019. /** @hidden */
  7020. _increaseReferences(): void;
  7021. /**
  7022. * Release all resources
  7023. */
  7024. dispose(): void;
  7025. }
  7026. /**
  7027. * Specialized buffer used to store vertex data
  7028. */
  7029. export class VertexBuffer {
  7030. private static _Counter;
  7031. /** @hidden */
  7032. _buffer: Buffer;
  7033. private _kind;
  7034. private _size;
  7035. private _ownsBuffer;
  7036. private _instanced;
  7037. private _instanceDivisor;
  7038. /**
  7039. * The byte type.
  7040. */
  7041. static readonly BYTE: number;
  7042. /**
  7043. * The unsigned byte type.
  7044. */
  7045. static readonly UNSIGNED_BYTE: number;
  7046. /**
  7047. * The short type.
  7048. */
  7049. static readonly SHORT: number;
  7050. /**
  7051. * The unsigned short type.
  7052. */
  7053. static readonly UNSIGNED_SHORT: number;
  7054. /**
  7055. * The integer type.
  7056. */
  7057. static readonly INT: number;
  7058. /**
  7059. * The unsigned integer type.
  7060. */
  7061. static readonly UNSIGNED_INT: number;
  7062. /**
  7063. * The float type.
  7064. */
  7065. static readonly FLOAT: number;
  7066. /**
  7067. * Gets or sets the instance divisor when in instanced mode
  7068. */
  7069. get instanceDivisor(): number;
  7070. set instanceDivisor(value: number);
  7071. /**
  7072. * Gets the byte stride.
  7073. */
  7074. readonly byteStride: number;
  7075. /**
  7076. * Gets the byte offset.
  7077. */
  7078. readonly byteOffset: number;
  7079. /**
  7080. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7081. */
  7082. readonly normalized: boolean;
  7083. /**
  7084. * Gets the data type of each component in the array.
  7085. */
  7086. readonly type: number;
  7087. /**
  7088. * Gets the unique id of this vertex buffer
  7089. */
  7090. readonly uniqueId: number;
  7091. /**
  7092. * Constructor
  7093. * @param engine the engine
  7094. * @param data the data to use for this vertex buffer
  7095. * @param kind the vertex buffer kind
  7096. * @param updatable whether the data is updatable
  7097. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7098. * @param stride the stride (optional)
  7099. * @param instanced whether the buffer is instanced (optional)
  7100. * @param offset the offset of the data (optional)
  7101. * @param size the number of components (optional)
  7102. * @param type the type of the component (optional)
  7103. * @param normalized whether the data contains normalized data (optional)
  7104. * @param useBytes set to true if stride and offset are in bytes (optional)
  7105. * @param divisor defines the instance divisor to use (1 by default)
  7106. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7107. */
  7108. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  7109. /** @hidden */
  7110. _rebuild(): void;
  7111. /**
  7112. * Returns the kind of the VertexBuffer (string)
  7113. * @returns a string
  7114. */
  7115. getKind(): string;
  7116. /**
  7117. * Gets a boolean indicating if the VertexBuffer is updatable?
  7118. * @returns true if the buffer is updatable
  7119. */
  7120. isUpdatable(): boolean;
  7121. /**
  7122. * Gets current buffer's data
  7123. * @returns a DataArray or null
  7124. */
  7125. getData(): Nullable<DataArray>;
  7126. /**
  7127. * Gets underlying native buffer
  7128. * @returns underlying native buffer
  7129. */
  7130. getBuffer(): Nullable<DataBuffer>;
  7131. /**
  7132. * Gets the stride in float32 units (i.e. byte stride / 4).
  7133. * May not be an integer if the byte stride is not divisible by 4.
  7134. * @returns the stride in float32 units
  7135. * @deprecated Please use byteStride instead.
  7136. */
  7137. getStrideSize(): number;
  7138. /**
  7139. * Returns the offset as a multiple of the type byte length.
  7140. * @returns the offset in bytes
  7141. * @deprecated Please use byteOffset instead.
  7142. */
  7143. getOffset(): number;
  7144. /**
  7145. * Returns the number of components per vertex attribute (integer)
  7146. * @returns the size in float
  7147. */
  7148. getSize(): number;
  7149. /**
  7150. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7151. * @returns true if this buffer is instanced
  7152. */
  7153. getIsInstanced(): boolean;
  7154. /**
  7155. * Returns the instancing divisor, zero for non-instanced (integer).
  7156. * @returns a number
  7157. */
  7158. getInstanceDivisor(): number;
  7159. /**
  7160. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7161. * @param data defines the data to store
  7162. */
  7163. create(data?: DataArray): void;
  7164. /**
  7165. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7166. * This function will create a new buffer if the current one is not updatable
  7167. * @param data defines the data to store
  7168. */
  7169. update(data: DataArray): void;
  7170. /**
  7171. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7172. * Returns the directly updated WebGLBuffer.
  7173. * @param data the new data
  7174. * @param offset the new offset
  7175. * @param useBytes set to true if the offset is in bytes
  7176. */
  7177. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7178. /**
  7179. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7180. */
  7181. dispose(): void;
  7182. /**
  7183. * Enumerates each value of this vertex buffer as numbers.
  7184. * @param count the number of values to enumerate
  7185. * @param callback the callback function called for each value
  7186. */
  7187. forEach(count: number, callback: (value: number, index: number) => void): void;
  7188. /**
  7189. * Positions
  7190. */
  7191. static readonly PositionKind: string;
  7192. /**
  7193. * Normals
  7194. */
  7195. static readonly NormalKind: string;
  7196. /**
  7197. * Tangents
  7198. */
  7199. static readonly TangentKind: string;
  7200. /**
  7201. * Texture coordinates
  7202. */
  7203. static readonly UVKind: string;
  7204. /**
  7205. * Texture coordinates 2
  7206. */
  7207. static readonly UV2Kind: string;
  7208. /**
  7209. * Texture coordinates 3
  7210. */
  7211. static readonly UV3Kind: string;
  7212. /**
  7213. * Texture coordinates 4
  7214. */
  7215. static readonly UV4Kind: string;
  7216. /**
  7217. * Texture coordinates 5
  7218. */
  7219. static readonly UV5Kind: string;
  7220. /**
  7221. * Texture coordinates 6
  7222. */
  7223. static readonly UV6Kind: string;
  7224. /**
  7225. * Colors
  7226. */
  7227. static readonly ColorKind: string;
  7228. /**
  7229. * Matrix indices (for bones)
  7230. */
  7231. static readonly MatricesIndicesKind: string;
  7232. /**
  7233. * Matrix weights (for bones)
  7234. */
  7235. static readonly MatricesWeightsKind: string;
  7236. /**
  7237. * Additional matrix indices (for bones)
  7238. */
  7239. static readonly MatricesIndicesExtraKind: string;
  7240. /**
  7241. * Additional matrix weights (for bones)
  7242. */
  7243. static readonly MatricesWeightsExtraKind: string;
  7244. /**
  7245. * Deduces the stride given a kind.
  7246. * @param kind The kind string to deduce
  7247. * @returns The deduced stride
  7248. */
  7249. static DeduceStride(kind: string): number;
  7250. /**
  7251. * Gets the byte length of the given type.
  7252. * @param type the type
  7253. * @returns the number of bytes
  7254. */
  7255. static GetTypeByteLength(type: number): number;
  7256. /**
  7257. * Enumerates each value of the given parameters as numbers.
  7258. * @param data the data to enumerate
  7259. * @param byteOffset the byte offset of the data
  7260. * @param byteStride the byte stride of the data
  7261. * @param componentCount the number of components per element
  7262. * @param componentType the type of the component
  7263. * @param count the number of values to enumerate
  7264. * @param normalized whether the data is normalized
  7265. * @param callback the callback function called for each value
  7266. */
  7267. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7268. private static _GetFloatValue;
  7269. }
  7270. }
  7271. declare module BABYLON {
  7272. /**
  7273. * @hidden
  7274. */
  7275. export class IntersectionInfo {
  7276. bu: Nullable<number>;
  7277. bv: Nullable<number>;
  7278. distance: number;
  7279. faceId: number;
  7280. subMeshId: number;
  7281. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7282. }
  7283. }
  7284. declare module BABYLON {
  7285. /**
  7286. * Class used to store bounding sphere information
  7287. */
  7288. export class BoundingSphere {
  7289. /**
  7290. * Gets the center of the bounding sphere in local space
  7291. */
  7292. readonly center: Vector3;
  7293. /**
  7294. * Radius of the bounding sphere in local space
  7295. */
  7296. radius: number;
  7297. /**
  7298. * Gets the center of the bounding sphere in world space
  7299. */
  7300. readonly centerWorld: Vector3;
  7301. /**
  7302. * Radius of the bounding sphere in world space
  7303. */
  7304. radiusWorld: number;
  7305. /**
  7306. * Gets the minimum vector in local space
  7307. */
  7308. readonly minimum: Vector3;
  7309. /**
  7310. * Gets the maximum vector in local space
  7311. */
  7312. readonly maximum: Vector3;
  7313. private _worldMatrix;
  7314. private static readonly TmpVector3;
  7315. /**
  7316. * Creates a new bounding sphere
  7317. * @param min defines the minimum vector (in local space)
  7318. * @param max defines the maximum vector (in local space)
  7319. * @param worldMatrix defines the new world matrix
  7320. */
  7321. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7322. /**
  7323. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7324. * @param min defines the new minimum vector (in local space)
  7325. * @param max defines the new maximum vector (in local space)
  7326. * @param worldMatrix defines the new world matrix
  7327. */
  7328. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7329. /**
  7330. * Scale the current bounding sphere by applying a scale factor
  7331. * @param factor defines the scale factor to apply
  7332. * @returns the current bounding box
  7333. */
  7334. scale(factor: number): BoundingSphere;
  7335. /**
  7336. * Gets the world matrix of the bounding box
  7337. * @returns a matrix
  7338. */
  7339. getWorldMatrix(): DeepImmutable<Matrix>;
  7340. /** @hidden */
  7341. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7342. /**
  7343. * Tests if the bounding sphere is intersecting the frustum planes
  7344. * @param frustumPlanes defines the frustum planes to test
  7345. * @returns true if there is an intersection
  7346. */
  7347. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7348. /**
  7349. * Tests if the bounding sphere center is in between the frustum planes.
  7350. * Used for optimistic fast inclusion.
  7351. * @param frustumPlanes defines the frustum planes to test
  7352. * @returns true if the sphere center is in between the frustum planes
  7353. */
  7354. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7355. /**
  7356. * Tests if a point is inside the bounding sphere
  7357. * @param point defines the point to test
  7358. * @returns true if the point is inside the bounding sphere
  7359. */
  7360. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7361. /**
  7362. * Checks if two sphere intersct
  7363. * @param sphere0 sphere 0
  7364. * @param sphere1 sphere 1
  7365. * @returns true if the speres intersect
  7366. */
  7367. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7368. }
  7369. }
  7370. declare module BABYLON {
  7371. /**
  7372. * Class used to store bounding box information
  7373. */
  7374. export class BoundingBox implements ICullable {
  7375. /**
  7376. * Gets the 8 vectors representing the bounding box in local space
  7377. */
  7378. readonly vectors: Vector3[];
  7379. /**
  7380. * Gets the center of the bounding box in local space
  7381. */
  7382. readonly center: Vector3;
  7383. /**
  7384. * Gets the center of the bounding box in world space
  7385. */
  7386. readonly centerWorld: Vector3;
  7387. /**
  7388. * Gets the extend size in local space
  7389. */
  7390. readonly extendSize: Vector3;
  7391. /**
  7392. * Gets the extend size in world space
  7393. */
  7394. readonly extendSizeWorld: Vector3;
  7395. /**
  7396. * Gets the OBB (object bounding box) directions
  7397. */
  7398. readonly directions: Vector3[];
  7399. /**
  7400. * Gets the 8 vectors representing the bounding box in world space
  7401. */
  7402. readonly vectorsWorld: Vector3[];
  7403. /**
  7404. * Gets the minimum vector in world space
  7405. */
  7406. readonly minimumWorld: Vector3;
  7407. /**
  7408. * Gets the maximum vector in world space
  7409. */
  7410. readonly maximumWorld: Vector3;
  7411. /**
  7412. * Gets the minimum vector in local space
  7413. */
  7414. readonly minimum: Vector3;
  7415. /**
  7416. * Gets the maximum vector in local space
  7417. */
  7418. readonly maximum: Vector3;
  7419. private _worldMatrix;
  7420. private static readonly TmpVector3;
  7421. /**
  7422. * @hidden
  7423. */
  7424. _tag: number;
  7425. /**
  7426. * Creates a new bounding box
  7427. * @param min defines the minimum vector (in local space)
  7428. * @param max defines the maximum vector (in local space)
  7429. * @param worldMatrix defines the new world matrix
  7430. */
  7431. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7432. /**
  7433. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7434. * @param min defines the new minimum vector (in local space)
  7435. * @param max defines the new maximum vector (in local space)
  7436. * @param worldMatrix defines the new world matrix
  7437. */
  7438. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7439. /**
  7440. * Scale the current bounding box by applying a scale factor
  7441. * @param factor defines the scale factor to apply
  7442. * @returns the current bounding box
  7443. */
  7444. scale(factor: number): BoundingBox;
  7445. /**
  7446. * Gets the world matrix of the bounding box
  7447. * @returns a matrix
  7448. */
  7449. getWorldMatrix(): DeepImmutable<Matrix>;
  7450. /** @hidden */
  7451. _update(world: DeepImmutable<Matrix>): void;
  7452. /**
  7453. * Tests if the bounding box is intersecting the frustum planes
  7454. * @param frustumPlanes defines the frustum planes to test
  7455. * @returns true if there is an intersection
  7456. */
  7457. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7458. /**
  7459. * Tests if the bounding box is entirely inside the frustum planes
  7460. * @param frustumPlanes defines the frustum planes to test
  7461. * @returns true if there is an inclusion
  7462. */
  7463. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7464. /**
  7465. * Tests if a point is inside the bounding box
  7466. * @param point defines the point to test
  7467. * @returns true if the point is inside the bounding box
  7468. */
  7469. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7470. /**
  7471. * Tests if the bounding box intersects with a bounding sphere
  7472. * @param sphere defines the sphere to test
  7473. * @returns true if there is an intersection
  7474. */
  7475. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7476. /**
  7477. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7478. * @param min defines the min vector to use
  7479. * @param max defines the max vector to use
  7480. * @returns true if there is an intersection
  7481. */
  7482. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7483. /**
  7484. * Tests if two bounding boxes are intersections
  7485. * @param box0 defines the first box to test
  7486. * @param box1 defines the second box to test
  7487. * @returns true if there is an intersection
  7488. */
  7489. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7490. /**
  7491. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7492. * @param minPoint defines the minimum vector of the bounding box
  7493. * @param maxPoint defines the maximum vector of the bounding box
  7494. * @param sphereCenter defines the sphere center
  7495. * @param sphereRadius defines the sphere radius
  7496. * @returns true if there is an intersection
  7497. */
  7498. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7499. /**
  7500. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7501. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7502. * @param frustumPlanes defines the frustum planes to test
  7503. * @return true if there is an inclusion
  7504. */
  7505. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7506. /**
  7507. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7508. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7509. * @param frustumPlanes defines the frustum planes to test
  7510. * @return true if there is an intersection
  7511. */
  7512. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7513. }
  7514. }
  7515. declare module BABYLON {
  7516. /** @hidden */
  7517. export class Collider {
  7518. /** Define if a collision was found */
  7519. collisionFound: boolean;
  7520. /**
  7521. * Define last intersection point in local space
  7522. */
  7523. intersectionPoint: Vector3;
  7524. /**
  7525. * Define last collided mesh
  7526. */
  7527. collidedMesh: Nullable<AbstractMesh>;
  7528. private _collisionPoint;
  7529. private _planeIntersectionPoint;
  7530. private _tempVector;
  7531. private _tempVector2;
  7532. private _tempVector3;
  7533. private _tempVector4;
  7534. private _edge;
  7535. private _baseToVertex;
  7536. private _destinationPoint;
  7537. private _slidePlaneNormal;
  7538. private _displacementVector;
  7539. /** @hidden */
  7540. _radius: Vector3;
  7541. /** @hidden */
  7542. _retry: number;
  7543. private _velocity;
  7544. private _basePoint;
  7545. private _epsilon;
  7546. /** @hidden */
  7547. _velocityWorldLength: number;
  7548. /** @hidden */
  7549. _basePointWorld: Vector3;
  7550. private _velocityWorld;
  7551. private _normalizedVelocity;
  7552. /** @hidden */
  7553. _initialVelocity: Vector3;
  7554. /** @hidden */
  7555. _initialPosition: Vector3;
  7556. private _nearestDistance;
  7557. private _collisionMask;
  7558. get collisionMask(): number;
  7559. set collisionMask(mask: number);
  7560. /**
  7561. * Gets the plane normal used to compute the sliding response (in local space)
  7562. */
  7563. get slidePlaneNormal(): Vector3;
  7564. /** @hidden */
  7565. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7566. /** @hidden */
  7567. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7568. /** @hidden */
  7569. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7570. /** @hidden */
  7571. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7572. /** @hidden */
  7573. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7574. /** @hidden */
  7575. _getResponse(pos: Vector3, vel: Vector3): void;
  7576. }
  7577. }
  7578. declare module BABYLON {
  7579. /**
  7580. * Interface for cullable objects
  7581. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7582. */
  7583. export interface ICullable {
  7584. /**
  7585. * Checks if the object or part of the object is in the frustum
  7586. * @param frustumPlanes Camera near/planes
  7587. * @returns true if the object is in frustum otherwise false
  7588. */
  7589. isInFrustum(frustumPlanes: Plane[]): boolean;
  7590. /**
  7591. * Checks if a cullable object (mesh...) is in the camera frustum
  7592. * Unlike isInFrustum this cheks the full bounding box
  7593. * @param frustumPlanes Camera near/planes
  7594. * @returns true if the object is in frustum otherwise false
  7595. */
  7596. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7597. }
  7598. /**
  7599. * Info for a bounding data of a mesh
  7600. */
  7601. export class BoundingInfo implements ICullable {
  7602. /**
  7603. * Bounding box for the mesh
  7604. */
  7605. readonly boundingBox: BoundingBox;
  7606. /**
  7607. * Bounding sphere for the mesh
  7608. */
  7609. readonly boundingSphere: BoundingSphere;
  7610. private _isLocked;
  7611. private static readonly TmpVector3;
  7612. /**
  7613. * Constructs bounding info
  7614. * @param minimum min vector of the bounding box/sphere
  7615. * @param maximum max vector of the bounding box/sphere
  7616. * @param worldMatrix defines the new world matrix
  7617. */
  7618. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7619. /**
  7620. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7621. * @param min defines the new minimum vector (in local space)
  7622. * @param max defines the new maximum vector (in local space)
  7623. * @param worldMatrix defines the new world matrix
  7624. */
  7625. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7626. /**
  7627. * min vector of the bounding box/sphere
  7628. */
  7629. get minimum(): Vector3;
  7630. /**
  7631. * max vector of the bounding box/sphere
  7632. */
  7633. get maximum(): Vector3;
  7634. /**
  7635. * If the info is locked and won't be updated to avoid perf overhead
  7636. */
  7637. get isLocked(): boolean;
  7638. set isLocked(value: boolean);
  7639. /**
  7640. * Updates the bounding sphere and box
  7641. * @param world world matrix to be used to update
  7642. */
  7643. update(world: DeepImmutable<Matrix>): void;
  7644. /**
  7645. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7646. * @param center New center of the bounding info
  7647. * @param extend New extend of the bounding info
  7648. * @returns the current bounding info
  7649. */
  7650. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7651. /**
  7652. * Grows the bounding info to include the given point.
  7653. * @param point The point that will be included in the current bounding info
  7654. * @returns the current bounding info
  7655. */
  7656. encapsulate(point: Vector3): BoundingInfo;
  7657. /**
  7658. * Grows the bounding info to encapsulate the given bounding info.
  7659. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7660. * @returns the current bounding info
  7661. */
  7662. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7663. /**
  7664. * Scale the current bounding info by applying a scale factor
  7665. * @param factor defines the scale factor to apply
  7666. * @returns the current bounding info
  7667. */
  7668. scale(factor: number): BoundingInfo;
  7669. /**
  7670. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7671. * @param frustumPlanes defines the frustum to test
  7672. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7673. * @returns true if the bounding info is in the frustum planes
  7674. */
  7675. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7676. /**
  7677. * Gets the world distance between the min and max points of the bounding box
  7678. */
  7679. get diagonalLength(): number;
  7680. /**
  7681. * Checks if a cullable object (mesh...) is in the camera frustum
  7682. * Unlike isInFrustum this cheks the full bounding box
  7683. * @param frustumPlanes Camera near/planes
  7684. * @returns true if the object is in frustum otherwise false
  7685. */
  7686. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7687. /** @hidden */
  7688. _checkCollision(collider: Collider): boolean;
  7689. /**
  7690. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7691. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7692. * @param point the point to check intersection with
  7693. * @returns if the point intersects
  7694. */
  7695. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7696. /**
  7697. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7698. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7699. * @param boundingInfo the bounding info to check intersection with
  7700. * @param precise if the intersection should be done using OBB
  7701. * @returns if the bounding info intersects
  7702. */
  7703. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7704. }
  7705. }
  7706. declare module BABYLON {
  7707. /**
  7708. * Extracts minimum and maximum values from a list of indexed positions
  7709. * @param positions defines the positions to use
  7710. * @param indices defines the indices to the positions
  7711. * @param indexStart defines the start index
  7712. * @param indexCount defines the end index
  7713. * @param bias defines bias value to add to the result
  7714. * @return minimum and maximum values
  7715. */
  7716. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7717. minimum: Vector3;
  7718. maximum: Vector3;
  7719. };
  7720. /**
  7721. * Extracts minimum and maximum values from a list of positions
  7722. * @param positions defines the positions to use
  7723. * @param start defines the start index in the positions array
  7724. * @param count defines the number of positions to handle
  7725. * @param bias defines bias value to add to the result
  7726. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7727. * @return minimum and maximum values
  7728. */
  7729. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7730. minimum: Vector3;
  7731. maximum: Vector3;
  7732. };
  7733. }
  7734. declare module BABYLON {
  7735. /**
  7736. * Class used to manipulate GUIDs
  7737. */
  7738. export class GUID {
  7739. /**
  7740. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7741. * Be aware Math.random() could cause collisions, but:
  7742. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  7743. * @returns a pseudo random id
  7744. */
  7745. static RandomId(): string;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Base class of all the textures in babylon.
  7751. * It groups all the common properties the materials, post process, lights... might need
  7752. * in order to make a correct use of the texture.
  7753. */
  7754. export class BaseTexture extends ThinTexture implements IAnimatable {
  7755. /**
  7756. * Default anisotropic filtering level for the application.
  7757. * It is set to 4 as a good tradeoff between perf and quality.
  7758. */
  7759. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7760. /**
  7761. * Gets or sets the unique id of the texture
  7762. */
  7763. uniqueId: number;
  7764. /**
  7765. * Define the name of the texture.
  7766. */
  7767. name: string;
  7768. /**
  7769. * Gets or sets an object used to store user defined information.
  7770. */
  7771. metadata: any;
  7772. /**
  7773. * For internal use only. Please do not use.
  7774. */
  7775. reservedDataStore: any;
  7776. private _hasAlpha;
  7777. /**
  7778. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7779. */
  7780. set hasAlpha(value: boolean);
  7781. get hasAlpha(): boolean;
  7782. /**
  7783. * Defines if the alpha value should be determined via the rgb values.
  7784. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7785. */
  7786. getAlphaFromRGB: boolean;
  7787. /**
  7788. * Intensity or strength of the texture.
  7789. * It is commonly used by materials to fine tune the intensity of the texture
  7790. */
  7791. level: number;
  7792. /**
  7793. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7794. * This is part of the texture as textures usually maps to one uv set.
  7795. */
  7796. coordinatesIndex: number;
  7797. protected _coordinatesMode: number;
  7798. /**
  7799. * How a texture is mapped.
  7800. *
  7801. * | Value | Type | Description |
  7802. * | ----- | ----------------------------------- | ----------- |
  7803. * | 0 | EXPLICIT_MODE | |
  7804. * | 1 | SPHERICAL_MODE | |
  7805. * | 2 | PLANAR_MODE | |
  7806. * | 3 | CUBIC_MODE | |
  7807. * | 4 | PROJECTION_MODE | |
  7808. * | 5 | SKYBOX_MODE | |
  7809. * | 6 | INVCUBIC_MODE | |
  7810. * | 7 | EQUIRECTANGULAR_MODE | |
  7811. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7812. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7813. */
  7814. set coordinatesMode(value: number);
  7815. get coordinatesMode(): number;
  7816. /**
  7817. * | Value | Type | Description |
  7818. * | ----- | ------------------ | ----------- |
  7819. * | 0 | CLAMP_ADDRESSMODE | |
  7820. * | 1 | WRAP_ADDRESSMODE | |
  7821. * | 2 | MIRROR_ADDRESSMODE | |
  7822. */
  7823. get wrapU(): number;
  7824. set wrapU(value: number);
  7825. /**
  7826. * | Value | Type | Description |
  7827. * | ----- | ------------------ | ----------- |
  7828. * | 0 | CLAMP_ADDRESSMODE | |
  7829. * | 1 | WRAP_ADDRESSMODE | |
  7830. * | 2 | MIRROR_ADDRESSMODE | |
  7831. */
  7832. get wrapV(): number;
  7833. set wrapV(value: number);
  7834. /**
  7835. * | Value | Type | Description |
  7836. * | ----- | ------------------ | ----------- |
  7837. * | 0 | CLAMP_ADDRESSMODE | |
  7838. * | 1 | WRAP_ADDRESSMODE | |
  7839. * | 2 | MIRROR_ADDRESSMODE | |
  7840. */
  7841. wrapR: number;
  7842. /**
  7843. * With compliant hardware and browser (supporting anisotropic filtering)
  7844. * this defines the level of anisotropic filtering in the texture.
  7845. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7846. */
  7847. anisotropicFilteringLevel: number;
  7848. private _isCube;
  7849. /**
  7850. * Define if the texture is a cube texture or if false a 2d texture.
  7851. */
  7852. get isCube(): boolean;
  7853. set isCube(value: boolean);
  7854. /**
  7855. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7856. */
  7857. get is3D(): boolean;
  7858. set is3D(value: boolean);
  7859. /**
  7860. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7861. */
  7862. get is2DArray(): boolean;
  7863. set is2DArray(value: boolean);
  7864. private _gammaSpace;
  7865. /**
  7866. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7867. * HDR texture are usually stored in linear space.
  7868. * This only impacts the PBR and Background materials
  7869. */
  7870. get gammaSpace(): boolean;
  7871. set gammaSpace(gamma: boolean);
  7872. /**
  7873. * Gets or sets whether or not the texture contains RGBD data.
  7874. */
  7875. get isRGBD(): boolean;
  7876. set isRGBD(value: boolean);
  7877. /**
  7878. * Is Z inverted in the texture (useful in a cube texture).
  7879. */
  7880. invertZ: boolean;
  7881. /**
  7882. * Are mip maps generated for this texture or not.
  7883. */
  7884. get noMipmap(): boolean;
  7885. /**
  7886. * @hidden
  7887. */
  7888. lodLevelInAlpha: boolean;
  7889. /**
  7890. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7891. */
  7892. get lodGenerationOffset(): number;
  7893. set lodGenerationOffset(value: number);
  7894. /**
  7895. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7896. */
  7897. get lodGenerationScale(): number;
  7898. set lodGenerationScale(value: number);
  7899. /**
  7900. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7901. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7902. * average roughness values.
  7903. */
  7904. get linearSpecularLOD(): boolean;
  7905. set linearSpecularLOD(value: boolean);
  7906. /**
  7907. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7908. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7909. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7910. */
  7911. get irradianceTexture(): Nullable<BaseTexture>;
  7912. set irradianceTexture(value: Nullable<BaseTexture>);
  7913. /**
  7914. * Define if the texture is a render target.
  7915. */
  7916. isRenderTarget: boolean;
  7917. /**
  7918. * Define the unique id of the texture in the scene.
  7919. */
  7920. get uid(): string;
  7921. /** @hidden */
  7922. _prefiltered: boolean;
  7923. /**
  7924. * Return a string representation of the texture.
  7925. * @returns the texture as a string
  7926. */
  7927. toString(): string;
  7928. /**
  7929. * Get the class name of the texture.
  7930. * @returns "BaseTexture"
  7931. */
  7932. getClassName(): string;
  7933. /**
  7934. * Define the list of animation attached to the texture.
  7935. */
  7936. animations: Animation[];
  7937. /**
  7938. * An event triggered when the texture is disposed.
  7939. */
  7940. onDisposeObservable: Observable<BaseTexture>;
  7941. private _onDisposeObserver;
  7942. /**
  7943. * Callback triggered when the texture has been disposed.
  7944. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7945. */
  7946. set onDispose(callback: () => void);
  7947. protected _scene: Nullable<Scene>;
  7948. /** @hidden */
  7949. _texture: Nullable<InternalTexture>;
  7950. private _uid;
  7951. /**
  7952. * Define if the texture is preventinga material to render or not.
  7953. * If not and the texture is not ready, the engine will use a default black texture instead.
  7954. */
  7955. get isBlocking(): boolean;
  7956. /**
  7957. * Instantiates a new BaseTexture.
  7958. * Base class of all the textures in babylon.
  7959. * It groups all the common properties the materials, post process, lights... might need
  7960. * in order to make a correct use of the texture.
  7961. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7962. */
  7963. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7964. /**
  7965. * Get the scene the texture belongs to.
  7966. * @returns the scene or null if undefined
  7967. */
  7968. getScene(): Nullable<Scene>;
  7969. /** @hidden */
  7970. protected _getEngine(): Nullable<ThinEngine>;
  7971. /**
  7972. * Checks if the texture has the same transform matrix than another texture
  7973. * @param texture texture to check against
  7974. * @returns true if the transforms are the same, else false
  7975. */
  7976. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7977. /**
  7978. * Get the texture transform matrix used to offset tile the texture for istance.
  7979. * @returns the transformation matrix
  7980. */
  7981. getTextureMatrix(): Matrix;
  7982. /**
  7983. * Get the texture reflection matrix used to rotate/transform the reflection.
  7984. * @returns the reflection matrix
  7985. */
  7986. getReflectionTextureMatrix(): Matrix;
  7987. /**
  7988. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7989. * @returns true if ready or not blocking
  7990. */
  7991. isReadyOrNotBlocking(): boolean;
  7992. /**
  7993. * Scales the texture if is `canRescale()`
  7994. * @param ratio the resize factor we want to use to rescale
  7995. */
  7996. scale(ratio: number): void;
  7997. /**
  7998. * Get if the texture can rescale.
  7999. */
  8000. get canRescale(): boolean;
  8001. /** @hidden */
  8002. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8003. /** @hidden */
  8004. _rebuild(): void;
  8005. /**
  8006. * Clones the texture.
  8007. * @returns the cloned texture
  8008. */
  8009. clone(): Nullable<BaseTexture>;
  8010. /**
  8011. * Get the texture underlying type (INT, FLOAT...)
  8012. */
  8013. get textureType(): number;
  8014. /**
  8015. * Get the texture underlying format (RGB, RGBA...)
  8016. */
  8017. get textureFormat(): number;
  8018. /**
  8019. * Indicates that textures need to be re-calculated for all materials
  8020. */
  8021. protected _markAllSubMeshesAsTexturesDirty(): void;
  8022. /**
  8023. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8024. * This will returns an RGBA array buffer containing either in values (0-255) or
  8025. * float values (0-1) depending of the underlying buffer type.
  8026. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8027. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8028. * @param buffer defines a user defined buffer to fill with data (can be null)
  8029. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8030. * @returns The Array buffer promise containing the pixels data.
  8031. */
  8032. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8033. /** @hidden */
  8034. get _lodTextureHigh(): Nullable<BaseTexture>;
  8035. /** @hidden */
  8036. get _lodTextureMid(): Nullable<BaseTexture>;
  8037. /** @hidden */
  8038. get _lodTextureLow(): Nullable<BaseTexture>;
  8039. /**
  8040. * Dispose the texture and release its associated resources.
  8041. */
  8042. dispose(): void;
  8043. /**
  8044. * Serialize the texture into a JSON representation that can be parsed later on.
  8045. * @returns the JSON representation of the texture
  8046. */
  8047. serialize(): any;
  8048. /**
  8049. * Helper function to be called back once a list of texture contains only ready textures.
  8050. * @param textures Define the list of textures to wait for
  8051. * @param callback Define the callback triggered once the entire list will be ready
  8052. */
  8053. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8054. private static _isScene;
  8055. }
  8056. }
  8057. declare module BABYLON {
  8058. /** @hidden */
  8059. export class WebGLDataBuffer extends DataBuffer {
  8060. private _buffer;
  8061. constructor(resource: WebGLBuffer);
  8062. get underlyingResource(): any;
  8063. }
  8064. }
  8065. declare module BABYLON {
  8066. /** @hidden */
  8067. export class WebGLPipelineContext implements IPipelineContext {
  8068. private _valueCache;
  8069. private _uniforms;
  8070. engine: ThinEngine;
  8071. program: Nullable<WebGLProgram>;
  8072. context?: WebGLRenderingContext;
  8073. vertexShader?: WebGLShader;
  8074. fragmentShader?: WebGLShader;
  8075. isParallelCompiled: boolean;
  8076. onCompiled?: () => void;
  8077. transformFeedback?: WebGLTransformFeedback | null;
  8078. vertexCompilationError: Nullable<string>;
  8079. fragmentCompilationError: Nullable<string>;
  8080. programLinkError: Nullable<string>;
  8081. programValidationError: Nullable<string>;
  8082. get isAsync(): boolean;
  8083. get isReady(): boolean;
  8084. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8085. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8086. [key: string]: number;
  8087. }, uniformsNames: string[], uniforms: {
  8088. [key: string]: Nullable<WebGLUniformLocation>;
  8089. }, samplerList: string[], samplers: {
  8090. [key: string]: number;
  8091. }, attributesNames: string[], attributes: number[]): void;
  8092. /**
  8093. * Release all associated resources.
  8094. **/
  8095. dispose(): void;
  8096. /** @hidden */
  8097. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8098. /** @hidden */
  8099. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8100. /** @hidden */
  8101. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8102. /** @hidden */
  8103. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8104. /**
  8105. * Sets an interger value on a uniform variable.
  8106. * @param uniformName Name of the variable.
  8107. * @param value Value to be set.
  8108. */
  8109. setInt(uniformName: string, value: number): void;
  8110. /**
  8111. * Sets a int2 on a uniform variable.
  8112. * @param uniformName Name of the variable.
  8113. * @param x First int in int2.
  8114. * @param y Second int in int2.
  8115. */
  8116. setInt2(uniformName: string, x: number, y: number): void;
  8117. /**
  8118. * Sets a int3 on a uniform variable.
  8119. * @param uniformName Name of the variable.
  8120. * @param x First int in int3.
  8121. * @param y Second int in int3.
  8122. * @param y Third int in int3.
  8123. */
  8124. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8125. /**
  8126. * Sets a int4 on a uniform variable.
  8127. * @param uniformName Name of the variable.
  8128. * @param x First int in int4.
  8129. * @param y Second int in int4.
  8130. * @param y Third int in int4.
  8131. * @param w Fourth int in int4.
  8132. */
  8133. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8134. /**
  8135. * Sets an int array on a uniform variable.
  8136. * @param uniformName Name of the variable.
  8137. * @param array array to be set.
  8138. */
  8139. setIntArray(uniformName: string, array: Int32Array): void;
  8140. /**
  8141. * 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)
  8142. * @param uniformName Name of the variable.
  8143. * @param array array to be set.
  8144. */
  8145. setIntArray2(uniformName: string, array: Int32Array): void;
  8146. /**
  8147. * 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)
  8148. * @param uniformName Name of the variable.
  8149. * @param array array to be set.
  8150. */
  8151. setIntArray3(uniformName: string, array: Int32Array): void;
  8152. /**
  8153. * 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)
  8154. * @param uniformName Name of the variable.
  8155. * @param array array to be set.
  8156. */
  8157. setIntArray4(uniformName: string, array: Int32Array): void;
  8158. /**
  8159. * Sets an array on a uniform variable.
  8160. * @param uniformName Name of the variable.
  8161. * @param array array to be set.
  8162. */
  8163. setArray(uniformName: string, array: number[]): void;
  8164. /**
  8165. * 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)
  8166. * @param uniformName Name of the variable.
  8167. * @param array array to be set.
  8168. */
  8169. setArray2(uniformName: string, array: number[]): void;
  8170. /**
  8171. * 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)
  8172. * @param uniformName Name of the variable.
  8173. * @param array array to be set.
  8174. * @returns this effect.
  8175. */
  8176. setArray3(uniformName: string, array: number[]): void;
  8177. /**
  8178. * 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)
  8179. * @param uniformName Name of the variable.
  8180. * @param array array to be set.
  8181. */
  8182. setArray4(uniformName: string, array: number[]): void;
  8183. /**
  8184. * Sets matrices on a uniform variable.
  8185. * @param uniformName Name of the variable.
  8186. * @param matrices matrices to be set.
  8187. */
  8188. setMatrices(uniformName: string, matrices: Float32Array): void;
  8189. /**
  8190. * Sets matrix on a uniform variable.
  8191. * @param uniformName Name of the variable.
  8192. * @param matrix matrix to be set.
  8193. */
  8194. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8195. /**
  8196. * 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)
  8197. * @param uniformName Name of the variable.
  8198. * @param matrix matrix to be set.
  8199. */
  8200. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8201. /**
  8202. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8203. * @param uniformName Name of the variable.
  8204. * @param matrix matrix to be set.
  8205. */
  8206. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8207. /**
  8208. * Sets a float on a uniform variable.
  8209. * @param uniformName Name of the variable.
  8210. * @param value value to be set.
  8211. * @returns this effect.
  8212. */
  8213. setFloat(uniformName: string, value: number): void;
  8214. /**
  8215. * Sets a Vector2 on a uniform variable.
  8216. * @param uniformName Name of the variable.
  8217. * @param vector2 vector2 to be set.
  8218. */
  8219. setVector2(uniformName: string, vector2: IVector2Like): void;
  8220. /**
  8221. * Sets a float2 on a uniform variable.
  8222. * @param uniformName Name of the variable.
  8223. * @param x First float in float2.
  8224. * @param y Second float in float2.
  8225. */
  8226. setFloat2(uniformName: string, x: number, y: number): void;
  8227. /**
  8228. * Sets a Vector3 on a uniform variable.
  8229. * @param uniformName Name of the variable.
  8230. * @param vector3 Value to be set.
  8231. */
  8232. setVector3(uniformName: string, vector3: IVector3Like): void;
  8233. /**
  8234. * Sets a float3 on a uniform variable.
  8235. * @param uniformName Name of the variable.
  8236. * @param x First float in float3.
  8237. * @param y Second float in float3.
  8238. * @param z Third float in float3.
  8239. */
  8240. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8241. /**
  8242. * Sets a Vector4 on a uniform variable.
  8243. * @param uniformName Name of the variable.
  8244. * @param vector4 Value to be set.
  8245. */
  8246. setVector4(uniformName: string, vector4: IVector4Like): void;
  8247. /**
  8248. * Sets a float4 on a uniform variable.
  8249. * @param uniformName Name of the variable.
  8250. * @param x First float in float4.
  8251. * @param y Second float in float4.
  8252. * @param z Third float in float4.
  8253. * @param w Fourth float in float4.
  8254. * @returns this effect.
  8255. */
  8256. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8257. /**
  8258. * Sets a Color3 on a uniform variable.
  8259. * @param uniformName Name of the variable.
  8260. * @param color3 Value to be set.
  8261. */
  8262. setColor3(uniformName: string, color3: IColor3Like): void;
  8263. /**
  8264. * Sets a Color4 on a uniform variable.
  8265. * @param uniformName Name of the variable.
  8266. * @param color3 Value to be set.
  8267. * @param alpha Alpha value to be set.
  8268. */
  8269. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8270. /**
  8271. * Sets a Color4 on a uniform variable
  8272. * @param uniformName defines the name of the variable
  8273. * @param color4 defines the value to be set
  8274. */
  8275. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8276. _getVertexShaderCode(): string | null;
  8277. _getFragmentShaderCode(): string | null;
  8278. }
  8279. }
  8280. declare module BABYLON {
  8281. interface ThinEngine {
  8282. /**
  8283. * Create an uniform buffer
  8284. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8285. * @param elements defines the content of the uniform buffer
  8286. * @returns the webGL uniform buffer
  8287. */
  8288. createUniformBuffer(elements: FloatArray): DataBuffer;
  8289. /**
  8290. * Create a dynamic uniform buffer
  8291. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8292. * @param elements defines the content of the uniform buffer
  8293. * @returns the webGL uniform buffer
  8294. */
  8295. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8296. /**
  8297. * Update an existing uniform buffer
  8298. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8299. * @param uniformBuffer defines the target uniform buffer
  8300. * @param elements defines the content to update
  8301. * @param offset defines the offset in the uniform buffer where update should start
  8302. * @param count defines the size of the data to update
  8303. */
  8304. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8305. /**
  8306. * Bind an uniform buffer to the current webGL context
  8307. * @param buffer defines the buffer to bind
  8308. */
  8309. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8310. /**
  8311. * Bind a buffer to the current webGL context at a given location
  8312. * @param buffer defines the buffer to bind
  8313. * @param location defines the index where to bind the buffer
  8314. * @param name Name of the uniform variable to bind
  8315. */
  8316. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8317. /**
  8318. * Bind a specific block at a given index in a specific shader program
  8319. * @param pipelineContext defines the pipeline context to use
  8320. * @param blockName defines the block name
  8321. * @param index defines the index where to bind the block
  8322. */
  8323. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8324. }
  8325. }
  8326. declare module BABYLON {
  8327. /**
  8328. * Uniform buffer objects.
  8329. *
  8330. * Handles blocks of uniform on the GPU.
  8331. *
  8332. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8333. *
  8334. * For more information, please refer to :
  8335. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8336. */
  8337. export class UniformBuffer {
  8338. /** @hidden */
  8339. static _updatedUbosInFrame: {
  8340. [name: string]: number;
  8341. };
  8342. private _engine;
  8343. private _buffer;
  8344. private _buffers;
  8345. private _bufferIndex;
  8346. private _createBufferOnWrite;
  8347. private _data;
  8348. private _bufferData;
  8349. private _dynamic?;
  8350. private _uniformLocations;
  8351. private _uniformSizes;
  8352. private _uniformArraySizes;
  8353. private _uniformLocationPointer;
  8354. private _needSync;
  8355. private _noUBO;
  8356. private _currentEffect;
  8357. private _currentEffectName;
  8358. private _name;
  8359. private _currentFrameId;
  8360. /** @hidden */
  8361. _alreadyBound: boolean;
  8362. private static _MAX_UNIFORM_SIZE;
  8363. private static _tempBuffer;
  8364. private static _tempBufferInt32View;
  8365. /**
  8366. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8367. * This is dynamic to allow compat with webgl 1 and 2.
  8368. * You will need to pass the name of the uniform as well as the value.
  8369. */
  8370. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8371. /**
  8372. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8373. * This is dynamic to allow compat with webgl 1 and 2.
  8374. * You will need to pass the name of the uniform as well as the value.
  8375. */
  8376. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8377. /**
  8378. * Lambda to Update a single float in a uniform buffer.
  8379. * This is dynamic to allow compat with webgl 1 and 2.
  8380. * You will need to pass the name of the uniform as well as the value.
  8381. */
  8382. updateFloat: (name: string, x: number) => void;
  8383. /**
  8384. * Lambda to Update a vec2 of float in a uniform buffer.
  8385. * This is dynamic to allow compat with webgl 1 and 2.
  8386. * You will need to pass the name of the uniform as well as the value.
  8387. */
  8388. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8389. /**
  8390. * Lambda to Update a vec3 of float in a uniform buffer.
  8391. * This is dynamic to allow compat with webgl 1 and 2.
  8392. * You will need to pass the name of the uniform as well as the value.
  8393. */
  8394. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8395. /**
  8396. * Lambda to Update a vec4 of float in a uniform buffer.
  8397. * This is dynamic to allow compat with webgl 1 and 2.
  8398. * You will need to pass the name of the uniform as well as the value.
  8399. */
  8400. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8401. /**
  8402. * Lambda to Update an array of float in a uniform buffer.
  8403. * This is dynamic to allow compat with webgl 1 and 2.
  8404. * You will need to pass the name of the uniform as well as the value.
  8405. */
  8406. updateFloatArray: (name: string, array: Float32Array) => void;
  8407. /**
  8408. * Lambda to Update an array of number in a uniform buffer.
  8409. * This is dynamic to allow compat with webgl 1 and 2.
  8410. * You will need to pass the name of the uniform as well as the value.
  8411. */
  8412. updateArray: (name: string, array: number[]) => void;
  8413. /**
  8414. * Lambda to Update an array of number in a uniform buffer.
  8415. * This is dynamic to allow compat with webgl 1 and 2.
  8416. * You will need to pass the name of the uniform as well as the value.
  8417. */
  8418. updateIntArray: (name: string, array: Int32Array) => void;
  8419. /**
  8420. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8421. * This is dynamic to allow compat with webgl 1 and 2.
  8422. * You will need to pass the name of the uniform as well as the value.
  8423. */
  8424. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8425. /**
  8426. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8427. * This is dynamic to allow compat with webgl 1 and 2.
  8428. * You will need to pass the name of the uniform as well as the value.
  8429. */
  8430. updateMatrices: (name: string, mat: Float32Array) => void;
  8431. /**
  8432. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8433. * This is dynamic to allow compat with webgl 1 and 2.
  8434. * You will need to pass the name of the uniform as well as the value.
  8435. */
  8436. updateVector3: (name: string, vector: Vector3) => void;
  8437. /**
  8438. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8439. * This is dynamic to allow compat with webgl 1 and 2.
  8440. * You will need to pass the name of the uniform as well as the value.
  8441. */
  8442. updateVector4: (name: string, vector: Vector4) => void;
  8443. /**
  8444. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8445. * This is dynamic to allow compat with webgl 1 and 2.
  8446. * You will need to pass the name of the uniform as well as the value.
  8447. */
  8448. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8449. /**
  8450. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8451. * This is dynamic to allow compat with webgl 1 and 2.
  8452. * You will need to pass the name of the uniform as well as the value.
  8453. */
  8454. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8455. /**
  8456. * Lambda to Update a int a uniform buffer.
  8457. * This is dynamic to allow compat with webgl 1 and 2.
  8458. * You will need to pass the name of the uniform as well as the value.
  8459. */
  8460. updateInt: (name: string, x: number, suffix?: string) => void;
  8461. /**
  8462. * Lambda to Update a vec2 of int in a uniform buffer.
  8463. * This is dynamic to allow compat with webgl 1 and 2.
  8464. * You will need to pass the name of the uniform as well as the value.
  8465. */
  8466. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8467. /**
  8468. * Lambda to Update a vec3 of int in a uniform buffer.
  8469. * This is dynamic to allow compat with webgl 1 and 2.
  8470. * You will need to pass the name of the uniform as well as the value.
  8471. */
  8472. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8473. /**
  8474. * Lambda to Update a vec4 of int in a uniform buffer.
  8475. * This is dynamic to allow compat with webgl 1 and 2.
  8476. * You will need to pass the name of the uniform as well as the value.
  8477. */
  8478. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8479. /**
  8480. * Instantiates a new Uniform buffer objects.
  8481. *
  8482. * Handles blocks of uniform on the GPU.
  8483. *
  8484. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8485. *
  8486. * For more information, please refer to :
  8487. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8488. * @param engine Define the engine the buffer is associated with
  8489. * @param data Define the data contained in the buffer
  8490. * @param dynamic Define if the buffer is updatable
  8491. * @param name to assign to the buffer (debugging purpose)
  8492. */
  8493. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8494. /**
  8495. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8496. * or just falling back on setUniformXXX calls.
  8497. */
  8498. get useUbo(): boolean;
  8499. /**
  8500. * Indicates if the WebGL underlying uniform buffer is in sync
  8501. * with the javascript cache data.
  8502. */
  8503. get isSync(): boolean;
  8504. /**
  8505. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8506. * Also, a dynamic UniformBuffer will disable cache verification and always
  8507. * update the underlying WebGL uniform buffer to the GPU.
  8508. * @returns if Dynamic, otherwise false
  8509. */
  8510. isDynamic(): boolean;
  8511. /**
  8512. * The data cache on JS side.
  8513. * @returns the underlying data as a float array
  8514. */
  8515. getData(): Float32Array;
  8516. /**
  8517. * The underlying WebGL Uniform buffer.
  8518. * @returns the webgl buffer
  8519. */
  8520. getBuffer(): Nullable<DataBuffer>;
  8521. /**
  8522. * std140 layout specifies how to align data within an UBO structure.
  8523. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8524. * for specs.
  8525. */
  8526. private _fillAlignment;
  8527. /**
  8528. * Adds an uniform in the buffer.
  8529. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8530. * for the layout to be correct !
  8531. * @param name Name of the uniform, as used in the uniform block in the shader.
  8532. * @param size Data size, or data directly.
  8533. * @param arraySize The number of elements in the array, 0 if not an array.
  8534. */
  8535. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8536. /**
  8537. * Adds a Matrix 4x4 to the uniform buffer.
  8538. * @param name Name of the uniform, as used in the uniform block in the shader.
  8539. * @param mat A 4x4 matrix.
  8540. */
  8541. addMatrix(name: string, mat: Matrix): void;
  8542. /**
  8543. * Adds a vec2 to the uniform buffer.
  8544. * @param name Name of the uniform, as used in the uniform block in the shader.
  8545. * @param x Define the x component value of the vec2
  8546. * @param y Define the y component value of the vec2
  8547. */
  8548. addFloat2(name: string, x: number, y: number): void;
  8549. /**
  8550. * Adds a vec3 to the uniform buffer.
  8551. * @param name Name of the uniform, as used in the uniform block in the shader.
  8552. * @param x Define the x component value of the vec3
  8553. * @param y Define the y component value of the vec3
  8554. * @param z Define the z component value of the vec3
  8555. */
  8556. addFloat3(name: string, x: number, y: number, z: number): void;
  8557. /**
  8558. * Adds a vec3 to the uniform buffer.
  8559. * @param name Name of the uniform, as used in the uniform block in the shader.
  8560. * @param color Define the vec3 from a Color
  8561. */
  8562. addColor3(name: string, color: Color3): void;
  8563. /**
  8564. * Adds a vec4 to the uniform buffer.
  8565. * @param name Name of the uniform, as used in the uniform block in the shader.
  8566. * @param color Define the rgb components from a Color
  8567. * @param alpha Define the a component of the vec4
  8568. */
  8569. addColor4(name: string, color: Color3, alpha: number): void;
  8570. /**
  8571. * Adds a vec3 to the uniform buffer.
  8572. * @param name Name of the uniform, as used in the uniform block in the shader.
  8573. * @param vector Define the vec3 components from a Vector
  8574. */
  8575. addVector3(name: string, vector: Vector3): void;
  8576. /**
  8577. * Adds a Matrix 3x3 to the uniform buffer.
  8578. * @param name Name of the uniform, as used in the uniform block in the shader.
  8579. */
  8580. addMatrix3x3(name: string): void;
  8581. /**
  8582. * Adds a Matrix 2x2 to the uniform buffer.
  8583. * @param name Name of the uniform, as used in the uniform block in the shader.
  8584. */
  8585. addMatrix2x2(name: string): void;
  8586. /**
  8587. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8588. */
  8589. create(): void;
  8590. /** @hidden */
  8591. _rebuild(): void;
  8592. /** @hidden */
  8593. get _numBuffers(): number;
  8594. /** @hidden */
  8595. get _indexBuffer(): number;
  8596. /** Gets the name of this buffer */
  8597. get name(): string;
  8598. /**
  8599. * Updates the WebGL Uniform Buffer on the GPU.
  8600. * If the `dynamic` flag is set to true, no cache comparison is done.
  8601. * Otherwise, the buffer will be updated only if the cache differs.
  8602. */
  8603. update(): void;
  8604. private _createNewBuffer;
  8605. private _checkNewFrame;
  8606. /**
  8607. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8608. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8609. * @param data Define the flattened data
  8610. * @param size Define the size of the data.
  8611. */
  8612. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8613. /**
  8614. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8615. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8616. * @param data Define the flattened data
  8617. * @param size Define the size of the data.
  8618. */
  8619. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8620. private _valueCache;
  8621. private _cacheMatrix;
  8622. private _updateMatrix3x3ForUniform;
  8623. private _updateMatrix3x3ForEffect;
  8624. private _updateMatrix2x2ForEffect;
  8625. private _updateMatrix2x2ForUniform;
  8626. private _updateFloatForEffect;
  8627. private _updateFloatForUniform;
  8628. private _updateFloat2ForEffect;
  8629. private _updateFloat2ForUniform;
  8630. private _updateFloat3ForEffect;
  8631. private _updateFloat3ForUniform;
  8632. private _updateFloat4ForEffect;
  8633. private _updateFloat4ForUniform;
  8634. private _updateFloatArrayForEffect;
  8635. private _updateFloatArrayForUniform;
  8636. private _updateArrayForEffect;
  8637. private _updateArrayForUniform;
  8638. private _updateIntArrayForEffect;
  8639. private _updateIntArrayForUniform;
  8640. private _updateMatrixForEffect;
  8641. private _updateMatrixForUniform;
  8642. private _updateMatricesForEffect;
  8643. private _updateMatricesForUniform;
  8644. private _updateVector3ForEffect;
  8645. private _updateVector3ForUniform;
  8646. private _updateVector4ForEffect;
  8647. private _updateVector4ForUniform;
  8648. private _updateColor3ForEffect;
  8649. private _updateColor3ForUniform;
  8650. private _updateColor4ForEffect;
  8651. private _updateColor4ForUniform;
  8652. private _updateIntForEffect;
  8653. private _updateIntForUniform;
  8654. private _updateInt2ForEffect;
  8655. private _updateInt2ForUniform;
  8656. private _updateInt3ForEffect;
  8657. private _updateInt3ForUniform;
  8658. private _updateInt4ForEffect;
  8659. private _updateInt4ForUniform;
  8660. /**
  8661. * Sets a sampler uniform on the effect.
  8662. * @param name Define the name of the sampler.
  8663. * @param texture Define the texture to set in the sampler
  8664. */
  8665. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8666. /**
  8667. * Directly updates the value of the uniform in the cache AND on the GPU.
  8668. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8669. * @param data Define the flattened data
  8670. */
  8671. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8672. /**
  8673. * Binds this uniform buffer to an effect.
  8674. * @param effect Define the effect to bind the buffer to
  8675. * @param name Name of the uniform block in the shader.
  8676. */
  8677. bindToEffect(effect: Effect, name: string): void;
  8678. /**
  8679. * Disposes the uniform buffer.
  8680. */
  8681. dispose(): void;
  8682. }
  8683. }
  8684. declare module BABYLON {
  8685. /**
  8686. * Manages the defines for the Material
  8687. */
  8688. export class MaterialDefines {
  8689. /** @hidden */
  8690. protected _keys: string[];
  8691. private _isDirty;
  8692. /** @hidden */
  8693. _renderId: number;
  8694. /** @hidden */
  8695. _areLightsDirty: boolean;
  8696. /** @hidden */
  8697. _areLightsDisposed: boolean;
  8698. /** @hidden */
  8699. _areAttributesDirty: boolean;
  8700. /** @hidden */
  8701. _areTexturesDirty: boolean;
  8702. /** @hidden */
  8703. _areFresnelDirty: boolean;
  8704. /** @hidden */
  8705. _areMiscDirty: boolean;
  8706. /** @hidden */
  8707. _arePrePassDirty: boolean;
  8708. /** @hidden */
  8709. _areImageProcessingDirty: boolean;
  8710. /** @hidden */
  8711. _normals: boolean;
  8712. /** @hidden */
  8713. _uvs: boolean;
  8714. /** @hidden */
  8715. _needNormals: boolean;
  8716. /** @hidden */
  8717. _needUVs: boolean;
  8718. [id: string]: any;
  8719. /**
  8720. * Specifies if the material needs to be re-calculated
  8721. */
  8722. get isDirty(): boolean;
  8723. /**
  8724. * Marks the material to indicate that it has been re-calculated
  8725. */
  8726. markAsProcessed(): void;
  8727. /**
  8728. * Marks the material to indicate that it needs to be re-calculated
  8729. */
  8730. markAsUnprocessed(): void;
  8731. /**
  8732. * Marks the material to indicate all of its defines need to be re-calculated
  8733. */
  8734. markAllAsDirty(): void;
  8735. /**
  8736. * Marks the material to indicate that image processing needs to be re-calculated
  8737. */
  8738. markAsImageProcessingDirty(): void;
  8739. /**
  8740. * Marks the material to indicate the lights need to be re-calculated
  8741. * @param disposed Defines whether the light is dirty due to dispose or not
  8742. */
  8743. markAsLightDirty(disposed?: boolean): void;
  8744. /**
  8745. * Marks the attribute state as changed
  8746. */
  8747. markAsAttributesDirty(): void;
  8748. /**
  8749. * Marks the texture state as changed
  8750. */
  8751. markAsTexturesDirty(): void;
  8752. /**
  8753. * Marks the fresnel state as changed
  8754. */
  8755. markAsFresnelDirty(): void;
  8756. /**
  8757. * Marks the misc state as changed
  8758. */
  8759. markAsMiscDirty(): void;
  8760. /**
  8761. * Marks the prepass state as changed
  8762. */
  8763. markAsPrePassDirty(): void;
  8764. /**
  8765. * Rebuilds the material defines
  8766. */
  8767. rebuild(): void;
  8768. /**
  8769. * Specifies if two material defines are equal
  8770. * @param other - A material define instance to compare to
  8771. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8772. */
  8773. isEqual(other: MaterialDefines): boolean;
  8774. /**
  8775. * Clones this instance's defines to another instance
  8776. * @param other - material defines to clone values to
  8777. */
  8778. cloneTo(other: MaterialDefines): void;
  8779. /**
  8780. * Resets the material define values
  8781. */
  8782. reset(): void;
  8783. /**
  8784. * Converts the material define values to a string
  8785. * @returns - String of material define information
  8786. */
  8787. toString(): string;
  8788. }
  8789. }
  8790. declare module BABYLON {
  8791. /**
  8792. * Enum that determines the text-wrapping mode to use.
  8793. */
  8794. export enum InspectableType {
  8795. /**
  8796. * Checkbox for booleans
  8797. */
  8798. Checkbox = 0,
  8799. /**
  8800. * Sliders for numbers
  8801. */
  8802. Slider = 1,
  8803. /**
  8804. * Vector3
  8805. */
  8806. Vector3 = 2,
  8807. /**
  8808. * Quaternions
  8809. */
  8810. Quaternion = 3,
  8811. /**
  8812. * Color3
  8813. */
  8814. Color3 = 4,
  8815. /**
  8816. * String
  8817. */
  8818. String = 5
  8819. }
  8820. /**
  8821. * Interface used to define custom inspectable properties.
  8822. * This interface is used by the inspector to display custom property grids
  8823. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8824. */
  8825. export interface IInspectable {
  8826. /**
  8827. * Gets the label to display
  8828. */
  8829. label: string;
  8830. /**
  8831. * Gets the name of the property to edit
  8832. */
  8833. propertyName: string;
  8834. /**
  8835. * Gets the type of the editor to use
  8836. */
  8837. type: InspectableType;
  8838. /**
  8839. * Gets the minimum value of the property when using in "slider" mode
  8840. */
  8841. min?: number;
  8842. /**
  8843. * Gets the maximum value of the property when using in "slider" mode
  8844. */
  8845. max?: number;
  8846. /**
  8847. * Gets the setp to use when using in "slider" mode
  8848. */
  8849. step?: number;
  8850. }
  8851. }
  8852. declare module BABYLON {
  8853. /**
  8854. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8855. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8856. * 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.
  8857. */
  8858. export abstract class Light extends Node {
  8859. /**
  8860. * Falloff Default: light is falling off following the material specification:
  8861. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8862. */
  8863. static readonly FALLOFF_DEFAULT: number;
  8864. /**
  8865. * Falloff Physical: light is falling off following the inverse squared distance law.
  8866. */
  8867. static readonly FALLOFF_PHYSICAL: number;
  8868. /**
  8869. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8870. * to enhance interoperability with other engines.
  8871. */
  8872. static readonly FALLOFF_GLTF: number;
  8873. /**
  8874. * Falloff Standard: light is falling off like in the standard material
  8875. * to enhance interoperability with other materials.
  8876. */
  8877. static readonly FALLOFF_STANDARD: number;
  8878. /**
  8879. * If every light affecting the material is in this lightmapMode,
  8880. * material.lightmapTexture adds or multiplies
  8881. * (depends on material.useLightmapAsShadowmap)
  8882. * after every other light calculations.
  8883. */
  8884. static readonly LIGHTMAP_DEFAULT: number;
  8885. /**
  8886. * material.lightmapTexture as only diffuse lighting from this light
  8887. * adds only specular lighting from this light
  8888. * adds dynamic shadows
  8889. */
  8890. static readonly LIGHTMAP_SPECULAR: number;
  8891. /**
  8892. * material.lightmapTexture as only lighting
  8893. * no light calculation from this light
  8894. * only adds dynamic shadows from this light
  8895. */
  8896. static readonly LIGHTMAP_SHADOWSONLY: number;
  8897. /**
  8898. * Each light type uses the default quantity according to its type:
  8899. * point/spot lights use luminous intensity
  8900. * directional lights use illuminance
  8901. */
  8902. static readonly INTENSITYMODE_AUTOMATIC: number;
  8903. /**
  8904. * lumen (lm)
  8905. */
  8906. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8907. /**
  8908. * candela (lm/sr)
  8909. */
  8910. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8911. /**
  8912. * lux (lm/m^2)
  8913. */
  8914. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8915. /**
  8916. * nit (cd/m^2)
  8917. */
  8918. static readonly INTENSITYMODE_LUMINANCE: number;
  8919. /**
  8920. * Light type const id of the point light.
  8921. */
  8922. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8923. /**
  8924. * Light type const id of the directional light.
  8925. */
  8926. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8927. /**
  8928. * Light type const id of the spot light.
  8929. */
  8930. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8931. /**
  8932. * Light type const id of the hemispheric light.
  8933. */
  8934. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8935. /**
  8936. * Diffuse gives the basic color to an object.
  8937. */
  8938. diffuse: Color3;
  8939. /**
  8940. * Specular produces a highlight color on an object.
  8941. * Note: This is note affecting PBR materials.
  8942. */
  8943. specular: Color3;
  8944. /**
  8945. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8946. * falling off base on range or angle.
  8947. * This can be set to any values in Light.FALLOFF_x.
  8948. *
  8949. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8950. * other types of materials.
  8951. */
  8952. falloffType: number;
  8953. /**
  8954. * Strength of the light.
  8955. * Note: By default it is define in the framework own unit.
  8956. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8957. */
  8958. intensity: number;
  8959. private _range;
  8960. protected _inverseSquaredRange: number;
  8961. /**
  8962. * Defines how far from the source the light is impacting in scene units.
  8963. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8964. */
  8965. get range(): number;
  8966. /**
  8967. * Defines how far from the source the light is impacting in scene units.
  8968. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8969. */
  8970. set range(value: number);
  8971. /**
  8972. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8973. * of light.
  8974. */
  8975. private _photometricScale;
  8976. private _intensityMode;
  8977. /**
  8978. * Gets the photometric scale used to interpret the intensity.
  8979. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8980. */
  8981. get intensityMode(): number;
  8982. /**
  8983. * Sets the photometric scale used to interpret the intensity.
  8984. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8985. */
  8986. set intensityMode(value: number);
  8987. private _radius;
  8988. /**
  8989. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8990. */
  8991. get radius(): number;
  8992. /**
  8993. * sets the light radius used by PBR Materials to simulate soft area lights.
  8994. */
  8995. set radius(value: number);
  8996. private _renderPriority;
  8997. /**
  8998. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8999. * exceeding the number allowed of the materials.
  9000. */
  9001. renderPriority: number;
  9002. private _shadowEnabled;
  9003. /**
  9004. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9005. * the current shadow generator.
  9006. */
  9007. get shadowEnabled(): boolean;
  9008. /**
  9009. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9010. * the current shadow generator.
  9011. */
  9012. set shadowEnabled(value: boolean);
  9013. private _includedOnlyMeshes;
  9014. /**
  9015. * Gets the only meshes impacted by this light.
  9016. */
  9017. get includedOnlyMeshes(): AbstractMesh[];
  9018. /**
  9019. * Sets the only meshes impacted by this light.
  9020. */
  9021. set includedOnlyMeshes(value: AbstractMesh[]);
  9022. private _excludedMeshes;
  9023. /**
  9024. * Gets the meshes not impacted by this light.
  9025. */
  9026. get excludedMeshes(): AbstractMesh[];
  9027. /**
  9028. * Sets the meshes not impacted by this light.
  9029. */
  9030. set excludedMeshes(value: AbstractMesh[]);
  9031. private _excludeWithLayerMask;
  9032. /**
  9033. * Gets the layer id use to find what meshes are not impacted by the light.
  9034. * Inactive if 0
  9035. */
  9036. get excludeWithLayerMask(): number;
  9037. /**
  9038. * Sets the layer id use to find what meshes are not impacted by the light.
  9039. * Inactive if 0
  9040. */
  9041. set excludeWithLayerMask(value: number);
  9042. private _includeOnlyWithLayerMask;
  9043. /**
  9044. * Gets the layer id use to find what meshes are impacted by the light.
  9045. * Inactive if 0
  9046. */
  9047. get includeOnlyWithLayerMask(): number;
  9048. /**
  9049. * Sets the layer id use to find what meshes are impacted by the light.
  9050. * Inactive if 0
  9051. */
  9052. set includeOnlyWithLayerMask(value: number);
  9053. private _lightmapMode;
  9054. /**
  9055. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9056. */
  9057. get lightmapMode(): number;
  9058. /**
  9059. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9060. */
  9061. set lightmapMode(value: number);
  9062. /**
  9063. * Shadow generator associted to the light.
  9064. * @hidden Internal use only.
  9065. */
  9066. _shadowGenerator: Nullable<IShadowGenerator>;
  9067. /**
  9068. * @hidden Internal use only.
  9069. */
  9070. _excludedMeshesIds: string[];
  9071. /**
  9072. * @hidden Internal use only.
  9073. */
  9074. _includedOnlyMeshesIds: string[];
  9075. /**
  9076. * The current light unifom buffer.
  9077. * @hidden Internal use only.
  9078. */
  9079. _uniformBuffer: UniformBuffer;
  9080. /** @hidden */
  9081. _renderId: number;
  9082. /**
  9083. * Creates a Light object in the scene.
  9084. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9085. * @param name The firendly name of the light
  9086. * @param scene The scene the light belongs too
  9087. */
  9088. constructor(name: string, scene: Scene);
  9089. protected abstract _buildUniformLayout(): void;
  9090. /**
  9091. * Sets the passed Effect "effect" with the Light information.
  9092. * @param effect The effect to update
  9093. * @param lightIndex The index of the light in the effect to update
  9094. * @returns The light
  9095. */
  9096. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9097. /**
  9098. * Sets the passed Effect "effect" with the Light textures.
  9099. * @param effect The effect to update
  9100. * @param lightIndex The index of the light in the effect to update
  9101. * @returns The light
  9102. */
  9103. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9104. /**
  9105. * Binds the lights information from the scene to the effect for the given mesh.
  9106. * @param lightIndex Light index
  9107. * @param scene The scene where the light belongs to
  9108. * @param effect The effect we are binding the data to
  9109. * @param useSpecular Defines if specular is supported
  9110. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9111. */
  9112. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9113. /**
  9114. * Sets the passed Effect "effect" with the Light information.
  9115. * @param effect The effect to update
  9116. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9117. * @returns The light
  9118. */
  9119. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9120. /**
  9121. * Returns the string "Light".
  9122. * @returns the class name
  9123. */
  9124. getClassName(): string;
  9125. /** @hidden */
  9126. readonly _isLight: boolean;
  9127. /**
  9128. * Converts the light information to a readable string for debug purpose.
  9129. * @param fullDetails Supports for multiple levels of logging within scene loading
  9130. * @returns the human readable light info
  9131. */
  9132. toString(fullDetails?: boolean): string;
  9133. /** @hidden */
  9134. protected _syncParentEnabledState(): void;
  9135. /**
  9136. * Set the enabled state of this node.
  9137. * @param value - the new enabled state
  9138. */
  9139. setEnabled(value: boolean): void;
  9140. /**
  9141. * Returns the Light associated shadow generator if any.
  9142. * @return the associated shadow generator.
  9143. */
  9144. getShadowGenerator(): Nullable<IShadowGenerator>;
  9145. /**
  9146. * Returns a Vector3, the absolute light position in the World.
  9147. * @returns the world space position of the light
  9148. */
  9149. getAbsolutePosition(): Vector3;
  9150. /**
  9151. * Specifies if the light will affect the passed mesh.
  9152. * @param mesh The mesh to test against the light
  9153. * @return true the mesh is affected otherwise, false.
  9154. */
  9155. canAffectMesh(mesh: AbstractMesh): boolean;
  9156. /**
  9157. * Sort function to order lights for rendering.
  9158. * @param a First Light object to compare to second.
  9159. * @param b Second Light object to compare first.
  9160. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9161. */
  9162. static CompareLightsPriority(a: Light, b: Light): number;
  9163. /**
  9164. * Releases resources associated with this node.
  9165. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9166. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9167. */
  9168. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9169. /**
  9170. * Returns the light type ID (integer).
  9171. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9172. */
  9173. getTypeID(): number;
  9174. /**
  9175. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9176. * @returns the scaled intensity in intensity mode unit
  9177. */
  9178. getScaledIntensity(): number;
  9179. /**
  9180. * Returns a new Light object, named "name", from the current one.
  9181. * @param name The name of the cloned light
  9182. * @param newParent The parent of this light, if it has one
  9183. * @returns the new created light
  9184. */
  9185. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9186. /**
  9187. * Serializes the current light into a Serialization object.
  9188. * @returns the serialized object.
  9189. */
  9190. serialize(): any;
  9191. /**
  9192. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9193. * This new light is named "name" and added to the passed scene.
  9194. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9195. * @param name The friendly name of the light
  9196. * @param scene The scene the new light will belong to
  9197. * @returns the constructor function
  9198. */
  9199. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9200. /**
  9201. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9202. * @param parsedLight The JSON representation of the light
  9203. * @param scene The scene to create the parsed light in
  9204. * @returns the created light after parsing
  9205. */
  9206. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9207. private _hookArrayForExcluded;
  9208. private _hookArrayForIncludedOnly;
  9209. private _resyncMeshes;
  9210. /**
  9211. * Forces the meshes to update their light related information in their rendering used effects
  9212. * @hidden Internal Use Only
  9213. */
  9214. _markMeshesAsLightDirty(): void;
  9215. /**
  9216. * Recomputes the cached photometric scale if needed.
  9217. */
  9218. private _computePhotometricScale;
  9219. /**
  9220. * Returns the Photometric Scale according to the light type and intensity mode.
  9221. */
  9222. private _getPhotometricScale;
  9223. /**
  9224. * Reorder the light in the scene according to their defined priority.
  9225. * @hidden Internal Use Only
  9226. */
  9227. _reorderLightsInScene(): void;
  9228. /**
  9229. * Prepares the list of defines specific to the light type.
  9230. * @param defines the list of defines
  9231. * @param lightIndex defines the index of the light for the effect
  9232. */
  9233. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9234. }
  9235. }
  9236. declare module BABYLON {
  9237. /** Defines supported spaces */
  9238. export enum Space {
  9239. /** Local (object) space */
  9240. LOCAL = 0,
  9241. /** World space */
  9242. WORLD = 1,
  9243. /** Bone space */
  9244. BONE = 2
  9245. }
  9246. /** Defines the 3 main axes */
  9247. export class Axis {
  9248. /** X axis */
  9249. static X: Vector3;
  9250. /** Y axis */
  9251. static Y: Vector3;
  9252. /** Z axis */
  9253. static Z: Vector3;
  9254. }
  9255. /**
  9256. * Defines cartesian components.
  9257. */
  9258. export enum Coordinate {
  9259. /** X axis */
  9260. X = 0,
  9261. /** Y axis */
  9262. Y = 1,
  9263. /** Z axis */
  9264. Z = 2
  9265. }
  9266. }
  9267. declare module BABYLON {
  9268. /**
  9269. * Interface describing all the common properties and methods a shadow light needs to implement.
  9270. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9271. * as well as binding the different shadow properties to the effects.
  9272. */
  9273. export interface IShadowLight extends Light {
  9274. /**
  9275. * The light id in the scene (used in scene.findLighById for instance)
  9276. */
  9277. id: string;
  9278. /**
  9279. * The position the shdow will be casted from.
  9280. */
  9281. position: Vector3;
  9282. /**
  9283. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9284. */
  9285. direction: Vector3;
  9286. /**
  9287. * The transformed position. Position of the light in world space taking parenting in account.
  9288. */
  9289. transformedPosition: Vector3;
  9290. /**
  9291. * The transformed direction. Direction of the light in world space taking parenting in account.
  9292. */
  9293. transformedDirection: Vector3;
  9294. /**
  9295. * The friendly name of the light in the scene.
  9296. */
  9297. name: string;
  9298. /**
  9299. * Defines the shadow projection clipping minimum z value.
  9300. */
  9301. shadowMinZ: number;
  9302. /**
  9303. * Defines the shadow projection clipping maximum z value.
  9304. */
  9305. shadowMaxZ: number;
  9306. /**
  9307. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9308. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9309. */
  9310. computeTransformedInformation(): boolean;
  9311. /**
  9312. * Gets the scene the light belongs to.
  9313. * @returns The scene
  9314. */
  9315. getScene(): Scene;
  9316. /**
  9317. * Callback defining a custom Projection Matrix Builder.
  9318. * This can be used to override the default projection matrix computation.
  9319. */
  9320. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9321. /**
  9322. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9323. * @param matrix The materix to updated with the projection information
  9324. * @param viewMatrix The transform matrix of the light
  9325. * @param renderList The list of mesh to render in the map
  9326. * @returns The current light
  9327. */
  9328. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9329. /**
  9330. * Gets the current depth scale used in ESM.
  9331. * @returns The scale
  9332. */
  9333. getDepthScale(): number;
  9334. /**
  9335. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9336. * @returns true if a cube texture needs to be use
  9337. */
  9338. needCube(): boolean;
  9339. /**
  9340. * Detects if the projection matrix requires to be recomputed this frame.
  9341. * @returns true if it requires to be recomputed otherwise, false.
  9342. */
  9343. needProjectionMatrixCompute(): boolean;
  9344. /**
  9345. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9346. */
  9347. forceProjectionMatrixCompute(): void;
  9348. /**
  9349. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9350. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9351. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9352. */
  9353. getShadowDirection(faceIndex?: number): Vector3;
  9354. /**
  9355. * Gets the minZ used for shadow according to both the scene and the light.
  9356. * @param activeCamera The camera we are returning the min for
  9357. * @returns the depth min z
  9358. */
  9359. getDepthMinZ(activeCamera: Camera): number;
  9360. /**
  9361. * Gets the maxZ used for shadow according to both the scene and the light.
  9362. * @param activeCamera The camera we are returning the max for
  9363. * @returns the depth max z
  9364. */
  9365. getDepthMaxZ(activeCamera: Camera): number;
  9366. }
  9367. /**
  9368. * Base implementation IShadowLight
  9369. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9370. */
  9371. export abstract class ShadowLight extends Light implements IShadowLight {
  9372. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9373. protected _position: Vector3;
  9374. protected _setPosition(value: Vector3): void;
  9375. /**
  9376. * Sets the position the shadow will be casted from. Also use as the light position for both
  9377. * point and spot lights.
  9378. */
  9379. get position(): Vector3;
  9380. /**
  9381. * Sets the position the shadow will be casted from. Also use as the light position for both
  9382. * point and spot lights.
  9383. */
  9384. set position(value: Vector3);
  9385. protected _direction: Vector3;
  9386. protected _setDirection(value: Vector3): void;
  9387. /**
  9388. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9389. * Also use as the light direction on spot and directional lights.
  9390. */
  9391. get direction(): Vector3;
  9392. /**
  9393. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9394. * Also use as the light direction on spot and directional lights.
  9395. */
  9396. set direction(value: Vector3);
  9397. protected _shadowMinZ: number;
  9398. /**
  9399. * Gets the shadow projection clipping minimum z value.
  9400. */
  9401. get shadowMinZ(): number;
  9402. /**
  9403. * Sets the shadow projection clipping minimum z value.
  9404. */
  9405. set shadowMinZ(value: number);
  9406. protected _shadowMaxZ: number;
  9407. /**
  9408. * Sets the shadow projection clipping maximum z value.
  9409. */
  9410. get shadowMaxZ(): number;
  9411. /**
  9412. * Gets the shadow projection clipping maximum z value.
  9413. */
  9414. set shadowMaxZ(value: number);
  9415. /**
  9416. * Callback defining a custom Projection Matrix Builder.
  9417. * This can be used to override the default projection matrix computation.
  9418. */
  9419. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9420. /**
  9421. * The transformed position. Position of the light in world space taking parenting in account.
  9422. */
  9423. transformedPosition: Vector3;
  9424. /**
  9425. * The transformed direction. Direction of the light in world space taking parenting in account.
  9426. */
  9427. transformedDirection: Vector3;
  9428. private _needProjectionMatrixCompute;
  9429. /**
  9430. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9431. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9432. */
  9433. computeTransformedInformation(): boolean;
  9434. /**
  9435. * Return the depth scale used for the shadow map.
  9436. * @returns the depth scale.
  9437. */
  9438. getDepthScale(): number;
  9439. /**
  9440. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9441. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9442. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9443. */
  9444. getShadowDirection(faceIndex?: number): Vector3;
  9445. /**
  9446. * Returns the ShadowLight absolute position in the World.
  9447. * @returns the position vector in world space
  9448. */
  9449. getAbsolutePosition(): Vector3;
  9450. /**
  9451. * Sets the ShadowLight direction toward the passed target.
  9452. * @param target The point to target in local space
  9453. * @returns the updated ShadowLight direction
  9454. */
  9455. setDirectionToTarget(target: Vector3): Vector3;
  9456. /**
  9457. * Returns the light rotation in euler definition.
  9458. * @returns the x y z rotation in local space.
  9459. */
  9460. getRotation(): Vector3;
  9461. /**
  9462. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9463. * @returns true if a cube texture needs to be use
  9464. */
  9465. needCube(): boolean;
  9466. /**
  9467. * Detects if the projection matrix requires to be recomputed this frame.
  9468. * @returns true if it requires to be recomputed otherwise, false.
  9469. */
  9470. needProjectionMatrixCompute(): boolean;
  9471. /**
  9472. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9473. */
  9474. forceProjectionMatrixCompute(): void;
  9475. /** @hidden */
  9476. _initCache(): void;
  9477. /** @hidden */
  9478. _isSynchronized(): boolean;
  9479. /**
  9480. * Computes the world matrix of the node
  9481. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9482. * @returns the world matrix
  9483. */
  9484. computeWorldMatrix(force?: boolean): Matrix;
  9485. /**
  9486. * Gets the minZ used for shadow according to both the scene and the light.
  9487. * @param activeCamera The camera we are returning the min for
  9488. * @returns the depth min z
  9489. */
  9490. getDepthMinZ(activeCamera: Camera): number;
  9491. /**
  9492. * Gets the maxZ used for shadow according to both the scene and the light.
  9493. * @param activeCamera The camera we are returning the max for
  9494. * @returns the depth max z
  9495. */
  9496. getDepthMaxZ(activeCamera: Camera): number;
  9497. /**
  9498. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9499. * @param matrix The materix to updated with the projection information
  9500. * @param viewMatrix The transform matrix of the light
  9501. * @param renderList The list of mesh to render in the map
  9502. * @returns The current light
  9503. */
  9504. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9505. }
  9506. }
  9507. declare module BABYLON {
  9508. /**
  9509. * Configuration needed for prepass-capable materials
  9510. */
  9511. export class PrePassConfiguration {
  9512. /**
  9513. * Previous world matrices of meshes carrying this material
  9514. * Used for computing velocity
  9515. */
  9516. previousWorldMatrices: {
  9517. [index: number]: Matrix;
  9518. };
  9519. /**
  9520. * Previous view project matrix
  9521. * Used for computing velocity
  9522. */
  9523. previousViewProjection: Matrix;
  9524. /**
  9525. * Previous bones of meshes carrying this material
  9526. * Used for computing velocity
  9527. */
  9528. previousBones: {
  9529. [index: number]: Float32Array;
  9530. };
  9531. /**
  9532. * Add the required uniforms to the current list.
  9533. * @param uniforms defines the current uniform list.
  9534. */
  9535. static AddUniforms(uniforms: string[]): void;
  9536. /**
  9537. * Add the required samplers to the current list.
  9538. * @param samplers defines the current sampler list.
  9539. */
  9540. static AddSamplers(samplers: string[]): void;
  9541. /**
  9542. * Binds the material data.
  9543. * @param effect defines the effect to update
  9544. * @param scene defines the scene the material belongs to.
  9545. * @param mesh The mesh
  9546. * @param world World matrix of this mesh
  9547. * @param isFrozen Is the material frozen
  9548. */
  9549. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9550. }
  9551. }
  9552. declare module BABYLON {
  9553. /**
  9554. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9555. * This is the base of the follow, arc rotate cameras and Free camera
  9556. * @see https://doc.babylonjs.com/features/cameras
  9557. */
  9558. export class TargetCamera extends Camera {
  9559. private static _RigCamTransformMatrix;
  9560. private static _TargetTransformMatrix;
  9561. private static _TargetFocalPoint;
  9562. private _tmpUpVector;
  9563. private _tmpTargetVector;
  9564. /**
  9565. * Define the current direction the camera is moving to
  9566. */
  9567. cameraDirection: Vector3;
  9568. /**
  9569. * Define the current rotation the camera is rotating to
  9570. */
  9571. cameraRotation: Vector2;
  9572. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9573. ignoreParentScaling: boolean;
  9574. /**
  9575. * When set, the up vector of the camera will be updated by the rotation of the camera
  9576. */
  9577. updateUpVectorFromRotation: boolean;
  9578. private _tmpQuaternion;
  9579. /**
  9580. * Define the current rotation of the camera
  9581. */
  9582. rotation: Vector3;
  9583. /**
  9584. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9585. */
  9586. rotationQuaternion: Quaternion;
  9587. /**
  9588. * Define the current speed of the camera
  9589. */
  9590. speed: number;
  9591. /**
  9592. * Add constraint to the camera to prevent it to move freely in all directions and
  9593. * around all axis.
  9594. */
  9595. noRotationConstraint: boolean;
  9596. /**
  9597. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9598. * panning
  9599. */
  9600. invertRotation: boolean;
  9601. /**
  9602. * Speed multiplier for inverse camera panning
  9603. */
  9604. inverseRotationSpeed: number;
  9605. /**
  9606. * Define the current target of the camera as an object or a position.
  9607. */
  9608. lockedTarget: any;
  9609. /** @hidden */
  9610. _currentTarget: Vector3;
  9611. /** @hidden */
  9612. _initialFocalDistance: number;
  9613. /** @hidden */
  9614. _viewMatrix: Matrix;
  9615. /** @hidden */
  9616. _camMatrix: Matrix;
  9617. /** @hidden */
  9618. _cameraTransformMatrix: Matrix;
  9619. /** @hidden */
  9620. _cameraRotationMatrix: Matrix;
  9621. /** @hidden */
  9622. _referencePoint: Vector3;
  9623. /** @hidden */
  9624. _transformedReferencePoint: Vector3;
  9625. /** @hidden */
  9626. _reset: () => void;
  9627. private _defaultUp;
  9628. /**
  9629. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9630. * This is the base of the follow, arc rotate cameras and Free camera
  9631. * @see https://doc.babylonjs.com/features/cameras
  9632. * @param name Defines the name of the camera in the scene
  9633. * @param position Defines the start position of the camera in the scene
  9634. * @param scene Defines the scene the camera belongs to
  9635. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9636. */
  9637. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9638. /**
  9639. * Gets the position in front of the camera at a given distance.
  9640. * @param distance The distance from the camera we want the position to be
  9641. * @returns the position
  9642. */
  9643. getFrontPosition(distance: number): Vector3;
  9644. /** @hidden */
  9645. _getLockedTargetPosition(): Nullable<Vector3>;
  9646. private _storedPosition;
  9647. private _storedRotation;
  9648. private _storedRotationQuaternion;
  9649. /**
  9650. * Store current camera state of the camera (fov, position, rotation, etc..)
  9651. * @returns the camera
  9652. */
  9653. storeState(): Camera;
  9654. /**
  9655. * Restored camera state. You must call storeState() first
  9656. * @returns whether it was successful or not
  9657. * @hidden
  9658. */
  9659. _restoreStateValues(): boolean;
  9660. /** @hidden */
  9661. _initCache(): void;
  9662. /** @hidden */
  9663. _updateCache(ignoreParentClass?: boolean): void;
  9664. /** @hidden */
  9665. _isSynchronizedViewMatrix(): boolean;
  9666. /** @hidden */
  9667. _computeLocalCameraSpeed(): number;
  9668. /**
  9669. * Defines the target the camera should look at.
  9670. * @param target Defines the new target as a Vector or a mesh
  9671. */
  9672. setTarget(target: Vector3): void;
  9673. /**
  9674. * Defines the target point of the camera.
  9675. * The camera looks towards it form the radius distance.
  9676. */
  9677. get target(): Vector3;
  9678. set target(value: Vector3);
  9679. /**
  9680. * Return the current target position of the camera. This value is expressed in local space.
  9681. * @returns the target position
  9682. */
  9683. getTarget(): Vector3;
  9684. /** @hidden */
  9685. _decideIfNeedsToMove(): boolean;
  9686. /** @hidden */
  9687. _updatePosition(): void;
  9688. /** @hidden */
  9689. _checkInputs(): void;
  9690. protected _updateCameraRotationMatrix(): void;
  9691. /**
  9692. * 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)
  9693. * @returns the current camera
  9694. */
  9695. private _rotateUpVectorWithCameraRotationMatrix;
  9696. private _cachedRotationZ;
  9697. private _cachedQuaternionRotationZ;
  9698. /** @hidden */
  9699. _getViewMatrix(): Matrix;
  9700. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9701. /**
  9702. * @hidden
  9703. */
  9704. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9705. /**
  9706. * @hidden
  9707. */
  9708. _updateRigCameras(): void;
  9709. private _getRigCamPositionAndTarget;
  9710. /**
  9711. * Gets the current object class name.
  9712. * @return the class name
  9713. */
  9714. getClassName(): string;
  9715. }
  9716. }
  9717. declare module BABYLON {
  9718. /**
  9719. * @ignore
  9720. * This is a list of all the different input types that are available in the application.
  9721. * Fo instance: ArcRotateCameraGamepadInput...
  9722. */
  9723. export var CameraInputTypes: {};
  9724. /**
  9725. * This is the contract to implement in order to create a new input class.
  9726. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9727. */
  9728. export interface ICameraInput<TCamera extends Camera> {
  9729. /**
  9730. * Defines the camera the input is attached to.
  9731. */
  9732. camera: Nullable<TCamera>;
  9733. /**
  9734. * Gets the class name of the current intput.
  9735. * @returns the class name
  9736. */
  9737. getClassName(): string;
  9738. /**
  9739. * Get the friendly name associated with the input class.
  9740. * @returns the input friendly name
  9741. */
  9742. getSimpleName(): string;
  9743. /**
  9744. * Attach the input controls to a specific dom element to get the input from.
  9745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9746. */
  9747. attachControl(noPreventDefault?: boolean): void;
  9748. /**
  9749. * Detach the current controls from the specified dom element.
  9750. */
  9751. detachControl(): void;
  9752. /**
  9753. * Update the current camera state depending on the inputs that have been used this frame.
  9754. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9755. */
  9756. checkInputs?: () => void;
  9757. }
  9758. /**
  9759. * Represents a map of input types to input instance or input index to input instance.
  9760. */
  9761. export interface CameraInputsMap<TCamera extends Camera> {
  9762. /**
  9763. * Accessor to the input by input type.
  9764. */
  9765. [name: string]: ICameraInput<TCamera>;
  9766. /**
  9767. * Accessor to the input by input index.
  9768. */
  9769. [idx: number]: ICameraInput<TCamera>;
  9770. }
  9771. /**
  9772. * This represents the input manager used within a camera.
  9773. * It helps dealing with all the different kind of input attached to a camera.
  9774. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9775. */
  9776. export class CameraInputsManager<TCamera extends Camera> {
  9777. /**
  9778. * Defines the list of inputs attahed to the camera.
  9779. */
  9780. attached: CameraInputsMap<TCamera>;
  9781. /**
  9782. * Defines the dom element the camera is collecting inputs from.
  9783. * This is null if the controls have not been attached.
  9784. */
  9785. attachedToElement: boolean;
  9786. /**
  9787. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9788. */
  9789. noPreventDefault: boolean;
  9790. /**
  9791. * Defined the camera the input manager belongs to.
  9792. */
  9793. camera: TCamera;
  9794. /**
  9795. * Update the current camera state depending on the inputs that have been used this frame.
  9796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9797. */
  9798. checkInputs: () => void;
  9799. /**
  9800. * Instantiate a new Camera Input Manager.
  9801. * @param camera Defines the camera the input manager blongs to
  9802. */
  9803. constructor(camera: TCamera);
  9804. /**
  9805. * Add an input method to a camera
  9806. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9807. * @param input camera input method
  9808. */
  9809. add(input: ICameraInput<TCamera>): void;
  9810. /**
  9811. * Remove a specific input method from a camera
  9812. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9813. * @param inputToRemove camera input method
  9814. */
  9815. remove(inputToRemove: ICameraInput<TCamera>): void;
  9816. /**
  9817. * Remove a specific input type from a camera
  9818. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9819. * @param inputType the type of the input to remove
  9820. */
  9821. removeByType(inputType: string): void;
  9822. private _addCheckInputs;
  9823. /**
  9824. * Attach the input controls to the currently attached dom element to listen the events from.
  9825. * @param input Defines the input to attach
  9826. */
  9827. attachInput(input: ICameraInput<TCamera>): void;
  9828. /**
  9829. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9830. * @param element Defines the dom element to collect the events from
  9831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9832. */
  9833. attachElement(noPreventDefault?: boolean): void;
  9834. /**
  9835. * Detach the current manager inputs controls from a specific dom element.
  9836. * @param element Defines the dom element to collect the events from
  9837. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9838. */
  9839. detachElement(disconnect?: boolean): void;
  9840. /**
  9841. * Rebuild the dynamic inputCheck function from the current list of
  9842. * defined inputs in the manager.
  9843. */
  9844. rebuildInputCheck(): void;
  9845. /**
  9846. * Remove all attached input methods from a camera
  9847. */
  9848. clear(): void;
  9849. /**
  9850. * Serialize the current input manager attached to a camera.
  9851. * This ensures than once parsed,
  9852. * the input associated to the camera will be identical to the current ones
  9853. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9854. */
  9855. serialize(serializedCamera: any): void;
  9856. /**
  9857. * Parses an input manager serialized JSON to restore the previous list of inputs
  9858. * and states associated to a camera.
  9859. * @param parsedCamera Defines the JSON to parse
  9860. */
  9861. parse(parsedCamera: any): void;
  9862. }
  9863. }
  9864. declare module BABYLON {
  9865. /**
  9866. * Gather the list of keyboard event types as constants.
  9867. */
  9868. export class KeyboardEventTypes {
  9869. /**
  9870. * The keydown event is fired when a key becomes active (pressed).
  9871. */
  9872. static readonly KEYDOWN: number;
  9873. /**
  9874. * The keyup event is fired when a key has been released.
  9875. */
  9876. static readonly KEYUP: number;
  9877. }
  9878. /**
  9879. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9880. */
  9881. export class KeyboardInfo {
  9882. /**
  9883. * Defines the type of event (KeyboardEventTypes)
  9884. */
  9885. type: number;
  9886. /**
  9887. * Defines the related dom event
  9888. */
  9889. event: KeyboardEvent;
  9890. /**
  9891. * Instantiates a new keyboard info.
  9892. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9893. * @param type Defines the type of event (KeyboardEventTypes)
  9894. * @param event Defines the related dom event
  9895. */
  9896. constructor(
  9897. /**
  9898. * Defines the type of event (KeyboardEventTypes)
  9899. */
  9900. type: number,
  9901. /**
  9902. * Defines the related dom event
  9903. */
  9904. event: KeyboardEvent);
  9905. }
  9906. /**
  9907. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9908. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9909. */
  9910. export class KeyboardInfoPre extends KeyboardInfo {
  9911. /**
  9912. * Defines the type of event (KeyboardEventTypes)
  9913. */
  9914. type: number;
  9915. /**
  9916. * Defines the related dom event
  9917. */
  9918. event: KeyboardEvent;
  9919. /**
  9920. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9921. */
  9922. skipOnPointerObservable: boolean;
  9923. /**
  9924. * Instantiates a new keyboard pre info.
  9925. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9926. * @param type Defines the type of event (KeyboardEventTypes)
  9927. * @param event Defines the related dom event
  9928. */
  9929. constructor(
  9930. /**
  9931. * Defines the type of event (KeyboardEventTypes)
  9932. */
  9933. type: number,
  9934. /**
  9935. * Defines the related dom event
  9936. */
  9937. event: KeyboardEvent);
  9938. }
  9939. }
  9940. declare module BABYLON {
  9941. /**
  9942. * Manage the keyboard inputs to control the movement of a free camera.
  9943. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9944. */
  9945. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9946. /**
  9947. * Defines the camera the input is attached to.
  9948. */
  9949. camera: FreeCamera;
  9950. /**
  9951. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9952. */
  9953. keysUp: number[];
  9954. /**
  9955. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9956. */
  9957. keysUpward: number[];
  9958. /**
  9959. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9960. */
  9961. keysDown: number[];
  9962. /**
  9963. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9964. */
  9965. keysDownward: number[];
  9966. /**
  9967. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9968. */
  9969. keysLeft: number[];
  9970. /**
  9971. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9972. */
  9973. keysRight: number[];
  9974. private _keys;
  9975. private _onCanvasBlurObserver;
  9976. private _onKeyboardObserver;
  9977. private _engine;
  9978. private _scene;
  9979. /**
  9980. * Attach the input controls to a specific dom element to get the input from.
  9981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9982. */
  9983. attachControl(noPreventDefault?: boolean): void;
  9984. /**
  9985. * Detach the current controls from the specified dom element.
  9986. */
  9987. detachControl(): void;
  9988. /**
  9989. * Update the current camera state depending on the inputs that have been used this frame.
  9990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9991. */
  9992. checkInputs(): void;
  9993. /**
  9994. * Gets the class name of the current intput.
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. _onLostFocus(): void;
  10000. /**
  10001. * Get the friendly name associated with the input class.
  10002. * @returns the input friendly name
  10003. */
  10004. getSimpleName(): string;
  10005. }
  10006. }
  10007. declare module BABYLON {
  10008. /**
  10009. * Interface used to define Action
  10010. */
  10011. export interface IAction {
  10012. /**
  10013. * Trigger for the action
  10014. */
  10015. trigger: number;
  10016. /** Options of the trigger */
  10017. triggerOptions: any;
  10018. /**
  10019. * Gets the trigger parameters
  10020. * @returns the trigger parameters
  10021. */
  10022. getTriggerParameter(): any;
  10023. /**
  10024. * Internal only - executes current action event
  10025. * @hidden
  10026. */
  10027. _executeCurrent(evt?: ActionEvent): void;
  10028. /**
  10029. * Serialize placeholder for child classes
  10030. * @param parent of child
  10031. * @returns the serialized object
  10032. */
  10033. serialize(parent: any): any;
  10034. /**
  10035. * Internal only
  10036. * @hidden
  10037. */
  10038. _prepare(): void;
  10039. /**
  10040. * Internal only - manager for action
  10041. * @hidden
  10042. */
  10043. _actionManager: Nullable<AbstractActionManager>;
  10044. /**
  10045. * Adds action to chain of actions, may be a DoNothingAction
  10046. * @param action defines the next action to execute
  10047. * @returns The action passed in
  10048. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10049. */
  10050. then(action: IAction): IAction;
  10051. }
  10052. /**
  10053. * The action to be carried out following a trigger
  10054. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10055. */
  10056. export class Action implements IAction {
  10057. /** the trigger, with or without parameters, for the action */
  10058. triggerOptions: any;
  10059. /**
  10060. * Trigger for the action
  10061. */
  10062. trigger: number;
  10063. /**
  10064. * Internal only - manager for action
  10065. * @hidden
  10066. */
  10067. _actionManager: ActionManager;
  10068. private _nextActiveAction;
  10069. private _child;
  10070. private _condition?;
  10071. private _triggerParameter;
  10072. /**
  10073. * An event triggered prior to action being executed.
  10074. */
  10075. onBeforeExecuteObservable: Observable<Action>;
  10076. /**
  10077. * Creates a new Action
  10078. * @param triggerOptions the trigger, with or without parameters, for the action
  10079. * @param condition an optional determinant of action
  10080. */
  10081. constructor(
  10082. /** the trigger, with or without parameters, for the action */
  10083. triggerOptions: any, condition?: Condition);
  10084. /**
  10085. * Internal only
  10086. * @hidden
  10087. */
  10088. _prepare(): void;
  10089. /**
  10090. * Gets the trigger parameter
  10091. * @returns the trigger parameter
  10092. */
  10093. getTriggerParameter(): any;
  10094. /**
  10095. * Sets the trigger parameter
  10096. * @param value defines the new trigger parameter
  10097. */
  10098. setTriggerParameter(value: any): void;
  10099. /**
  10100. * Internal only - executes current action event
  10101. * @hidden
  10102. */
  10103. _executeCurrent(evt?: ActionEvent): void;
  10104. /**
  10105. * Execute placeholder for child classes
  10106. * @param evt optional action event
  10107. */
  10108. execute(evt?: ActionEvent): void;
  10109. /**
  10110. * Skips to next active action
  10111. */
  10112. skipToNextActiveAction(): void;
  10113. /**
  10114. * Adds action to chain of actions, may be a DoNothingAction
  10115. * @param action defines the next action to execute
  10116. * @returns The action passed in
  10117. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10118. */
  10119. then(action: Action): Action;
  10120. /**
  10121. * Internal only
  10122. * @hidden
  10123. */
  10124. _getProperty(propertyPath: string): string;
  10125. /**
  10126. * Internal only
  10127. * @hidden
  10128. */
  10129. _getEffectiveTarget(target: any, propertyPath: string): any;
  10130. /**
  10131. * Serialize placeholder for child classes
  10132. * @param parent of child
  10133. * @returns the serialized object
  10134. */
  10135. serialize(parent: any): any;
  10136. /**
  10137. * Internal only called by serialize
  10138. * @hidden
  10139. */
  10140. protected _serialize(serializedAction: any, parent?: any): any;
  10141. /**
  10142. * Internal only
  10143. * @hidden
  10144. */
  10145. static _SerializeValueAsString: (value: any) => string;
  10146. /**
  10147. * Internal only
  10148. * @hidden
  10149. */
  10150. static _GetTargetProperty: (target: Scene | Node) => {
  10151. name: string;
  10152. targetType: string;
  10153. value: string;
  10154. };
  10155. }
  10156. }
  10157. declare module BABYLON {
  10158. /**
  10159. * A Condition applied to an Action
  10160. */
  10161. export class Condition {
  10162. /**
  10163. * Internal only - manager for action
  10164. * @hidden
  10165. */
  10166. _actionManager: ActionManager;
  10167. /**
  10168. * Internal only
  10169. * @hidden
  10170. */
  10171. _evaluationId: number;
  10172. /**
  10173. * Internal only
  10174. * @hidden
  10175. */
  10176. _currentResult: boolean;
  10177. /**
  10178. * Creates a new Condition
  10179. * @param actionManager the manager of the action the condition is applied to
  10180. */
  10181. constructor(actionManager: ActionManager);
  10182. /**
  10183. * Check if the current condition is valid
  10184. * @returns a boolean
  10185. */
  10186. isValid(): boolean;
  10187. /**
  10188. * Internal only
  10189. * @hidden
  10190. */
  10191. _getProperty(propertyPath: string): string;
  10192. /**
  10193. * Internal only
  10194. * @hidden
  10195. */
  10196. _getEffectiveTarget(target: any, propertyPath: string): any;
  10197. /**
  10198. * Serialize placeholder for child classes
  10199. * @returns the serialized object
  10200. */
  10201. serialize(): any;
  10202. /**
  10203. * Internal only
  10204. * @hidden
  10205. */
  10206. protected _serialize(serializedCondition: any): any;
  10207. }
  10208. /**
  10209. * Defines specific conditional operators as extensions of Condition
  10210. */
  10211. export class ValueCondition extends Condition {
  10212. /** path to specify the property of the target the conditional operator uses */
  10213. propertyPath: string;
  10214. /** the value compared by the conditional operator against the current value of the property */
  10215. value: any;
  10216. /** the conditional operator, default ValueCondition.IsEqual */
  10217. operator: number;
  10218. /**
  10219. * Internal only
  10220. * @hidden
  10221. */
  10222. private static _IsEqual;
  10223. /**
  10224. * Internal only
  10225. * @hidden
  10226. */
  10227. private static _IsDifferent;
  10228. /**
  10229. * Internal only
  10230. * @hidden
  10231. */
  10232. private static _IsGreater;
  10233. /**
  10234. * Internal only
  10235. * @hidden
  10236. */
  10237. private static _IsLesser;
  10238. /**
  10239. * returns the number for IsEqual
  10240. */
  10241. static get IsEqual(): number;
  10242. /**
  10243. * Returns the number for IsDifferent
  10244. */
  10245. static get IsDifferent(): number;
  10246. /**
  10247. * Returns the number for IsGreater
  10248. */
  10249. static get IsGreater(): number;
  10250. /**
  10251. * Returns the number for IsLesser
  10252. */
  10253. static get IsLesser(): number;
  10254. /**
  10255. * Internal only The action manager for the condition
  10256. * @hidden
  10257. */
  10258. _actionManager: ActionManager;
  10259. /**
  10260. * Internal only
  10261. * @hidden
  10262. */
  10263. private _target;
  10264. /**
  10265. * Internal only
  10266. * @hidden
  10267. */
  10268. private _effectiveTarget;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. private _property;
  10274. /**
  10275. * Creates a new ValueCondition
  10276. * @param actionManager manager for the action the condition applies to
  10277. * @param target for the action
  10278. * @param propertyPath path to specify the property of the target the conditional operator uses
  10279. * @param value the value compared by the conditional operator against the current value of the property
  10280. * @param operator the conditional operator, default ValueCondition.IsEqual
  10281. */
  10282. constructor(actionManager: ActionManager, target: any,
  10283. /** path to specify the property of the target the conditional operator uses */
  10284. propertyPath: string,
  10285. /** the value compared by the conditional operator against the current value of the property */
  10286. value: any,
  10287. /** the conditional operator, default ValueCondition.IsEqual */
  10288. operator?: number);
  10289. /**
  10290. * Compares the given value with the property value for the specified conditional operator
  10291. * @returns the result of the comparison
  10292. */
  10293. isValid(): boolean;
  10294. /**
  10295. * Serialize the ValueCondition into a JSON compatible object
  10296. * @returns serialization object
  10297. */
  10298. serialize(): any;
  10299. /**
  10300. * Gets the name of the conditional operator for the ValueCondition
  10301. * @param operator the conditional operator
  10302. * @returns the name
  10303. */
  10304. static GetOperatorName(operator: number): string;
  10305. }
  10306. /**
  10307. * Defines a predicate condition as an extension of Condition
  10308. */
  10309. export class PredicateCondition extends Condition {
  10310. /** defines the predicate function used to validate the condition */
  10311. predicate: () => boolean;
  10312. /**
  10313. * Internal only - manager for action
  10314. * @hidden
  10315. */
  10316. _actionManager: ActionManager;
  10317. /**
  10318. * Creates a new PredicateCondition
  10319. * @param actionManager manager for the action the condition applies to
  10320. * @param predicate defines the predicate function used to validate the condition
  10321. */
  10322. constructor(actionManager: ActionManager,
  10323. /** defines the predicate function used to validate the condition */
  10324. predicate: () => boolean);
  10325. /**
  10326. * @returns the validity of the predicate condition
  10327. */
  10328. isValid(): boolean;
  10329. }
  10330. /**
  10331. * Defines a state condition as an extension of Condition
  10332. */
  10333. export class StateCondition extends Condition {
  10334. /** Value to compare with target state */
  10335. value: string;
  10336. /**
  10337. * Internal only - manager for action
  10338. * @hidden
  10339. */
  10340. _actionManager: ActionManager;
  10341. /**
  10342. * Internal only
  10343. * @hidden
  10344. */
  10345. private _target;
  10346. /**
  10347. * Creates a new StateCondition
  10348. * @param actionManager manager for the action the condition applies to
  10349. * @param target of the condition
  10350. * @param value to compare with target state
  10351. */
  10352. constructor(actionManager: ActionManager, target: any,
  10353. /** Value to compare with target state */
  10354. value: string);
  10355. /**
  10356. * Gets a boolean indicating if the current condition is met
  10357. * @returns the validity of the state
  10358. */
  10359. isValid(): boolean;
  10360. /**
  10361. * Serialize the StateCondition into a JSON compatible object
  10362. * @returns serialization object
  10363. */
  10364. serialize(): any;
  10365. }
  10366. }
  10367. declare module BABYLON {
  10368. /**
  10369. * This defines an action responsible to toggle a boolean once triggered.
  10370. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10371. */
  10372. export class SwitchBooleanAction extends Action {
  10373. /**
  10374. * The path to the boolean property in the target object
  10375. */
  10376. propertyPath: string;
  10377. private _target;
  10378. private _effectiveTarget;
  10379. private _property;
  10380. /**
  10381. * Instantiate the action
  10382. * @param triggerOptions defines the trigger options
  10383. * @param target defines the object containing the boolean
  10384. * @param propertyPath defines the path to the boolean property in the target object
  10385. * @param condition defines the trigger related conditions
  10386. */
  10387. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10388. /** @hidden */
  10389. _prepare(): void;
  10390. /**
  10391. * Execute the action toggle the boolean value.
  10392. */
  10393. execute(): void;
  10394. /**
  10395. * Serializes the actions and its related information.
  10396. * @param parent defines the object to serialize in
  10397. * @returns the serialized object
  10398. */
  10399. serialize(parent: any): any;
  10400. }
  10401. /**
  10402. * This defines an action responsible to set a the state field of the target
  10403. * to a desired value once triggered.
  10404. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10405. */
  10406. export class SetStateAction extends Action {
  10407. /**
  10408. * The value to store in the state field.
  10409. */
  10410. value: string;
  10411. private _target;
  10412. /**
  10413. * Instantiate the action
  10414. * @param triggerOptions defines the trigger options
  10415. * @param target defines the object containing the state property
  10416. * @param value defines the value to store in the state field
  10417. * @param condition defines the trigger related conditions
  10418. */
  10419. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10420. /**
  10421. * Execute the action and store the value on the target state property.
  10422. */
  10423. execute(): void;
  10424. /**
  10425. * Serializes the actions and its related information.
  10426. * @param parent defines the object to serialize in
  10427. * @returns the serialized object
  10428. */
  10429. serialize(parent: any): any;
  10430. }
  10431. /**
  10432. * This defines an action responsible to set a property of the target
  10433. * to a desired value once triggered.
  10434. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10435. */
  10436. export class SetValueAction extends Action {
  10437. /**
  10438. * The path of the property to set in the target.
  10439. */
  10440. propertyPath: string;
  10441. /**
  10442. * The value to set in the property
  10443. */
  10444. value: any;
  10445. private _target;
  10446. private _effectiveTarget;
  10447. private _property;
  10448. /**
  10449. * Instantiate the action
  10450. * @param triggerOptions defines the trigger options
  10451. * @param target defines the object containing the property
  10452. * @param propertyPath defines the path of the property to set in the target
  10453. * @param value defines the value to set in the property
  10454. * @param condition defines the trigger related conditions
  10455. */
  10456. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10457. /** @hidden */
  10458. _prepare(): void;
  10459. /**
  10460. * Execute the action and set the targetted property to the desired value.
  10461. */
  10462. execute(): void;
  10463. /**
  10464. * Serializes the actions and its related information.
  10465. * @param parent defines the object to serialize in
  10466. * @returns the serialized object
  10467. */
  10468. serialize(parent: any): any;
  10469. }
  10470. /**
  10471. * This defines an action responsible to increment the target value
  10472. * to a desired value once triggered.
  10473. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10474. */
  10475. export class IncrementValueAction extends Action {
  10476. /**
  10477. * The path of the property to increment in the target.
  10478. */
  10479. propertyPath: string;
  10480. /**
  10481. * The value we should increment the property by.
  10482. */
  10483. value: any;
  10484. private _target;
  10485. private _effectiveTarget;
  10486. private _property;
  10487. /**
  10488. * Instantiate the action
  10489. * @param triggerOptions defines the trigger options
  10490. * @param target defines the object containing the property
  10491. * @param propertyPath defines the path of the property to increment in the target
  10492. * @param value defines the value value we should increment the property by
  10493. * @param condition defines the trigger related conditions
  10494. */
  10495. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10496. /** @hidden */
  10497. _prepare(): void;
  10498. /**
  10499. * Execute the action and increment the target of the value amount.
  10500. */
  10501. execute(): void;
  10502. /**
  10503. * Serializes the actions and its related information.
  10504. * @param parent defines the object to serialize in
  10505. * @returns the serialized object
  10506. */
  10507. serialize(parent: any): any;
  10508. }
  10509. /**
  10510. * This defines an action responsible to start an animation once triggered.
  10511. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10512. */
  10513. export class PlayAnimationAction extends Action {
  10514. /**
  10515. * Where the animation should start (animation frame)
  10516. */
  10517. from: number;
  10518. /**
  10519. * Where the animation should stop (animation frame)
  10520. */
  10521. to: number;
  10522. /**
  10523. * Define if the animation should loop or stop after the first play.
  10524. */
  10525. loop?: boolean;
  10526. private _target;
  10527. /**
  10528. * Instantiate the action
  10529. * @param triggerOptions defines the trigger options
  10530. * @param target defines the target animation or animation name
  10531. * @param from defines from where the animation should start (animation frame)
  10532. * @param end defines where the animation should stop (animation frame)
  10533. * @param loop defines if the animation should loop or stop after the first play
  10534. * @param condition defines the trigger related conditions
  10535. */
  10536. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10537. /** @hidden */
  10538. _prepare(): void;
  10539. /**
  10540. * Execute the action and play the animation.
  10541. */
  10542. execute(): void;
  10543. /**
  10544. * Serializes the actions and its related information.
  10545. * @param parent defines the object to serialize in
  10546. * @returns the serialized object
  10547. */
  10548. serialize(parent: any): any;
  10549. }
  10550. /**
  10551. * This defines an action responsible to stop an animation once triggered.
  10552. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10553. */
  10554. export class StopAnimationAction extends Action {
  10555. private _target;
  10556. /**
  10557. * Instantiate the action
  10558. * @param triggerOptions defines the trigger options
  10559. * @param target defines the target animation or animation name
  10560. * @param condition defines the trigger related conditions
  10561. */
  10562. constructor(triggerOptions: any, target: any, condition?: Condition);
  10563. /** @hidden */
  10564. _prepare(): void;
  10565. /**
  10566. * Execute the action and stop the animation.
  10567. */
  10568. execute(): void;
  10569. /**
  10570. * Serializes the actions and its related information.
  10571. * @param parent defines the object to serialize in
  10572. * @returns the serialized object
  10573. */
  10574. serialize(parent: any): any;
  10575. }
  10576. /**
  10577. * This defines an action responsible that does nothing once triggered.
  10578. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class DoNothingAction extends Action {
  10581. /**
  10582. * Instantiate the action
  10583. * @param triggerOptions defines the trigger options
  10584. * @param condition defines the trigger related conditions
  10585. */
  10586. constructor(triggerOptions?: any, condition?: Condition);
  10587. /**
  10588. * Execute the action and do nothing.
  10589. */
  10590. execute(): void;
  10591. /**
  10592. * Serializes the actions and its related information.
  10593. * @param parent defines the object to serialize in
  10594. * @returns the serialized object
  10595. */
  10596. serialize(parent: any): any;
  10597. }
  10598. /**
  10599. * This defines an action responsible to trigger several actions once triggered.
  10600. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10601. */
  10602. export class CombineAction extends Action {
  10603. /**
  10604. * The list of aggregated animations to run.
  10605. */
  10606. children: Action[];
  10607. /**
  10608. * Instantiate the action
  10609. * @param triggerOptions defines the trigger options
  10610. * @param children defines the list of aggregated animations to run
  10611. * @param condition defines the trigger related conditions
  10612. */
  10613. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10614. /** @hidden */
  10615. _prepare(): void;
  10616. /**
  10617. * Execute the action and executes all the aggregated actions.
  10618. */
  10619. execute(evt: ActionEvent): void;
  10620. /**
  10621. * Serializes the actions and its related information.
  10622. * @param parent defines the object to serialize in
  10623. * @returns the serialized object
  10624. */
  10625. serialize(parent: any): any;
  10626. }
  10627. /**
  10628. * This defines an action responsible to run code (external event) once triggered.
  10629. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10630. */
  10631. export class ExecuteCodeAction extends Action {
  10632. /**
  10633. * The callback function to run.
  10634. */
  10635. func: (evt: ActionEvent) => void;
  10636. /**
  10637. * Instantiate the action
  10638. * @param triggerOptions defines the trigger options
  10639. * @param func defines the callback function to run
  10640. * @param condition defines the trigger related conditions
  10641. */
  10642. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10643. /**
  10644. * Execute the action and run the attached code.
  10645. */
  10646. execute(evt: ActionEvent): void;
  10647. }
  10648. /**
  10649. * This defines an action responsible to set the parent property of the target once triggered.
  10650. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10651. */
  10652. export class SetParentAction extends Action {
  10653. private _parent;
  10654. private _target;
  10655. /**
  10656. * Instantiate the action
  10657. * @param triggerOptions defines the trigger options
  10658. * @param target defines the target containing the parent property
  10659. * @param parent defines from where the animation should start (animation frame)
  10660. * @param condition defines the trigger related conditions
  10661. */
  10662. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10663. /** @hidden */
  10664. _prepare(): void;
  10665. /**
  10666. * Execute the action and set the parent property.
  10667. */
  10668. execute(): void;
  10669. /**
  10670. * Serializes the actions and its related information.
  10671. * @param parent defines the object to serialize in
  10672. * @returns the serialized object
  10673. */
  10674. serialize(parent: any): any;
  10675. }
  10676. }
  10677. declare module BABYLON {
  10678. /**
  10679. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10680. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10681. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10682. */
  10683. export class ActionManager extends AbstractActionManager {
  10684. /**
  10685. * Nothing
  10686. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10687. */
  10688. static readonly NothingTrigger: number;
  10689. /**
  10690. * On pick
  10691. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10692. */
  10693. static readonly OnPickTrigger: number;
  10694. /**
  10695. * On left pick
  10696. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10697. */
  10698. static readonly OnLeftPickTrigger: number;
  10699. /**
  10700. * On right pick
  10701. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10702. */
  10703. static readonly OnRightPickTrigger: number;
  10704. /**
  10705. * On center pick
  10706. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10707. */
  10708. static readonly OnCenterPickTrigger: number;
  10709. /**
  10710. * On pick down
  10711. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10712. */
  10713. static readonly OnPickDownTrigger: number;
  10714. /**
  10715. * On double pick
  10716. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10717. */
  10718. static readonly OnDoublePickTrigger: number;
  10719. /**
  10720. * On pick up
  10721. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10722. */
  10723. static readonly OnPickUpTrigger: number;
  10724. /**
  10725. * On pick out.
  10726. * This trigger will only be raised if you also declared a OnPickDown
  10727. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10728. */
  10729. static readonly OnPickOutTrigger: number;
  10730. /**
  10731. * On long press
  10732. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10733. */
  10734. static readonly OnLongPressTrigger: number;
  10735. /**
  10736. * On pointer over
  10737. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10738. */
  10739. static readonly OnPointerOverTrigger: number;
  10740. /**
  10741. * On pointer out
  10742. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10743. */
  10744. static readonly OnPointerOutTrigger: number;
  10745. /**
  10746. * On every frame
  10747. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10748. */
  10749. static readonly OnEveryFrameTrigger: number;
  10750. /**
  10751. * On intersection enter
  10752. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10753. */
  10754. static readonly OnIntersectionEnterTrigger: number;
  10755. /**
  10756. * On intersection exit
  10757. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10758. */
  10759. static readonly OnIntersectionExitTrigger: number;
  10760. /**
  10761. * On key down
  10762. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10763. */
  10764. static readonly OnKeyDownTrigger: number;
  10765. /**
  10766. * On key up
  10767. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10768. */
  10769. static readonly OnKeyUpTrigger: number;
  10770. private _scene;
  10771. /**
  10772. * Creates a new action manager
  10773. * @param scene defines the hosting scene
  10774. */
  10775. constructor(scene: Scene);
  10776. /**
  10777. * Releases all associated resources
  10778. */
  10779. dispose(): void;
  10780. /**
  10781. * Gets hosting scene
  10782. * @returns the hosting scene
  10783. */
  10784. getScene(): Scene;
  10785. /**
  10786. * Does this action manager handles actions of any of the given triggers
  10787. * @param triggers defines the triggers to be tested
  10788. * @return a boolean indicating whether one (or more) of the triggers is handled
  10789. */
  10790. hasSpecificTriggers(triggers: number[]): boolean;
  10791. /**
  10792. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10793. * speed.
  10794. * @param triggerA defines the trigger to be tested
  10795. * @param triggerB defines the trigger to be tested
  10796. * @return a boolean indicating whether one (or more) of the triggers is handled
  10797. */
  10798. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10799. /**
  10800. * Does this action manager handles actions of a given trigger
  10801. * @param trigger defines the trigger to be tested
  10802. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10803. * @return whether the trigger is handled
  10804. */
  10805. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10806. /**
  10807. * Does this action manager has pointer triggers
  10808. */
  10809. get hasPointerTriggers(): boolean;
  10810. /**
  10811. * Does this action manager has pick triggers
  10812. */
  10813. get hasPickTriggers(): boolean;
  10814. /**
  10815. * Registers an action to this action manager
  10816. * @param action defines the action to be registered
  10817. * @return the action amended (prepared) after registration
  10818. */
  10819. registerAction(action: IAction): Nullable<IAction>;
  10820. /**
  10821. * Unregisters an action to this action manager
  10822. * @param action defines the action to be unregistered
  10823. * @return a boolean indicating whether the action has been unregistered
  10824. */
  10825. unregisterAction(action: IAction): Boolean;
  10826. /**
  10827. * Process a specific trigger
  10828. * @param trigger defines the trigger to process
  10829. * @param evt defines the event details to be processed
  10830. */
  10831. processTrigger(trigger: number, evt?: IActionEvent): void;
  10832. /** @hidden */
  10833. _getEffectiveTarget(target: any, propertyPath: string): any;
  10834. /** @hidden */
  10835. _getProperty(propertyPath: string): string;
  10836. /**
  10837. * Serialize this manager to a JSON object
  10838. * @param name defines the property name to store this manager
  10839. * @returns a JSON representation of this manager
  10840. */
  10841. serialize(name: string): any;
  10842. /**
  10843. * Creates a new ActionManager from a JSON data
  10844. * @param parsedActions defines the JSON data to read from
  10845. * @param object defines the hosting mesh
  10846. * @param scene defines the hosting scene
  10847. */
  10848. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10849. /**
  10850. * Get a trigger name by index
  10851. * @param trigger defines the trigger index
  10852. * @returns a trigger name
  10853. */
  10854. static GetTriggerName(trigger: number): string;
  10855. }
  10856. }
  10857. declare module BABYLON {
  10858. /**
  10859. * Class representing a ray with position and direction
  10860. */
  10861. export class Ray {
  10862. /** origin point */
  10863. origin: Vector3;
  10864. /** direction */
  10865. direction: Vector3;
  10866. /** length of the ray */
  10867. length: number;
  10868. private static readonly _TmpVector3;
  10869. private _tmpRay;
  10870. /**
  10871. * Creates a new ray
  10872. * @param origin origin point
  10873. * @param direction direction
  10874. * @param length length of the ray
  10875. */
  10876. constructor(
  10877. /** origin point */
  10878. origin: Vector3,
  10879. /** direction */
  10880. direction: Vector3,
  10881. /** length of the ray */
  10882. length?: number);
  10883. /**
  10884. * Checks if the ray intersects a box
  10885. * This does not account for the ray lenght by design to improve perfs.
  10886. * @param minimum bound of the box
  10887. * @param maximum bound of the box
  10888. * @param intersectionTreshold extra extend to be added to the box in all direction
  10889. * @returns if the box was hit
  10890. */
  10891. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10892. /**
  10893. * Checks if the ray intersects a box
  10894. * This does not account for the ray lenght by design to improve perfs.
  10895. * @param box the bounding box to check
  10896. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10897. * @returns if the box was hit
  10898. */
  10899. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10900. /**
  10901. * If the ray hits a sphere
  10902. * @param sphere the bounding sphere to check
  10903. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10904. * @returns true if it hits the sphere
  10905. */
  10906. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10907. /**
  10908. * If the ray hits a triange
  10909. * @param vertex0 triangle vertex
  10910. * @param vertex1 triangle vertex
  10911. * @param vertex2 triangle vertex
  10912. * @returns intersection information if hit
  10913. */
  10914. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10915. /**
  10916. * Checks if ray intersects a plane
  10917. * @param plane the plane to check
  10918. * @returns the distance away it was hit
  10919. */
  10920. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10921. /**
  10922. * Calculate the intercept of a ray on a given axis
  10923. * @param axis to check 'x' | 'y' | 'z'
  10924. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10925. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10926. */
  10927. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10928. /**
  10929. * Checks if ray intersects a mesh
  10930. * @param mesh the mesh to check
  10931. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10932. * @returns picking info of the intersecton
  10933. */
  10934. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10935. /**
  10936. * Checks if ray intersects a mesh
  10937. * @param meshes the meshes to check
  10938. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10939. * @param results array to store result in
  10940. * @returns Array of picking infos
  10941. */
  10942. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10943. private _comparePickingInfo;
  10944. private static smallnum;
  10945. private static rayl;
  10946. /**
  10947. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10948. * @param sega the first point of the segment to test the intersection against
  10949. * @param segb the second point of the segment to test the intersection against
  10950. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10951. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10952. */
  10953. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10954. /**
  10955. * Update the ray from viewport position
  10956. * @param x position
  10957. * @param y y position
  10958. * @param viewportWidth viewport width
  10959. * @param viewportHeight viewport height
  10960. * @param world world matrix
  10961. * @param view view matrix
  10962. * @param projection projection matrix
  10963. * @returns this ray updated
  10964. */
  10965. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10966. /**
  10967. * Creates a ray with origin and direction of 0,0,0
  10968. * @returns the new ray
  10969. */
  10970. static Zero(): Ray;
  10971. /**
  10972. * Creates a new ray from screen space and viewport
  10973. * @param x position
  10974. * @param y y position
  10975. * @param viewportWidth viewport width
  10976. * @param viewportHeight viewport height
  10977. * @param world world matrix
  10978. * @param view view matrix
  10979. * @param projection projection matrix
  10980. * @returns new ray
  10981. */
  10982. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10983. /**
  10984. * 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
  10985. * transformed to the given world matrix.
  10986. * @param origin The origin point
  10987. * @param end The end point
  10988. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10989. * @returns the new ray
  10990. */
  10991. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10992. /**
  10993. * Transforms a ray by a matrix
  10994. * @param ray ray to transform
  10995. * @param matrix matrix to apply
  10996. * @returns the resulting new ray
  10997. */
  10998. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10999. /**
  11000. * Transforms a ray by a matrix
  11001. * @param ray ray to transform
  11002. * @param matrix matrix to apply
  11003. * @param result ray to store result in
  11004. */
  11005. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11006. /**
  11007. * Unproject a ray from screen space to object space
  11008. * @param sourceX defines the screen space x coordinate to use
  11009. * @param sourceY defines the screen space y coordinate to use
  11010. * @param viewportWidth defines the current width of the viewport
  11011. * @param viewportHeight defines the current height of the viewport
  11012. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11013. * @param view defines the view matrix to use
  11014. * @param projection defines the projection matrix to use
  11015. */
  11016. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11017. }
  11018. /**
  11019. * Type used to define predicate used to select faces when a mesh intersection is detected
  11020. */
  11021. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11022. interface Scene {
  11023. /** @hidden */
  11024. _tempPickingRay: Nullable<Ray>;
  11025. /** @hidden */
  11026. _cachedRayForTransform: Ray;
  11027. /** @hidden */
  11028. _pickWithRayInverseMatrix: Matrix;
  11029. /** @hidden */
  11030. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11031. /** @hidden */
  11032. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11033. /** @hidden */
  11034. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11035. }
  11036. }
  11037. declare module BABYLON {
  11038. /**
  11039. * Groups all the scene component constants in one place to ease maintenance.
  11040. * @hidden
  11041. */
  11042. export class SceneComponentConstants {
  11043. static readonly NAME_EFFECTLAYER: string;
  11044. static readonly NAME_LAYER: string;
  11045. static readonly NAME_LENSFLARESYSTEM: string;
  11046. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11047. static readonly NAME_PARTICLESYSTEM: string;
  11048. static readonly NAME_GAMEPAD: string;
  11049. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11050. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11051. static readonly NAME_PREPASSRENDERER: string;
  11052. static readonly NAME_DEPTHRENDERER: string;
  11053. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11054. static readonly NAME_SPRITE: string;
  11055. static readonly NAME_SUBSURFACE: string;
  11056. static readonly NAME_OUTLINERENDERER: string;
  11057. static readonly NAME_PROCEDURALTEXTURE: string;
  11058. static readonly NAME_SHADOWGENERATOR: string;
  11059. static readonly NAME_OCTREE: string;
  11060. static readonly NAME_PHYSICSENGINE: string;
  11061. static readonly NAME_AUDIO: string;
  11062. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11063. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11064. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11065. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11066. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11067. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11068. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11069. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11070. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11071. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11072. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11073. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11074. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11075. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11076. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11077. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11078. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11079. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11080. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11081. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11082. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11083. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11084. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11085. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11086. static readonly STEP_AFTERRENDER_AUDIO: number;
  11087. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11088. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11089. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11090. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11091. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11092. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11093. static readonly STEP_POINTERMOVE_SPRITE: number;
  11094. static readonly STEP_POINTERDOWN_SPRITE: number;
  11095. static readonly STEP_POINTERUP_SPRITE: number;
  11096. }
  11097. /**
  11098. * This represents a scene component.
  11099. *
  11100. * This is used to decouple the dependency the scene is having on the different workloads like
  11101. * layers, post processes...
  11102. */
  11103. export interface ISceneComponent {
  11104. /**
  11105. * The name of the component. Each component must have a unique name.
  11106. */
  11107. name: string;
  11108. /**
  11109. * The scene the component belongs to.
  11110. */
  11111. scene: Scene;
  11112. /**
  11113. * Register the component to one instance of a scene.
  11114. */
  11115. register(): void;
  11116. /**
  11117. * Rebuilds the elements related to this component in case of
  11118. * context lost for instance.
  11119. */
  11120. rebuild(): void;
  11121. /**
  11122. * Disposes the component and the associated ressources.
  11123. */
  11124. dispose(): void;
  11125. }
  11126. /**
  11127. * This represents a SERIALIZABLE scene component.
  11128. *
  11129. * This extends Scene Component to add Serialization methods on top.
  11130. */
  11131. export interface ISceneSerializableComponent extends ISceneComponent {
  11132. /**
  11133. * Adds all the elements from the container to the scene
  11134. * @param container the container holding the elements
  11135. */
  11136. addFromContainer(container: AbstractScene): void;
  11137. /**
  11138. * Removes all the elements in the container from the scene
  11139. * @param container contains the elements to remove
  11140. * @param dispose if the removed element should be disposed (default: false)
  11141. */
  11142. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11143. /**
  11144. * Serializes the component data to the specified json object
  11145. * @param serializationObject The object to serialize to
  11146. */
  11147. serialize(serializationObject: any): void;
  11148. }
  11149. /**
  11150. * Strong typing of a Mesh related stage step action
  11151. */
  11152. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11153. /**
  11154. * Strong typing of a Evaluate Sub Mesh related stage step action
  11155. */
  11156. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11157. /**
  11158. * Strong typing of a pre active Mesh related stage step action
  11159. */
  11160. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11161. /**
  11162. * Strong typing of a Camera related stage step action
  11163. */
  11164. export type CameraStageAction = (camera: Camera) => void;
  11165. /**
  11166. * Strong typing of a Camera Frame buffer related stage step action
  11167. */
  11168. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11169. /**
  11170. * Strong typing of a Render Target related stage step action
  11171. */
  11172. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11173. /**
  11174. * Strong typing of a RenderingGroup related stage step action
  11175. */
  11176. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11177. /**
  11178. * Strong typing of a Mesh Render related stage step action
  11179. */
  11180. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11181. /**
  11182. * Strong typing of a simple stage step action
  11183. */
  11184. export type SimpleStageAction = () => void;
  11185. /**
  11186. * Strong typing of a render target action.
  11187. */
  11188. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11189. /**
  11190. * Strong typing of a pointer move action.
  11191. */
  11192. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11193. /**
  11194. * Strong typing of a pointer up/down action.
  11195. */
  11196. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11197. /**
  11198. * Representation of a stage in the scene (Basically a list of ordered steps)
  11199. * @hidden
  11200. */
  11201. export class Stage<T extends Function> extends Array<{
  11202. index: number;
  11203. component: ISceneComponent;
  11204. action: T;
  11205. }> {
  11206. /**
  11207. * Hide ctor from the rest of the world.
  11208. * @param items The items to add.
  11209. */
  11210. private constructor();
  11211. /**
  11212. * Creates a new Stage.
  11213. * @returns A new instance of a Stage
  11214. */
  11215. static Create<T extends Function>(): Stage<T>;
  11216. /**
  11217. * Registers a step in an ordered way in the targeted stage.
  11218. * @param index Defines the position to register the step in
  11219. * @param component Defines the component attached to the step
  11220. * @param action Defines the action to launch during the step
  11221. */
  11222. registerStep(index: number, component: ISceneComponent, action: T): void;
  11223. /**
  11224. * Clears all the steps from the stage.
  11225. */
  11226. clear(): void;
  11227. }
  11228. }
  11229. declare module BABYLON {
  11230. interface Scene {
  11231. /** @hidden */
  11232. _pointerOverSprite: Nullable<Sprite>;
  11233. /** @hidden */
  11234. _pickedDownSprite: Nullable<Sprite>;
  11235. /** @hidden */
  11236. _tempSpritePickingRay: Nullable<Ray>;
  11237. /**
  11238. * All of the sprite managers added to this scene
  11239. * @see https://doc.babylonjs.com/babylon101/sprites
  11240. */
  11241. spriteManagers: Array<ISpriteManager>;
  11242. /**
  11243. * An event triggered when sprites rendering is about to start
  11244. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11245. */
  11246. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11247. /**
  11248. * An event triggered when sprites rendering is done
  11249. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11250. */
  11251. onAfterSpritesRenderingObservable: Observable<Scene>;
  11252. /** @hidden */
  11253. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11254. /** Launch a ray to try to pick a sprite in the scene
  11255. * @param x position on screen
  11256. * @param y position on screen
  11257. * @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
  11258. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11259. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11260. * @returns a PickingInfo
  11261. */
  11262. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11263. /** Use the given ray to pick a sprite in the scene
  11264. * @param ray The ray (in world space) to use to pick meshes
  11265. * @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
  11266. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11267. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11268. * @returns a PickingInfo
  11269. */
  11270. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11271. /** @hidden */
  11272. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11273. /** Launch a ray to try to pick sprites in the scene
  11274. * @param x position on screen
  11275. * @param y position on screen
  11276. * @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
  11277. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11278. * @returns a PickingInfo array
  11279. */
  11280. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11281. /** Use the given ray to pick sprites in the scene
  11282. * @param ray The ray (in world space) to use to pick meshes
  11283. * @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
  11284. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11285. * @returns a PickingInfo array
  11286. */
  11287. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11288. /**
  11289. * Force the sprite under the pointer
  11290. * @param sprite defines the sprite to use
  11291. */
  11292. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11293. /**
  11294. * Gets the sprite under the pointer
  11295. * @returns a Sprite or null if no sprite is under the pointer
  11296. */
  11297. getPointerOverSprite(): Nullable<Sprite>;
  11298. }
  11299. /**
  11300. * Defines the sprite scene component responsible to manage sprites
  11301. * in a given scene.
  11302. */
  11303. export class SpriteSceneComponent implements ISceneComponent {
  11304. /**
  11305. * The component name helpfull to identify the component in the list of scene components.
  11306. */
  11307. readonly name: string;
  11308. /**
  11309. * The scene the component belongs to.
  11310. */
  11311. scene: Scene;
  11312. /** @hidden */
  11313. private _spritePredicate;
  11314. /**
  11315. * Creates a new instance of the component for the given scene
  11316. * @param scene Defines the scene to register the component in
  11317. */
  11318. constructor(scene: Scene);
  11319. /**
  11320. * Registers the component in a given scene
  11321. */
  11322. register(): void;
  11323. /**
  11324. * Rebuilds the elements related to this component in case of
  11325. * context lost for instance.
  11326. */
  11327. rebuild(): void;
  11328. /**
  11329. * Disposes the component and the associated ressources.
  11330. */
  11331. dispose(): void;
  11332. private _pickSpriteButKeepRay;
  11333. private _pointerMove;
  11334. private _pointerDown;
  11335. private _pointerUp;
  11336. }
  11337. }
  11338. declare module BABYLON {
  11339. /**
  11340. * Class used to provide helper for timing
  11341. */
  11342. export class TimingTools {
  11343. /**
  11344. * Polyfill for setImmediate
  11345. * @param action defines the action to execute after the current execution block
  11346. */
  11347. static SetImmediate(action: () => void): void;
  11348. }
  11349. }
  11350. declare module BABYLON {
  11351. /**
  11352. * Class used to enable instatition of objects by class name
  11353. */
  11354. export class InstantiationTools {
  11355. /**
  11356. * Use this object to register external classes like custom textures or material
  11357. * to allow the laoders to instantiate them
  11358. */
  11359. static RegisteredExternalClasses: {
  11360. [key: string]: Object;
  11361. };
  11362. /**
  11363. * Tries to instantiate a new object from a given class name
  11364. * @param className defines the class name to instantiate
  11365. * @returns the new object or null if the system was not able to do the instantiation
  11366. */
  11367. static Instantiate(className: string): any;
  11368. }
  11369. }
  11370. declare module BABYLON {
  11371. /**
  11372. * Class used to host copy specific utilities
  11373. */
  11374. export class CopyTools {
  11375. /**
  11376. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11377. * @param texture defines the texture to read pixels from
  11378. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11379. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11380. * @returns The base64 encoded string or null
  11381. */
  11382. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11383. }
  11384. }
  11385. declare module BABYLON {
  11386. /**
  11387. * Define options used to create a depth texture
  11388. */
  11389. export class DepthTextureCreationOptions {
  11390. /** Specifies whether or not a stencil should be allocated in the texture */
  11391. generateStencil?: boolean;
  11392. /** Specifies whether or not bilinear filtering is enable on the texture */
  11393. bilinearFiltering?: boolean;
  11394. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11395. comparisonFunction?: number;
  11396. /** Specifies if the created texture is a cube texture */
  11397. isCube?: boolean;
  11398. /** Specifies the sample count of the depth/stencil texture texture */
  11399. samples?: number;
  11400. }
  11401. }
  11402. declare module BABYLON {
  11403. interface ThinEngine {
  11404. /**
  11405. * Creates a depth stencil cube texture.
  11406. * This is only available in WebGL 2.
  11407. * @param size The size of face edge in the cube texture.
  11408. * @param options The options defining the cube texture.
  11409. * @returns The cube texture
  11410. */
  11411. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11412. /**
  11413. * Creates a cube texture
  11414. * @param rootUrl defines the url where the files to load is located
  11415. * @param scene defines the current scene
  11416. * @param files defines the list of files to load (1 per face)
  11417. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11418. * @param onLoad defines an optional callback raised when the texture is loaded
  11419. * @param onError defines an optional callback raised if there is an issue to load the texture
  11420. * @param format defines the format of the data
  11421. * @param forcedExtension defines the extension to use to pick the right loader
  11422. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11423. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11424. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11425. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11426. * @param loaderOptions options to be passed to the loader
  11427. * @returns the cube texture as an InternalTexture
  11428. */
  11429. 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;
  11430. /**
  11431. * Creates a cube texture
  11432. * @param rootUrl defines the url where the files to load is located
  11433. * @param scene defines the current scene
  11434. * @param files defines the list of files to load (1 per face)
  11435. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11436. * @param onLoad defines an optional callback raised when the texture is loaded
  11437. * @param onError defines an optional callback raised if there is an issue to load the texture
  11438. * @param format defines the format of the data
  11439. * @param forcedExtension defines the extension to use to pick the right loader
  11440. * @returns the cube texture as an InternalTexture
  11441. */
  11442. 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;
  11443. /**
  11444. * Creates a cube texture
  11445. * @param rootUrl defines the url where the files to load is located
  11446. * @param scene defines the current scene
  11447. * @param files defines the list of files to load (1 per face)
  11448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11449. * @param onLoad defines an optional callback raised when the texture is loaded
  11450. * @param onError defines an optional callback raised if there is an issue to load the texture
  11451. * @param format defines the format of the data
  11452. * @param forcedExtension defines the extension to use to pick the right loader
  11453. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11454. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11455. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11456. * @returns the cube texture as an InternalTexture
  11457. */
  11458. 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;
  11459. /** @hidden */
  11460. 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;
  11461. /** @hidden */
  11462. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11463. /** @hidden */
  11464. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11465. /** @hidden */
  11466. _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;
  11467. /** @hidden */
  11468. _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;
  11469. /**
  11470. * @hidden
  11471. */
  11472. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11473. }
  11474. }
  11475. declare module BABYLON {
  11476. /**
  11477. * Class for creating a cube texture
  11478. */
  11479. export class CubeTexture extends BaseTexture {
  11480. private _delayedOnLoad;
  11481. /**
  11482. * Observable triggered once the texture has been loaded.
  11483. */
  11484. onLoadObservable: Observable<CubeTexture>;
  11485. /**
  11486. * The url of the texture
  11487. */
  11488. url: string;
  11489. /**
  11490. * Gets or sets the center of the bounding box associated with the cube texture.
  11491. * It must define where the camera used to render the texture was set
  11492. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11493. */
  11494. boundingBoxPosition: Vector3;
  11495. private _boundingBoxSize;
  11496. /**
  11497. * Gets or sets the size of the bounding box associated with the cube texture
  11498. * When defined, the cubemap will switch to local mode
  11499. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11500. * @example https://www.babylonjs-playground.com/#RNASML
  11501. */
  11502. set boundingBoxSize(value: Vector3);
  11503. /**
  11504. * Returns the bounding box size
  11505. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11506. */
  11507. get boundingBoxSize(): Vector3;
  11508. protected _rotationY: number;
  11509. /**
  11510. * Sets texture matrix rotation angle around Y axis in radians.
  11511. */
  11512. set rotationY(value: number);
  11513. /**
  11514. * Gets texture matrix rotation angle around Y axis radians.
  11515. */
  11516. get rotationY(): number;
  11517. /**
  11518. * Are mip maps generated for this texture or not.
  11519. */
  11520. get noMipmap(): boolean;
  11521. private _noMipmap;
  11522. private _files;
  11523. protected _forcedExtension: Nullable<string>;
  11524. private _extensions;
  11525. private _textureMatrix;
  11526. private _format;
  11527. private _createPolynomials;
  11528. private _loaderOptions;
  11529. /**
  11530. * Creates a cube texture from an array of image urls
  11531. * @param files defines an array of image urls
  11532. * @param scene defines the hosting scene
  11533. * @param noMipmap specifies if mip maps are not used
  11534. * @returns a cube texture
  11535. */
  11536. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11537. /**
  11538. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11539. * @param url defines the url of the prefiltered texture
  11540. * @param scene defines the scene the texture is attached to
  11541. * @param forcedExtension defines the extension of the file if different from the url
  11542. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11543. * @return the prefiltered texture
  11544. */
  11545. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11546. /**
  11547. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11548. * as prefiltered data.
  11549. * @param rootUrl defines the url of the texture or the root name of the six images
  11550. * @param null defines the scene or engine the texture is attached to
  11551. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11552. * @param noMipmap defines if mipmaps should be created or not
  11553. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11554. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11555. * @param onError defines a callback triggered in case of error during load
  11556. * @param format defines the internal format to use for the texture once loaded
  11557. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11558. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11559. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11560. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11561. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11562. * @param loaderOptions options to be passed to the loader
  11563. * @return the cube texture
  11564. */
  11565. 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);
  11566. /**
  11567. * Get the current class name of the texture useful for serialization or dynamic coding.
  11568. * @returns "CubeTexture"
  11569. */
  11570. getClassName(): string;
  11571. /**
  11572. * Update the url (and optional buffer) of this texture if url was null during construction.
  11573. * @param url the url of the texture
  11574. * @param forcedExtension defines the extension to use
  11575. * @param onLoad callback called when the texture is loaded (defaults to null)
  11576. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11577. */
  11578. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11579. /**
  11580. * Delays loading of the cube texture
  11581. * @param forcedExtension defines the extension to use
  11582. */
  11583. delayLoad(forcedExtension?: string): void;
  11584. /**
  11585. * Returns the reflection texture matrix
  11586. * @returns the reflection texture matrix
  11587. */
  11588. getReflectionTextureMatrix(): Matrix;
  11589. /**
  11590. * Sets the reflection texture matrix
  11591. * @param value Reflection texture matrix
  11592. */
  11593. setReflectionTextureMatrix(value: Matrix): void;
  11594. /**
  11595. * Parses text to create a cube texture
  11596. * @param parsedTexture define the serialized text to read from
  11597. * @param scene defines the hosting scene
  11598. * @param rootUrl defines the root url of the cube texture
  11599. * @returns a cube texture
  11600. */
  11601. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11602. /**
  11603. * Makes a clone, or deep copy, of the cube texture
  11604. * @returns a new cube texture
  11605. */
  11606. clone(): CubeTexture;
  11607. }
  11608. }
  11609. declare module BABYLON {
  11610. /**
  11611. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11612. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11613. * 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;
  11614. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11615. */
  11616. export class ColorCurves {
  11617. private _dirty;
  11618. private _tempColor;
  11619. private _globalCurve;
  11620. private _highlightsCurve;
  11621. private _midtonesCurve;
  11622. private _shadowsCurve;
  11623. private _positiveCurve;
  11624. private _negativeCurve;
  11625. private _globalHue;
  11626. private _globalDensity;
  11627. private _globalSaturation;
  11628. private _globalExposure;
  11629. /**
  11630. * Gets the global Hue value.
  11631. * 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).
  11632. */
  11633. get globalHue(): number;
  11634. /**
  11635. * Sets the global Hue value.
  11636. * 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).
  11637. */
  11638. set globalHue(value: number);
  11639. /**
  11640. * Gets the global Density value.
  11641. * 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.
  11642. * Values less than zero provide a filter of opposite hue.
  11643. */
  11644. get globalDensity(): number;
  11645. /**
  11646. * Sets the global Density value.
  11647. * 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.
  11648. * Values less than zero provide a filter of opposite hue.
  11649. */
  11650. set globalDensity(value: number);
  11651. /**
  11652. * Gets the global Saturation value.
  11653. * 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.
  11654. */
  11655. get globalSaturation(): number;
  11656. /**
  11657. * Sets the global Saturation value.
  11658. * 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.
  11659. */
  11660. set globalSaturation(value: number);
  11661. /**
  11662. * Gets the global Exposure value.
  11663. * 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.
  11664. */
  11665. get globalExposure(): number;
  11666. /**
  11667. * Sets the global Exposure value.
  11668. * 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.
  11669. */
  11670. set globalExposure(value: number);
  11671. private _highlightsHue;
  11672. private _highlightsDensity;
  11673. private _highlightsSaturation;
  11674. private _highlightsExposure;
  11675. /**
  11676. * Gets the highlights Hue value.
  11677. * 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).
  11678. */
  11679. get highlightsHue(): number;
  11680. /**
  11681. * Sets the highlights Hue value.
  11682. * 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).
  11683. */
  11684. set highlightsHue(value: number);
  11685. /**
  11686. * Gets the highlights Density value.
  11687. * 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.
  11688. * Values less than zero provide a filter of opposite hue.
  11689. */
  11690. get highlightsDensity(): number;
  11691. /**
  11692. * Sets the highlights Density value.
  11693. * 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.
  11694. * Values less than zero provide a filter of opposite hue.
  11695. */
  11696. set highlightsDensity(value: number);
  11697. /**
  11698. * Gets the highlights Saturation value.
  11699. * 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.
  11700. */
  11701. get highlightsSaturation(): number;
  11702. /**
  11703. * Sets the highlights Saturation value.
  11704. * 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.
  11705. */
  11706. set highlightsSaturation(value: number);
  11707. /**
  11708. * Gets the highlights Exposure value.
  11709. * 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.
  11710. */
  11711. get highlightsExposure(): number;
  11712. /**
  11713. * Sets the highlights Exposure value.
  11714. * 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.
  11715. */
  11716. set highlightsExposure(value: number);
  11717. private _midtonesHue;
  11718. private _midtonesDensity;
  11719. private _midtonesSaturation;
  11720. private _midtonesExposure;
  11721. /**
  11722. * Gets the midtones Hue value.
  11723. * 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).
  11724. */
  11725. get midtonesHue(): number;
  11726. /**
  11727. * Sets the midtones Hue value.
  11728. * 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).
  11729. */
  11730. set midtonesHue(value: number);
  11731. /**
  11732. * Gets the midtones Density value.
  11733. * 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.
  11734. * Values less than zero provide a filter of opposite hue.
  11735. */
  11736. get midtonesDensity(): number;
  11737. /**
  11738. * Sets the midtones Density value.
  11739. * 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.
  11740. * Values less than zero provide a filter of opposite hue.
  11741. */
  11742. set midtonesDensity(value: number);
  11743. /**
  11744. * Gets the midtones Saturation value.
  11745. * 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.
  11746. */
  11747. get midtonesSaturation(): number;
  11748. /**
  11749. * Sets the midtones Saturation value.
  11750. * 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.
  11751. */
  11752. set midtonesSaturation(value: number);
  11753. /**
  11754. * Gets the midtones Exposure value.
  11755. * 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.
  11756. */
  11757. get midtonesExposure(): number;
  11758. /**
  11759. * Sets the midtones Exposure value.
  11760. * 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.
  11761. */
  11762. set midtonesExposure(value: number);
  11763. private _shadowsHue;
  11764. private _shadowsDensity;
  11765. private _shadowsSaturation;
  11766. private _shadowsExposure;
  11767. /**
  11768. * Gets the shadows Hue value.
  11769. * 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).
  11770. */
  11771. get shadowsHue(): number;
  11772. /**
  11773. * Sets the shadows Hue value.
  11774. * 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).
  11775. */
  11776. set shadowsHue(value: number);
  11777. /**
  11778. * Gets the shadows Density value.
  11779. * 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.
  11780. * Values less than zero provide a filter of opposite hue.
  11781. */
  11782. get shadowsDensity(): number;
  11783. /**
  11784. * Sets the shadows Density value.
  11785. * 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.
  11786. * Values less than zero provide a filter of opposite hue.
  11787. */
  11788. set shadowsDensity(value: number);
  11789. /**
  11790. * Gets the shadows Saturation value.
  11791. * 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.
  11792. */
  11793. get shadowsSaturation(): number;
  11794. /**
  11795. * Sets the shadows Saturation value.
  11796. * 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.
  11797. */
  11798. set shadowsSaturation(value: number);
  11799. /**
  11800. * Gets the shadows Exposure value.
  11801. * 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.
  11802. */
  11803. get shadowsExposure(): number;
  11804. /**
  11805. * Sets the shadows Exposure value.
  11806. * 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.
  11807. */
  11808. set shadowsExposure(value: number);
  11809. /**
  11810. * Returns the class name
  11811. * @returns The class name
  11812. */
  11813. getClassName(): string;
  11814. /**
  11815. * Binds the color curves to the shader.
  11816. * @param colorCurves The color curve to bind
  11817. * @param effect The effect to bind to
  11818. * @param positiveUniform The positive uniform shader parameter
  11819. * @param neutralUniform The neutral uniform shader parameter
  11820. * @param negativeUniform The negative uniform shader parameter
  11821. */
  11822. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11823. /**
  11824. * Prepare the list of uniforms associated with the ColorCurves effects.
  11825. * @param uniformsList The list of uniforms used in the effect
  11826. */
  11827. static PrepareUniforms(uniformsList: string[]): void;
  11828. /**
  11829. * Returns color grading data based on a hue, density, saturation and exposure value.
  11830. * @param filterHue The hue of the color filter.
  11831. * @param filterDensity The density of the color filter.
  11832. * @param saturation The saturation.
  11833. * @param exposure The exposure.
  11834. * @param result The result data container.
  11835. */
  11836. private getColorGradingDataToRef;
  11837. /**
  11838. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11839. * @param value The input slider value in range [-100,100].
  11840. * @returns Adjusted value.
  11841. */
  11842. private static applyColorGradingSliderNonlinear;
  11843. /**
  11844. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11845. * @param hue The hue (H) input.
  11846. * @param saturation The saturation (S) input.
  11847. * @param brightness The brightness (B) input.
  11848. * @result An RGBA color represented as Vector4.
  11849. */
  11850. private static fromHSBToRef;
  11851. /**
  11852. * Returns a value clamped between min and max
  11853. * @param value The value to clamp
  11854. * @param min The minimum of value
  11855. * @param max The maximum of value
  11856. * @returns The clamped value.
  11857. */
  11858. private static clamp;
  11859. /**
  11860. * Clones the current color curve instance.
  11861. * @return The cloned curves
  11862. */
  11863. clone(): ColorCurves;
  11864. /**
  11865. * Serializes the current color curve instance to a json representation.
  11866. * @return a JSON representation
  11867. */
  11868. serialize(): any;
  11869. /**
  11870. * Parses the color curve from a json representation.
  11871. * @param source the JSON source to parse
  11872. * @return The parsed curves
  11873. */
  11874. static Parse(source: any): ColorCurves;
  11875. }
  11876. }
  11877. declare module BABYLON {
  11878. /**
  11879. * Interface to follow in your material defines to integrate easily the
  11880. * Image proccessing functions.
  11881. * @hidden
  11882. */
  11883. export interface IImageProcessingConfigurationDefines {
  11884. IMAGEPROCESSING: boolean;
  11885. VIGNETTE: boolean;
  11886. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11887. VIGNETTEBLENDMODEOPAQUE: boolean;
  11888. TONEMAPPING: boolean;
  11889. TONEMAPPING_ACES: boolean;
  11890. CONTRAST: boolean;
  11891. EXPOSURE: boolean;
  11892. COLORCURVES: boolean;
  11893. COLORGRADING: boolean;
  11894. COLORGRADING3D: boolean;
  11895. SAMPLER3DGREENDEPTH: boolean;
  11896. SAMPLER3DBGRMAP: boolean;
  11897. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11898. }
  11899. /**
  11900. * @hidden
  11901. */
  11902. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11903. IMAGEPROCESSING: boolean;
  11904. VIGNETTE: boolean;
  11905. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11906. VIGNETTEBLENDMODEOPAQUE: boolean;
  11907. TONEMAPPING: boolean;
  11908. TONEMAPPING_ACES: boolean;
  11909. CONTRAST: boolean;
  11910. COLORCURVES: boolean;
  11911. COLORGRADING: boolean;
  11912. COLORGRADING3D: boolean;
  11913. SAMPLER3DGREENDEPTH: boolean;
  11914. SAMPLER3DBGRMAP: boolean;
  11915. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11916. EXPOSURE: boolean;
  11917. constructor();
  11918. }
  11919. /**
  11920. * This groups together the common properties used for image processing either in direct forward pass
  11921. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11922. * or not.
  11923. */
  11924. export class ImageProcessingConfiguration {
  11925. /**
  11926. * Default tone mapping applied in BabylonJS.
  11927. */
  11928. static readonly TONEMAPPING_STANDARD: number;
  11929. /**
  11930. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11931. * to other engines rendering to increase portability.
  11932. */
  11933. static readonly TONEMAPPING_ACES: number;
  11934. /**
  11935. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11936. */
  11937. colorCurves: Nullable<ColorCurves>;
  11938. private _colorCurvesEnabled;
  11939. /**
  11940. * Gets wether the color curves effect is enabled.
  11941. */
  11942. get colorCurvesEnabled(): boolean;
  11943. /**
  11944. * Sets wether the color curves effect is enabled.
  11945. */
  11946. set colorCurvesEnabled(value: boolean);
  11947. private _colorGradingTexture;
  11948. /**
  11949. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11950. */
  11951. get colorGradingTexture(): Nullable<BaseTexture>;
  11952. /**
  11953. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11954. */
  11955. set colorGradingTexture(value: Nullable<BaseTexture>);
  11956. private _colorGradingEnabled;
  11957. /**
  11958. * Gets wether the color grading effect is enabled.
  11959. */
  11960. get colorGradingEnabled(): boolean;
  11961. /**
  11962. * Sets wether the color grading effect is enabled.
  11963. */
  11964. set colorGradingEnabled(value: boolean);
  11965. private _colorGradingWithGreenDepth;
  11966. /**
  11967. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11968. */
  11969. get colorGradingWithGreenDepth(): boolean;
  11970. /**
  11971. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11972. */
  11973. set colorGradingWithGreenDepth(value: boolean);
  11974. private _colorGradingBGR;
  11975. /**
  11976. * Gets wether the color grading texture contains BGR values.
  11977. */
  11978. get colorGradingBGR(): boolean;
  11979. /**
  11980. * Sets wether the color grading texture contains BGR values.
  11981. */
  11982. set colorGradingBGR(value: boolean);
  11983. /** @hidden */
  11984. _exposure: number;
  11985. /**
  11986. * Gets the Exposure used in the effect.
  11987. */
  11988. get exposure(): number;
  11989. /**
  11990. * Sets the Exposure used in the effect.
  11991. */
  11992. set exposure(value: number);
  11993. private _toneMappingEnabled;
  11994. /**
  11995. * Gets wether the tone mapping effect is enabled.
  11996. */
  11997. get toneMappingEnabled(): boolean;
  11998. /**
  11999. * Sets wether the tone mapping effect is enabled.
  12000. */
  12001. set toneMappingEnabled(value: boolean);
  12002. private _toneMappingType;
  12003. /**
  12004. * Gets the type of tone mapping effect.
  12005. */
  12006. get toneMappingType(): number;
  12007. /**
  12008. * Sets the type of tone mapping effect used in BabylonJS.
  12009. */
  12010. set toneMappingType(value: number);
  12011. protected _contrast: number;
  12012. /**
  12013. * Gets the contrast used in the effect.
  12014. */
  12015. get contrast(): number;
  12016. /**
  12017. * Sets the contrast used in the effect.
  12018. */
  12019. set contrast(value: number);
  12020. /**
  12021. * Vignette stretch size.
  12022. */
  12023. vignetteStretch: number;
  12024. /**
  12025. * Vignette centre X Offset.
  12026. */
  12027. vignetteCentreX: number;
  12028. /**
  12029. * Vignette centre Y Offset.
  12030. */
  12031. vignetteCentreY: number;
  12032. /**
  12033. * Vignette weight or intensity of the vignette effect.
  12034. */
  12035. vignetteWeight: number;
  12036. /**
  12037. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12038. * if vignetteEnabled is set to true.
  12039. */
  12040. vignetteColor: Color4;
  12041. /**
  12042. * Camera field of view used by the Vignette effect.
  12043. */
  12044. vignetteCameraFov: number;
  12045. private _vignetteBlendMode;
  12046. /**
  12047. * Gets the vignette blend mode allowing different kind of effect.
  12048. */
  12049. get vignetteBlendMode(): number;
  12050. /**
  12051. * Sets the vignette blend mode allowing different kind of effect.
  12052. */
  12053. set vignetteBlendMode(value: number);
  12054. private _vignetteEnabled;
  12055. /**
  12056. * Gets wether the vignette effect is enabled.
  12057. */
  12058. get vignetteEnabled(): boolean;
  12059. /**
  12060. * Sets wether the vignette effect is enabled.
  12061. */
  12062. set vignetteEnabled(value: boolean);
  12063. private _applyByPostProcess;
  12064. /**
  12065. * Gets wether the image processing is applied through a post process or not.
  12066. */
  12067. get applyByPostProcess(): boolean;
  12068. /**
  12069. * Sets wether the image processing is applied through a post process or not.
  12070. */
  12071. set applyByPostProcess(value: boolean);
  12072. private _isEnabled;
  12073. /**
  12074. * Gets wether the image processing is enabled or not.
  12075. */
  12076. get isEnabled(): boolean;
  12077. /**
  12078. * Sets wether the image processing is enabled or not.
  12079. */
  12080. set isEnabled(value: boolean);
  12081. /**
  12082. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12083. */
  12084. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12085. /**
  12086. * Method called each time the image processing information changes requires to recompile the effect.
  12087. */
  12088. protected _updateParameters(): void;
  12089. /**
  12090. * Gets the current class name.
  12091. * @return "ImageProcessingConfiguration"
  12092. */
  12093. getClassName(): string;
  12094. /**
  12095. * Prepare the list of uniforms associated with the Image Processing effects.
  12096. * @param uniforms The list of uniforms used in the effect
  12097. * @param defines the list of defines currently in use
  12098. */
  12099. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12100. /**
  12101. * Prepare the list of samplers associated with the Image Processing effects.
  12102. * @param samplersList The list of uniforms used in the effect
  12103. * @param defines the list of defines currently in use
  12104. */
  12105. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12106. /**
  12107. * Prepare the list of defines associated to the shader.
  12108. * @param defines the list of defines to complete
  12109. * @param forPostProcess Define if we are currently in post process mode or not
  12110. */
  12111. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12112. /**
  12113. * Returns true if all the image processing information are ready.
  12114. * @returns True if ready, otherwise, false
  12115. */
  12116. isReady(): boolean;
  12117. /**
  12118. * Binds the image processing to the shader.
  12119. * @param effect The effect to bind to
  12120. * @param overrideAspectRatio Override the aspect ratio of the effect
  12121. */
  12122. bind(effect: Effect, overrideAspectRatio?: number): void;
  12123. /**
  12124. * Clones the current image processing instance.
  12125. * @return The cloned image processing
  12126. */
  12127. clone(): ImageProcessingConfiguration;
  12128. /**
  12129. * Serializes the current image processing instance to a json representation.
  12130. * @return a JSON representation
  12131. */
  12132. serialize(): any;
  12133. /**
  12134. * Parses the image processing from a json representation.
  12135. * @param source the JSON source to parse
  12136. * @return The parsed image processing
  12137. */
  12138. static Parse(source: any): ImageProcessingConfiguration;
  12139. private static _VIGNETTEMODE_MULTIPLY;
  12140. private static _VIGNETTEMODE_OPAQUE;
  12141. /**
  12142. * Used to apply the vignette as a mix with the pixel color.
  12143. */
  12144. static get VIGNETTEMODE_MULTIPLY(): number;
  12145. /**
  12146. * Used to apply the vignette as a replacement of the pixel color.
  12147. */
  12148. static get VIGNETTEMODE_OPAQUE(): number;
  12149. }
  12150. }
  12151. declare module BABYLON {
  12152. /** @hidden */
  12153. export var postprocessVertexShader: {
  12154. name: string;
  12155. shader: string;
  12156. };
  12157. }
  12158. declare module BABYLON {
  12159. /**
  12160. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12161. */
  12162. export type RenderTargetTextureSize = number | {
  12163. width: number;
  12164. height: number;
  12165. layers?: number;
  12166. };
  12167. interface ThinEngine {
  12168. /**
  12169. * Creates a new render target texture
  12170. * @param size defines the size of the texture
  12171. * @param options defines the options used to create the texture
  12172. * @returns a new render target texture stored in an InternalTexture
  12173. */
  12174. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12175. /**
  12176. * Creates a depth stencil texture.
  12177. * This is only available in WebGL 2 or with the depth texture extension available.
  12178. * @param size The size of face edge in the texture.
  12179. * @param options The options defining the texture.
  12180. * @returns The texture
  12181. */
  12182. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12183. /** @hidden */
  12184. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12185. }
  12186. }
  12187. declare module BABYLON {
  12188. /**
  12189. * Defines the kind of connection point for node based material
  12190. */
  12191. export enum NodeMaterialBlockConnectionPointTypes {
  12192. /** Float */
  12193. Float = 1,
  12194. /** Int */
  12195. Int = 2,
  12196. /** Vector2 */
  12197. Vector2 = 4,
  12198. /** Vector3 */
  12199. Vector3 = 8,
  12200. /** Vector4 */
  12201. Vector4 = 16,
  12202. /** Color3 */
  12203. Color3 = 32,
  12204. /** Color4 */
  12205. Color4 = 64,
  12206. /** Matrix */
  12207. Matrix = 128,
  12208. /** Custom object */
  12209. Object = 256,
  12210. /** Detect type based on connection */
  12211. AutoDetect = 1024,
  12212. /** Output type that will be defined by input type */
  12213. BasedOnInput = 2048
  12214. }
  12215. }
  12216. declare module BABYLON {
  12217. /**
  12218. * Enum used to define the target of a block
  12219. */
  12220. export enum NodeMaterialBlockTargets {
  12221. /** Vertex shader */
  12222. Vertex = 1,
  12223. /** Fragment shader */
  12224. Fragment = 2,
  12225. /** Neutral */
  12226. Neutral = 4,
  12227. /** Vertex and Fragment */
  12228. VertexAndFragment = 3
  12229. }
  12230. }
  12231. declare module BABYLON {
  12232. /**
  12233. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12234. */
  12235. export enum NodeMaterialBlockConnectionPointMode {
  12236. /** Value is an uniform */
  12237. Uniform = 0,
  12238. /** Value is a mesh attribute */
  12239. Attribute = 1,
  12240. /** Value is a varying between vertex and fragment shaders */
  12241. Varying = 2,
  12242. /** Mode is undefined */
  12243. Undefined = 3
  12244. }
  12245. }
  12246. declare module BABYLON {
  12247. /**
  12248. * Enum used to define system values e.g. values automatically provided by the system
  12249. */
  12250. export enum NodeMaterialSystemValues {
  12251. /** World */
  12252. World = 1,
  12253. /** View */
  12254. View = 2,
  12255. /** Projection */
  12256. Projection = 3,
  12257. /** ViewProjection */
  12258. ViewProjection = 4,
  12259. /** WorldView */
  12260. WorldView = 5,
  12261. /** WorldViewProjection */
  12262. WorldViewProjection = 6,
  12263. /** CameraPosition */
  12264. CameraPosition = 7,
  12265. /** Fog Color */
  12266. FogColor = 8,
  12267. /** Delta time */
  12268. DeltaTime = 9
  12269. }
  12270. }
  12271. declare module BABYLON {
  12272. /**
  12273. * Represents a camera frustum
  12274. */
  12275. export class Frustum {
  12276. /**
  12277. * Gets the planes representing the frustum
  12278. * @param transform matrix to be applied to the returned planes
  12279. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12280. */
  12281. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12282. /**
  12283. * Gets the near frustum plane transformed by the transform matrix
  12284. * @param transform transformation matrix to be applied to the resulting frustum plane
  12285. * @param frustumPlane the resuling frustum plane
  12286. */
  12287. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12288. /**
  12289. * Gets the far frustum plane transformed by the transform matrix
  12290. * @param transform transformation matrix to be applied to the resulting frustum plane
  12291. * @param frustumPlane the resuling frustum plane
  12292. */
  12293. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12294. /**
  12295. * Gets the left frustum plane transformed by the transform matrix
  12296. * @param transform transformation matrix to be applied to the resulting frustum plane
  12297. * @param frustumPlane the resuling frustum plane
  12298. */
  12299. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12300. /**
  12301. * Gets the right frustum plane transformed by the transform matrix
  12302. * @param transform transformation matrix to be applied to the resulting frustum plane
  12303. * @param frustumPlane the resuling frustum plane
  12304. */
  12305. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12306. /**
  12307. * Gets the top frustum plane transformed by the transform matrix
  12308. * @param transform transformation matrix to be applied to the resulting frustum plane
  12309. * @param frustumPlane the resuling frustum plane
  12310. */
  12311. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12312. /**
  12313. * Gets the bottom frustum plane transformed by the transform matrix
  12314. * @param transform transformation matrix to be applied to the resulting frustum plane
  12315. * @param frustumPlane the resuling frustum plane
  12316. */
  12317. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12318. /**
  12319. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12320. * @param transform transformation matrix to be applied to the resulting frustum planes
  12321. * @param frustumPlanes the resuling frustum planes
  12322. */
  12323. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12324. }
  12325. }
  12326. declare module BABYLON {
  12327. /**
  12328. * Contains position and normal vectors for a vertex
  12329. */
  12330. export class PositionNormalVertex {
  12331. /** the position of the vertex (defaut: 0,0,0) */
  12332. position: Vector3;
  12333. /** the normal of the vertex (defaut: 0,1,0) */
  12334. normal: Vector3;
  12335. /**
  12336. * Creates a PositionNormalVertex
  12337. * @param position the position of the vertex (defaut: 0,0,0)
  12338. * @param normal the normal of the vertex (defaut: 0,1,0)
  12339. */
  12340. constructor(
  12341. /** the position of the vertex (defaut: 0,0,0) */
  12342. position?: Vector3,
  12343. /** the normal of the vertex (defaut: 0,1,0) */
  12344. normal?: Vector3);
  12345. /**
  12346. * Clones the PositionNormalVertex
  12347. * @returns the cloned PositionNormalVertex
  12348. */
  12349. clone(): PositionNormalVertex;
  12350. }
  12351. /**
  12352. * Contains position, normal and uv vectors for a vertex
  12353. */
  12354. export class PositionNormalTextureVertex {
  12355. /** the position of the vertex (defaut: 0,0,0) */
  12356. position: Vector3;
  12357. /** the normal of the vertex (defaut: 0,1,0) */
  12358. normal: Vector3;
  12359. /** the uv of the vertex (default: 0,0) */
  12360. uv: Vector2;
  12361. /**
  12362. * Creates a PositionNormalTextureVertex
  12363. * @param position the position of the vertex (defaut: 0,0,0)
  12364. * @param normal the normal of the vertex (defaut: 0,1,0)
  12365. * @param uv the uv of the vertex (default: 0,0)
  12366. */
  12367. constructor(
  12368. /** the position of the vertex (defaut: 0,0,0) */
  12369. position?: Vector3,
  12370. /** the normal of the vertex (defaut: 0,1,0) */
  12371. normal?: Vector3,
  12372. /** the uv of the vertex (default: 0,0) */
  12373. uv?: Vector2);
  12374. /**
  12375. * Clones the PositionNormalTextureVertex
  12376. * @returns the cloned PositionNormalTextureVertex
  12377. */
  12378. clone(): PositionNormalTextureVertex;
  12379. }
  12380. }
  12381. declare module BABYLON {
  12382. /**
  12383. * Enum defining the type of animations supported by InputBlock
  12384. */
  12385. export enum AnimatedInputBlockTypes {
  12386. /** No animation */
  12387. None = 0,
  12388. /** Time based animation. Will only work for floats */
  12389. Time = 1
  12390. }
  12391. }
  12392. declare module BABYLON {
  12393. /**
  12394. * Block used to expose an input value
  12395. */
  12396. export class InputBlock extends NodeMaterialBlock {
  12397. private _mode;
  12398. private _associatedVariableName;
  12399. private _storedValue;
  12400. private _valueCallback;
  12401. private _type;
  12402. private _animationType;
  12403. /** Gets or set a value used to limit the range of float values */
  12404. min: number;
  12405. /** Gets or set a value used to limit the range of float values */
  12406. max: number;
  12407. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12408. isBoolean: boolean;
  12409. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12410. matrixMode: number;
  12411. /** @hidden */
  12412. _systemValue: Nullable<NodeMaterialSystemValues>;
  12413. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12414. isConstant: boolean;
  12415. /** Gets or sets the group to use to display this block in the Inspector */
  12416. groupInInspector: string;
  12417. /** Gets an observable raised when the value is changed */
  12418. onValueChangedObservable: Observable<InputBlock>;
  12419. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12420. convertToGammaSpace: boolean;
  12421. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12422. convertToLinearSpace: boolean;
  12423. /**
  12424. * Gets or sets the connection point type (default is float)
  12425. */
  12426. get type(): NodeMaterialBlockConnectionPointTypes;
  12427. /**
  12428. * Creates a new InputBlock
  12429. * @param name defines the block name
  12430. * @param target defines the target of that block (Vertex by default)
  12431. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12432. */
  12433. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12434. /**
  12435. * Validates if a name is a reserve word.
  12436. * @param newName the new name to be given to the node.
  12437. * @returns false if the name is a reserve word, else true.
  12438. */
  12439. validateBlockName(newName: string): boolean;
  12440. /**
  12441. * Gets the output component
  12442. */
  12443. get output(): NodeMaterialConnectionPoint;
  12444. /**
  12445. * Set the source of this connection point to a vertex attribute
  12446. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12447. * @returns the current connection point
  12448. */
  12449. setAsAttribute(attributeName?: string): InputBlock;
  12450. /**
  12451. * Set the source of this connection point to a system value
  12452. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12453. * @returns the current connection point
  12454. */
  12455. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12456. /**
  12457. * Gets or sets the value of that point.
  12458. * Please note that this value will be ignored if valueCallback is defined
  12459. */
  12460. get value(): any;
  12461. set value(value: any);
  12462. /**
  12463. * Gets or sets a callback used to get the value of that point.
  12464. * Please note that setting this value will force the connection point to ignore the value property
  12465. */
  12466. get valueCallback(): () => any;
  12467. set valueCallback(value: () => any);
  12468. /**
  12469. * Gets or sets the associated variable name in the shader
  12470. */
  12471. get associatedVariableName(): string;
  12472. set associatedVariableName(value: string);
  12473. /** Gets or sets the type of animation applied to the input */
  12474. get animationType(): AnimatedInputBlockTypes;
  12475. set animationType(value: AnimatedInputBlockTypes);
  12476. /**
  12477. * Gets a boolean indicating that this connection point not defined yet
  12478. */
  12479. get isUndefined(): boolean;
  12480. /**
  12481. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12482. * In this case the connection point name must be the name of the uniform to use.
  12483. * Can only be set on inputs
  12484. */
  12485. get isUniform(): boolean;
  12486. set isUniform(value: boolean);
  12487. /**
  12488. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12489. * In this case the connection point name must be the name of the attribute to use
  12490. * Can only be set on inputs
  12491. */
  12492. get isAttribute(): boolean;
  12493. set isAttribute(value: boolean);
  12494. /**
  12495. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12496. * Can only be set on exit points
  12497. */
  12498. get isVarying(): boolean;
  12499. set isVarying(value: boolean);
  12500. /**
  12501. * Gets a boolean indicating that the current connection point is a system value
  12502. */
  12503. get isSystemValue(): boolean;
  12504. /**
  12505. * Gets or sets the current well known value or null if not defined as a system value
  12506. */
  12507. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12508. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12509. /**
  12510. * Gets the current class name
  12511. * @returns the class name
  12512. */
  12513. getClassName(): string;
  12514. /**
  12515. * Animate the input if animationType !== None
  12516. * @param scene defines the rendering scene
  12517. */
  12518. animate(scene: Scene): void;
  12519. private _emitDefine;
  12520. initialize(state: NodeMaterialBuildState): void;
  12521. /**
  12522. * Set the input block to its default value (based on its type)
  12523. */
  12524. setDefaultValue(): void;
  12525. private _emitConstant;
  12526. /** @hidden */
  12527. get _noContextSwitch(): boolean;
  12528. private _emit;
  12529. /** @hidden */
  12530. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12531. /** @hidden */
  12532. _transmit(effect: Effect, scene: Scene): void;
  12533. protected _buildBlock(state: NodeMaterialBuildState): void;
  12534. protected _dumpPropertiesCode(): string;
  12535. dispose(): void;
  12536. serialize(): any;
  12537. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12538. }
  12539. }
  12540. declare module BABYLON {
  12541. /**
  12542. * Enum used to define the compatibility state between two connection points
  12543. */
  12544. export enum NodeMaterialConnectionPointCompatibilityStates {
  12545. /** Points are compatibles */
  12546. Compatible = 0,
  12547. /** Points are incompatible because of their types */
  12548. TypeIncompatible = 1,
  12549. /** Points are incompatible because of their targets (vertex vs fragment) */
  12550. TargetIncompatible = 2
  12551. }
  12552. /**
  12553. * Defines the direction of a connection point
  12554. */
  12555. export enum NodeMaterialConnectionPointDirection {
  12556. /** Input */
  12557. Input = 0,
  12558. /** Output */
  12559. Output = 1
  12560. }
  12561. /**
  12562. * Defines a connection point for a block
  12563. */
  12564. export class NodeMaterialConnectionPoint {
  12565. /**
  12566. * Checks if two types are equivalent
  12567. * @param type1 type 1 to check
  12568. * @param type2 type 2 to check
  12569. * @returns true if both types are equivalent, else false
  12570. */
  12571. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12572. /** @hidden */
  12573. _ownerBlock: NodeMaterialBlock;
  12574. /** @hidden */
  12575. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12576. private _endpoints;
  12577. private _associatedVariableName;
  12578. private _direction;
  12579. /** @hidden */
  12580. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12581. /** @hidden */
  12582. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12583. /** @hidden */
  12584. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12585. private _type;
  12586. /** @hidden */
  12587. _enforceAssociatedVariableName: boolean;
  12588. /** Gets the direction of the point */
  12589. get direction(): NodeMaterialConnectionPointDirection;
  12590. /** Indicates that this connection point needs dual validation before being connected to another point */
  12591. needDualDirectionValidation: boolean;
  12592. /**
  12593. * Gets or sets the additional types supported by this connection point
  12594. */
  12595. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12596. /**
  12597. * Gets or sets the additional types excluded by this connection point
  12598. */
  12599. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12600. /**
  12601. * Observable triggered when this point is connected
  12602. */
  12603. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12604. /**
  12605. * Gets or sets the associated variable name in the shader
  12606. */
  12607. get associatedVariableName(): string;
  12608. set associatedVariableName(value: string);
  12609. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12610. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12611. /**
  12612. * Gets or sets the connection point type (default is float)
  12613. */
  12614. get type(): NodeMaterialBlockConnectionPointTypes;
  12615. set type(value: NodeMaterialBlockConnectionPointTypes);
  12616. /**
  12617. * Gets or sets the connection point name
  12618. */
  12619. name: string;
  12620. /**
  12621. * Gets or sets the connection point name
  12622. */
  12623. displayName: string;
  12624. /**
  12625. * Gets or sets a boolean indicating that this connection point can be omitted
  12626. */
  12627. isOptional: boolean;
  12628. /**
  12629. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12630. */
  12631. isExposedOnFrame: boolean;
  12632. /**
  12633. * Gets or sets number indicating the position that the port is exposed to on a frame
  12634. */
  12635. exposedPortPosition: number;
  12636. /**
  12637. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12638. */
  12639. define: string;
  12640. /** @hidden */
  12641. _prioritizeVertex: boolean;
  12642. private _target;
  12643. /** Gets or sets the target of that connection point */
  12644. get target(): NodeMaterialBlockTargets;
  12645. set target(value: NodeMaterialBlockTargets);
  12646. /**
  12647. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12648. */
  12649. get isConnected(): boolean;
  12650. /**
  12651. * Gets a boolean indicating that the current point is connected to an input block
  12652. */
  12653. get isConnectedToInputBlock(): boolean;
  12654. /**
  12655. * Gets a the connected input block (if any)
  12656. */
  12657. get connectInputBlock(): Nullable<InputBlock>;
  12658. /** Get the other side of the connection (if any) */
  12659. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12660. /** Get the block that owns this connection point */
  12661. get ownerBlock(): NodeMaterialBlock;
  12662. /** Get the block connected on the other side of this connection (if any) */
  12663. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12664. /** Get the block connected on the endpoints of this connection (if any) */
  12665. get connectedBlocks(): Array<NodeMaterialBlock>;
  12666. /** Gets the list of connected endpoints */
  12667. get endpoints(): NodeMaterialConnectionPoint[];
  12668. /** Gets a boolean indicating if that output point is connected to at least one input */
  12669. get hasEndpoints(): boolean;
  12670. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12671. get isConnectedInVertexShader(): boolean;
  12672. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12673. get isConnectedInFragmentShader(): boolean;
  12674. /**
  12675. * Creates a block suitable to be used as an input for this input point.
  12676. * If null is returned, a block based on the point type will be created.
  12677. * @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
  12678. */
  12679. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12680. /**
  12681. * Creates a new connection point
  12682. * @param name defines the connection point name
  12683. * @param ownerBlock defines the block hosting this connection point
  12684. * @param direction defines the direction of the connection point
  12685. */
  12686. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12687. /**
  12688. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12689. * @returns the class name
  12690. */
  12691. getClassName(): string;
  12692. /**
  12693. * Gets a boolean indicating if the current point can be connected to another point
  12694. * @param connectionPoint defines the other connection point
  12695. * @returns a boolean
  12696. */
  12697. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12698. /**
  12699. * Gets a number indicating if the current point can be connected to another point
  12700. * @param connectionPoint defines the other connection point
  12701. * @returns a number defining the compatibility state
  12702. */
  12703. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12704. /**
  12705. * Connect this point to another connection point
  12706. * @param connectionPoint defines the other connection point
  12707. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12708. * @returns the current connection point
  12709. */
  12710. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12711. /**
  12712. * Disconnect this point from one of his endpoint
  12713. * @param endpoint defines the other connection point
  12714. * @returns the current connection point
  12715. */
  12716. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12717. /**
  12718. * Serializes this point in a JSON representation
  12719. * @param isInput defines if the connection point is an input (default is true)
  12720. * @returns the serialized point object
  12721. */
  12722. serialize(isInput?: boolean): any;
  12723. /**
  12724. * Release resources
  12725. */
  12726. dispose(): void;
  12727. }
  12728. }
  12729. declare module BABYLON {
  12730. /**
  12731. * Enum used to define the material modes
  12732. */
  12733. export enum NodeMaterialModes {
  12734. /** Regular material */
  12735. Material = 0,
  12736. /** For post process */
  12737. PostProcess = 1,
  12738. /** For particle system */
  12739. Particle = 2,
  12740. /** For procedural texture */
  12741. ProceduralTexture = 3
  12742. }
  12743. }
  12744. declare module BABYLON {
  12745. /** @hidden */
  12746. export var helperFunctions: {
  12747. name: string;
  12748. shader: string;
  12749. };
  12750. }
  12751. declare module BABYLON {
  12752. /**
  12753. * Block used to read a texture from a sampler
  12754. */
  12755. export class TextureBlock extends NodeMaterialBlock {
  12756. private _defineName;
  12757. private _linearDefineName;
  12758. private _gammaDefineName;
  12759. private _tempTextureRead;
  12760. private _samplerName;
  12761. private _transformedUVName;
  12762. private _textureTransformName;
  12763. private _textureInfoName;
  12764. private _mainUVName;
  12765. private _mainUVDefineName;
  12766. private _fragmentOnly;
  12767. /**
  12768. * Gets or sets the texture associated with the node
  12769. */
  12770. texture: Nullable<Texture>;
  12771. /**
  12772. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12773. */
  12774. convertToGammaSpace: boolean;
  12775. /**
  12776. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12777. */
  12778. convertToLinearSpace: boolean;
  12779. /**
  12780. * Create a new TextureBlock
  12781. * @param name defines the block name
  12782. */
  12783. constructor(name: string, fragmentOnly?: boolean);
  12784. /**
  12785. * Gets the current class name
  12786. * @returns the class name
  12787. */
  12788. getClassName(): string;
  12789. /**
  12790. * Gets the uv input component
  12791. */
  12792. get uv(): NodeMaterialConnectionPoint;
  12793. /**
  12794. * Gets the rgba output component
  12795. */
  12796. get rgba(): NodeMaterialConnectionPoint;
  12797. /**
  12798. * Gets the rgb output component
  12799. */
  12800. get rgb(): NodeMaterialConnectionPoint;
  12801. /**
  12802. * Gets the r output component
  12803. */
  12804. get r(): NodeMaterialConnectionPoint;
  12805. /**
  12806. * Gets the g output component
  12807. */
  12808. get g(): NodeMaterialConnectionPoint;
  12809. /**
  12810. * Gets the b output component
  12811. */
  12812. get b(): NodeMaterialConnectionPoint;
  12813. /**
  12814. * Gets the a output component
  12815. */
  12816. get a(): NodeMaterialConnectionPoint;
  12817. get target(): NodeMaterialBlockTargets;
  12818. autoConfigure(material: NodeMaterial): void;
  12819. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12821. isReady(): boolean;
  12822. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12823. private get _isMixed();
  12824. private _injectVertexCode;
  12825. private _writeTextureRead;
  12826. private _writeOutput;
  12827. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12828. protected _dumpPropertiesCode(): string;
  12829. serialize(): any;
  12830. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12831. }
  12832. }
  12833. declare module BABYLON {
  12834. /** @hidden */
  12835. export var reflectionFunction: {
  12836. name: string;
  12837. shader: string;
  12838. };
  12839. }
  12840. declare module BABYLON {
  12841. /**
  12842. * Base block used to read a reflection texture from a sampler
  12843. */
  12844. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12845. /** @hidden */
  12846. _define3DName: string;
  12847. /** @hidden */
  12848. _defineCubicName: string;
  12849. /** @hidden */
  12850. _defineExplicitName: string;
  12851. /** @hidden */
  12852. _defineProjectionName: string;
  12853. /** @hidden */
  12854. _defineLocalCubicName: string;
  12855. /** @hidden */
  12856. _defineSphericalName: string;
  12857. /** @hidden */
  12858. _definePlanarName: string;
  12859. /** @hidden */
  12860. _defineEquirectangularName: string;
  12861. /** @hidden */
  12862. _defineMirroredEquirectangularFixedName: string;
  12863. /** @hidden */
  12864. _defineEquirectangularFixedName: string;
  12865. /** @hidden */
  12866. _defineSkyboxName: string;
  12867. /** @hidden */
  12868. _defineOppositeZ: string;
  12869. /** @hidden */
  12870. _cubeSamplerName: string;
  12871. /** @hidden */
  12872. _2DSamplerName: string;
  12873. protected _positionUVWName: string;
  12874. protected _directionWName: string;
  12875. protected _reflectionVectorName: string;
  12876. /** @hidden */
  12877. _reflectionCoordsName: string;
  12878. /** @hidden */
  12879. _reflectionMatrixName: string;
  12880. protected _reflectionColorName: string;
  12881. /**
  12882. * Gets or sets the texture associated with the node
  12883. */
  12884. texture: Nullable<BaseTexture>;
  12885. /**
  12886. * Create a new ReflectionTextureBaseBlock
  12887. * @param name defines the block name
  12888. */
  12889. constructor(name: string);
  12890. /**
  12891. * Gets the current class name
  12892. * @returns the class name
  12893. */
  12894. getClassName(): string;
  12895. /**
  12896. * Gets the world position input component
  12897. */
  12898. abstract get position(): NodeMaterialConnectionPoint;
  12899. /**
  12900. * Gets the world position input component
  12901. */
  12902. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12903. /**
  12904. * Gets the world normal input component
  12905. */
  12906. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12907. /**
  12908. * Gets the world input component
  12909. */
  12910. abstract get world(): NodeMaterialConnectionPoint;
  12911. /**
  12912. * Gets the camera (or eye) position component
  12913. */
  12914. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12915. /**
  12916. * Gets the view input component
  12917. */
  12918. abstract get view(): NodeMaterialConnectionPoint;
  12919. protected _getTexture(): Nullable<BaseTexture>;
  12920. autoConfigure(material: NodeMaterial): void;
  12921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12922. isReady(): boolean;
  12923. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12924. /**
  12925. * Gets the code to inject in the vertex shader
  12926. * @param state current state of the node material building
  12927. * @returns the shader code
  12928. */
  12929. handleVertexSide(state: NodeMaterialBuildState): string;
  12930. /**
  12931. * Handles the inits for the fragment code path
  12932. * @param state node material build state
  12933. */
  12934. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12935. /**
  12936. * Generates the reflection coords code for the fragment code path
  12937. * @param worldNormalVarName name of the world normal variable
  12938. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12939. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12940. * @returns the shader code
  12941. */
  12942. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12943. /**
  12944. * Generates the reflection color code for the fragment code path
  12945. * @param lodVarName name of the lod variable
  12946. * @param swizzleLookupTexture swizzle to use for the final color variable
  12947. * @returns the shader code
  12948. */
  12949. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12950. /**
  12951. * Generates the code corresponding to the connected output points
  12952. * @param state node material build state
  12953. * @param varName name of the variable to output
  12954. * @returns the shader code
  12955. */
  12956. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12957. protected _buildBlock(state: NodeMaterialBuildState): this;
  12958. protected _dumpPropertiesCode(): string;
  12959. serialize(): any;
  12960. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12961. }
  12962. }
  12963. declare module BABYLON {
  12964. /**
  12965. * Defines a connection point to be used for points with a custom object type
  12966. */
  12967. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12968. private _blockType;
  12969. private _blockName;
  12970. private _nameForCheking?;
  12971. /**
  12972. * Creates a new connection point
  12973. * @param name defines the connection point name
  12974. * @param ownerBlock defines the block hosting this connection point
  12975. * @param direction defines the direction of the connection point
  12976. */
  12977. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12978. /**
  12979. * Gets a number indicating if the current point can be connected to another point
  12980. * @param connectionPoint defines the other connection point
  12981. * @returns a number defining the compatibility state
  12982. */
  12983. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12984. /**
  12985. * Creates a block suitable to be used as an input for this input point.
  12986. * If null is returned, a block based on the point type will be created.
  12987. * @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
  12988. */
  12989. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12990. }
  12991. }
  12992. declare module BABYLON {
  12993. /**
  12994. * Enum defining the type of properties that can be edited in the property pages in the NME
  12995. */
  12996. export enum PropertyTypeForEdition {
  12997. /** property is a boolean */
  12998. Boolean = 0,
  12999. /** property is a float */
  13000. Float = 1,
  13001. /** property is a Vector2 */
  13002. Vector2 = 2,
  13003. /** property is a list of values */
  13004. List = 3
  13005. }
  13006. /**
  13007. * Interface that defines an option in a variable of type list
  13008. */
  13009. export interface IEditablePropertyListOption {
  13010. /** label of the option */
  13011. "label": string;
  13012. /** value of the option */
  13013. "value": number;
  13014. }
  13015. /**
  13016. * Interface that defines the options available for an editable property
  13017. */
  13018. export interface IEditablePropertyOption {
  13019. /** min value */
  13020. "min"?: number;
  13021. /** max value */
  13022. "max"?: number;
  13023. /** notifiers: indicates which actions to take when the property is changed */
  13024. "notifiers"?: {
  13025. /** the material should be rebuilt */
  13026. "rebuild"?: boolean;
  13027. /** the preview should be updated */
  13028. "update"?: boolean;
  13029. };
  13030. /** list of the options for a variable of type list */
  13031. "options"?: IEditablePropertyListOption[];
  13032. }
  13033. /**
  13034. * Interface that describes an editable property
  13035. */
  13036. export interface IPropertyDescriptionForEdition {
  13037. /** name of the property */
  13038. "propertyName": string;
  13039. /** display name of the property */
  13040. "displayName": string;
  13041. /** type of the property */
  13042. "type": PropertyTypeForEdition;
  13043. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13044. "groupName": string;
  13045. /** options for the property */
  13046. "options": IEditablePropertyOption;
  13047. }
  13048. /**
  13049. * Decorator that flags a property in a node material block as being editable
  13050. */
  13051. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13052. }
  13053. declare module BABYLON {
  13054. /**
  13055. * Block used to implement the refraction part of the sub surface module of the PBR material
  13056. */
  13057. export class RefractionBlock extends NodeMaterialBlock {
  13058. /** @hidden */
  13059. _define3DName: string;
  13060. /** @hidden */
  13061. _refractionMatrixName: string;
  13062. /** @hidden */
  13063. _defineLODRefractionAlpha: string;
  13064. /** @hidden */
  13065. _defineLinearSpecularRefraction: string;
  13066. /** @hidden */
  13067. _defineOppositeZ: string;
  13068. /** @hidden */
  13069. _cubeSamplerName: string;
  13070. /** @hidden */
  13071. _2DSamplerName: string;
  13072. /** @hidden */
  13073. _vRefractionMicrosurfaceInfosName: string;
  13074. /** @hidden */
  13075. _vRefractionInfosName: string;
  13076. /** @hidden */
  13077. _vRefractionFilteringInfoName: string;
  13078. private _scene;
  13079. /**
  13080. * The properties below are set by the main PBR block prior to calling methods of this class.
  13081. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13082. * It's less burden on the user side in the editor part.
  13083. */
  13084. /** @hidden */
  13085. viewConnectionPoint: NodeMaterialConnectionPoint;
  13086. /** @hidden */
  13087. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13088. /**
  13089. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13090. * Materials half opaque for instance using refraction could benefit from this control.
  13091. */
  13092. linkRefractionWithTransparency: boolean;
  13093. /**
  13094. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13095. */
  13096. invertRefractionY: boolean;
  13097. /**
  13098. * Gets or sets the texture associated with the node
  13099. */
  13100. texture: Nullable<BaseTexture>;
  13101. /**
  13102. * Create a new RefractionBlock
  13103. * @param name defines the block name
  13104. */
  13105. constructor(name: string);
  13106. /**
  13107. * Gets the current class name
  13108. * @returns the class name
  13109. */
  13110. getClassName(): string;
  13111. /**
  13112. * Gets the intensity input component
  13113. */
  13114. get intensity(): NodeMaterialConnectionPoint;
  13115. /**
  13116. * Gets the tint at distance input component
  13117. */
  13118. get tintAtDistance(): NodeMaterialConnectionPoint;
  13119. /**
  13120. * Gets the view input component
  13121. */
  13122. get view(): NodeMaterialConnectionPoint;
  13123. /**
  13124. * Gets the refraction object output component
  13125. */
  13126. get refraction(): NodeMaterialConnectionPoint;
  13127. /**
  13128. * Returns true if the block has a texture
  13129. */
  13130. get hasTexture(): boolean;
  13131. protected _getTexture(): Nullable<BaseTexture>;
  13132. autoConfigure(material: NodeMaterial): void;
  13133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13134. isReady(): boolean;
  13135. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13136. /**
  13137. * Gets the main code of the block (fragment side)
  13138. * @param state current state of the node material building
  13139. * @returns the shader code
  13140. */
  13141. getCode(state: NodeMaterialBuildState): string;
  13142. protected _buildBlock(state: NodeMaterialBuildState): this;
  13143. protected _dumpPropertiesCode(): string;
  13144. serialize(): any;
  13145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13146. }
  13147. }
  13148. declare module BABYLON {
  13149. /**
  13150. * Base block used as input for post process
  13151. */
  13152. export class CurrentScreenBlock extends NodeMaterialBlock {
  13153. private _samplerName;
  13154. private _linearDefineName;
  13155. private _gammaDefineName;
  13156. private _mainUVName;
  13157. private _tempTextureRead;
  13158. /**
  13159. * Gets or sets the texture associated with the node
  13160. */
  13161. texture: Nullable<BaseTexture>;
  13162. /**
  13163. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13164. */
  13165. convertToGammaSpace: boolean;
  13166. /**
  13167. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13168. */
  13169. convertToLinearSpace: boolean;
  13170. /**
  13171. * Create a new CurrentScreenBlock
  13172. * @param name defines the block name
  13173. */
  13174. constructor(name: string);
  13175. /**
  13176. * Gets the current class name
  13177. * @returns the class name
  13178. */
  13179. getClassName(): string;
  13180. /**
  13181. * Gets the uv input component
  13182. */
  13183. get uv(): NodeMaterialConnectionPoint;
  13184. /**
  13185. * Gets the rgba output component
  13186. */
  13187. get rgba(): NodeMaterialConnectionPoint;
  13188. /**
  13189. * Gets the rgb output component
  13190. */
  13191. get rgb(): NodeMaterialConnectionPoint;
  13192. /**
  13193. * Gets the r output component
  13194. */
  13195. get r(): NodeMaterialConnectionPoint;
  13196. /**
  13197. * Gets the g output component
  13198. */
  13199. get g(): NodeMaterialConnectionPoint;
  13200. /**
  13201. * Gets the b output component
  13202. */
  13203. get b(): NodeMaterialConnectionPoint;
  13204. /**
  13205. * Gets the a output component
  13206. */
  13207. get a(): NodeMaterialConnectionPoint;
  13208. /**
  13209. * Initialize the block and prepare the context for build
  13210. * @param state defines the state that will be used for the build
  13211. */
  13212. initialize(state: NodeMaterialBuildState): void;
  13213. get target(): NodeMaterialBlockTargets;
  13214. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13215. isReady(): boolean;
  13216. private _injectVertexCode;
  13217. private _writeTextureRead;
  13218. private _writeOutput;
  13219. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13220. serialize(): any;
  13221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13222. }
  13223. }
  13224. declare module BABYLON {
  13225. /**
  13226. * Base block used for the particle texture
  13227. */
  13228. export class ParticleTextureBlock extends NodeMaterialBlock {
  13229. private _samplerName;
  13230. private _linearDefineName;
  13231. private _gammaDefineName;
  13232. private _tempTextureRead;
  13233. /**
  13234. * Gets or sets the texture associated with the node
  13235. */
  13236. texture: Nullable<BaseTexture>;
  13237. /**
  13238. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13239. */
  13240. convertToGammaSpace: boolean;
  13241. /**
  13242. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13243. */
  13244. convertToLinearSpace: boolean;
  13245. /**
  13246. * Create a new ParticleTextureBlock
  13247. * @param name defines the block name
  13248. */
  13249. constructor(name: string);
  13250. /**
  13251. * Gets the current class name
  13252. * @returns the class name
  13253. */
  13254. getClassName(): string;
  13255. /**
  13256. * Gets the uv input component
  13257. */
  13258. get uv(): NodeMaterialConnectionPoint;
  13259. /**
  13260. * Gets the rgba output component
  13261. */
  13262. get rgba(): NodeMaterialConnectionPoint;
  13263. /**
  13264. * Gets the rgb output component
  13265. */
  13266. get rgb(): NodeMaterialConnectionPoint;
  13267. /**
  13268. * Gets the r output component
  13269. */
  13270. get r(): NodeMaterialConnectionPoint;
  13271. /**
  13272. * Gets the g output component
  13273. */
  13274. get g(): NodeMaterialConnectionPoint;
  13275. /**
  13276. * Gets the b output component
  13277. */
  13278. get b(): NodeMaterialConnectionPoint;
  13279. /**
  13280. * Gets the a output component
  13281. */
  13282. get a(): NodeMaterialConnectionPoint;
  13283. /**
  13284. * Initialize the block and prepare the context for build
  13285. * @param state defines the state that will be used for the build
  13286. */
  13287. initialize(state: NodeMaterialBuildState): void;
  13288. autoConfigure(material: NodeMaterial): void;
  13289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13290. isReady(): boolean;
  13291. private _writeOutput;
  13292. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13293. serialize(): any;
  13294. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13295. }
  13296. }
  13297. declare module BABYLON {
  13298. /**
  13299. * Class used to store shared data between 2 NodeMaterialBuildState
  13300. */
  13301. export class NodeMaterialBuildStateSharedData {
  13302. /**
  13303. * Gets the list of emitted varyings
  13304. */
  13305. temps: string[];
  13306. /**
  13307. * Gets the list of emitted varyings
  13308. */
  13309. varyings: string[];
  13310. /**
  13311. * Gets the varying declaration string
  13312. */
  13313. varyingDeclaration: string;
  13314. /**
  13315. * Input blocks
  13316. */
  13317. inputBlocks: InputBlock[];
  13318. /**
  13319. * Input blocks
  13320. */
  13321. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13322. /**
  13323. * Bindable blocks (Blocks that need to set data to the effect)
  13324. */
  13325. bindableBlocks: NodeMaterialBlock[];
  13326. /**
  13327. * List of blocks that can provide a compilation fallback
  13328. */
  13329. blocksWithFallbacks: NodeMaterialBlock[];
  13330. /**
  13331. * List of blocks that can provide a define update
  13332. */
  13333. blocksWithDefines: NodeMaterialBlock[];
  13334. /**
  13335. * List of blocks that can provide a repeatable content
  13336. */
  13337. repeatableContentBlocks: NodeMaterialBlock[];
  13338. /**
  13339. * List of blocks that can provide a dynamic list of uniforms
  13340. */
  13341. dynamicUniformBlocks: NodeMaterialBlock[];
  13342. /**
  13343. * List of blocks that can block the isReady function for the material
  13344. */
  13345. blockingBlocks: NodeMaterialBlock[];
  13346. /**
  13347. * Gets the list of animated inputs
  13348. */
  13349. animatedInputs: InputBlock[];
  13350. /**
  13351. * Build Id used to avoid multiple recompilations
  13352. */
  13353. buildId: number;
  13354. /** List of emitted variables */
  13355. variableNames: {
  13356. [key: string]: number;
  13357. };
  13358. /** List of emitted defines */
  13359. defineNames: {
  13360. [key: string]: number;
  13361. };
  13362. /** Should emit comments? */
  13363. emitComments: boolean;
  13364. /** Emit build activity */
  13365. verbose: boolean;
  13366. /** Gets or sets the hosting scene */
  13367. scene: Scene;
  13368. /**
  13369. * Gets the compilation hints emitted at compilation time
  13370. */
  13371. hints: {
  13372. needWorldViewMatrix: boolean;
  13373. needWorldViewProjectionMatrix: boolean;
  13374. needAlphaBlending: boolean;
  13375. needAlphaTesting: boolean;
  13376. };
  13377. /**
  13378. * List of compilation checks
  13379. */
  13380. checks: {
  13381. emitVertex: boolean;
  13382. emitFragment: boolean;
  13383. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13384. };
  13385. /**
  13386. * Is vertex program allowed to be empty?
  13387. */
  13388. allowEmptyVertexProgram: boolean;
  13389. /** Creates a new shared data */
  13390. constructor();
  13391. /**
  13392. * Emits console errors and exceptions if there is a failing check
  13393. */
  13394. emitErrors(): void;
  13395. }
  13396. }
  13397. declare module BABYLON {
  13398. /**
  13399. * Class used to store node based material build state
  13400. */
  13401. export class NodeMaterialBuildState {
  13402. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13403. supportUniformBuffers: boolean;
  13404. /**
  13405. * Gets the list of emitted attributes
  13406. */
  13407. attributes: string[];
  13408. /**
  13409. * Gets the list of emitted uniforms
  13410. */
  13411. uniforms: string[];
  13412. /**
  13413. * Gets the list of emitted constants
  13414. */
  13415. constants: string[];
  13416. /**
  13417. * Gets the list of emitted samplers
  13418. */
  13419. samplers: string[];
  13420. /**
  13421. * Gets the list of emitted functions
  13422. */
  13423. functions: {
  13424. [key: string]: string;
  13425. };
  13426. /**
  13427. * Gets the list of emitted extensions
  13428. */
  13429. extensions: {
  13430. [key: string]: string;
  13431. };
  13432. /**
  13433. * Gets the target of the compilation state
  13434. */
  13435. target: NodeMaterialBlockTargets;
  13436. /**
  13437. * Gets the list of emitted counters
  13438. */
  13439. counters: {
  13440. [key: string]: number;
  13441. };
  13442. /**
  13443. * Shared data between multiple NodeMaterialBuildState instances
  13444. */
  13445. sharedData: NodeMaterialBuildStateSharedData;
  13446. /** @hidden */
  13447. _vertexState: NodeMaterialBuildState;
  13448. /** @hidden */
  13449. _attributeDeclaration: string;
  13450. /** @hidden */
  13451. _uniformDeclaration: string;
  13452. /** @hidden */
  13453. _constantDeclaration: string;
  13454. /** @hidden */
  13455. _samplerDeclaration: string;
  13456. /** @hidden */
  13457. _varyingTransfer: string;
  13458. /** @hidden */
  13459. _injectAtEnd: string;
  13460. private _repeatableContentAnchorIndex;
  13461. /** @hidden */
  13462. _builtCompilationString: string;
  13463. /**
  13464. * Gets the emitted compilation strings
  13465. */
  13466. compilationString: string;
  13467. /**
  13468. * Finalize the compilation strings
  13469. * @param state defines the current compilation state
  13470. */
  13471. finalize(state: NodeMaterialBuildState): void;
  13472. /** @hidden */
  13473. get _repeatableContentAnchor(): string;
  13474. /** @hidden */
  13475. _getFreeVariableName(prefix: string): string;
  13476. /** @hidden */
  13477. _getFreeDefineName(prefix: string): string;
  13478. /** @hidden */
  13479. _excludeVariableName(name: string): void;
  13480. /** @hidden */
  13481. _emit2DSampler(name: string): void;
  13482. /** @hidden */
  13483. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13484. /** @hidden */
  13485. _emitExtension(name: string, extension: string, define?: string): void;
  13486. /** @hidden */
  13487. _emitFunction(name: string, code: string, comments: string): void;
  13488. /** @hidden */
  13489. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13490. replaceStrings?: {
  13491. search: RegExp;
  13492. replace: string;
  13493. }[];
  13494. repeatKey?: string;
  13495. }): string;
  13496. /** @hidden */
  13497. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13498. repeatKey?: string;
  13499. removeAttributes?: boolean;
  13500. removeUniforms?: boolean;
  13501. removeVaryings?: boolean;
  13502. removeIfDef?: boolean;
  13503. replaceStrings?: {
  13504. search: RegExp;
  13505. replace: string;
  13506. }[];
  13507. }, storeKey?: string): void;
  13508. /** @hidden */
  13509. _registerTempVariable(name: string): boolean;
  13510. /** @hidden */
  13511. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13512. /** @hidden */
  13513. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13514. /** @hidden */
  13515. _emitFloat(value: number): string;
  13516. }
  13517. }
  13518. declare module BABYLON {
  13519. /**
  13520. * Helper class used to generate session unique ID
  13521. */
  13522. export class UniqueIdGenerator {
  13523. private static _UniqueIdCounter;
  13524. /**
  13525. * Gets an unique (relatively to the current scene) Id
  13526. */
  13527. static get UniqueId(): number;
  13528. }
  13529. }
  13530. declare module BABYLON {
  13531. /**
  13532. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13533. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13534. */
  13535. export class EffectFallbacks implements IEffectFallbacks {
  13536. private _defines;
  13537. private _currentRank;
  13538. private _maxRank;
  13539. private _mesh;
  13540. /**
  13541. * Removes the fallback from the bound mesh.
  13542. */
  13543. unBindMesh(): void;
  13544. /**
  13545. * Adds a fallback on the specified property.
  13546. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13547. * @param define The name of the define in the shader
  13548. */
  13549. addFallback(rank: number, define: string): void;
  13550. /**
  13551. * Sets the mesh to use CPU skinning when needing to fallback.
  13552. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13553. * @param mesh The mesh to use the fallbacks.
  13554. */
  13555. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13556. /**
  13557. * Checks to see if more fallbacks are still availible.
  13558. */
  13559. get hasMoreFallbacks(): boolean;
  13560. /**
  13561. * Removes the defines that should be removed when falling back.
  13562. * @param currentDefines defines the current define statements for the shader.
  13563. * @param effect defines the current effect we try to compile
  13564. * @returns The resulting defines with defines of the current rank removed.
  13565. */
  13566. reduce(currentDefines: string, effect: Effect): string;
  13567. }
  13568. }
  13569. declare module BABYLON {
  13570. /**
  13571. * Defines a block that can be used inside a node based material
  13572. */
  13573. export class NodeMaterialBlock {
  13574. private _buildId;
  13575. private _buildTarget;
  13576. private _target;
  13577. private _isFinalMerger;
  13578. private _isInput;
  13579. private _name;
  13580. protected _isUnique: boolean;
  13581. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13582. inputsAreExclusive: boolean;
  13583. /** @hidden */
  13584. _codeVariableName: string;
  13585. /** @hidden */
  13586. _inputs: NodeMaterialConnectionPoint[];
  13587. /** @hidden */
  13588. _outputs: NodeMaterialConnectionPoint[];
  13589. /** @hidden */
  13590. _preparationId: number;
  13591. /** @hidden */
  13592. readonly _originalTargetIsNeutral: boolean;
  13593. /**
  13594. * Gets the name of the block
  13595. */
  13596. get name(): string;
  13597. /**
  13598. * Sets the name of the block. Will check if the name is valid.
  13599. */
  13600. set name(newName: string);
  13601. /**
  13602. * Gets or sets the unique id of the node
  13603. */
  13604. uniqueId: number;
  13605. /**
  13606. * Gets or sets the comments associated with this block
  13607. */
  13608. comments: string;
  13609. /**
  13610. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13611. */
  13612. get isUnique(): boolean;
  13613. /**
  13614. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13615. */
  13616. get isFinalMerger(): boolean;
  13617. /**
  13618. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13619. */
  13620. get isInput(): boolean;
  13621. /**
  13622. * Gets or sets the build Id
  13623. */
  13624. get buildId(): number;
  13625. set buildId(value: number);
  13626. /**
  13627. * Gets or sets the target of the block
  13628. */
  13629. get target(): NodeMaterialBlockTargets;
  13630. set target(value: NodeMaterialBlockTargets);
  13631. /**
  13632. * Gets the list of input points
  13633. */
  13634. get inputs(): NodeMaterialConnectionPoint[];
  13635. /** Gets the list of output points */
  13636. get outputs(): NodeMaterialConnectionPoint[];
  13637. /**
  13638. * Find an input by its name
  13639. * @param name defines the name of the input to look for
  13640. * @returns the input or null if not found
  13641. */
  13642. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13643. /**
  13644. * Find an output by its name
  13645. * @param name defines the name of the outputto look for
  13646. * @returns the output or null if not found
  13647. */
  13648. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13649. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13650. visibleInInspector: boolean;
  13651. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13652. visibleOnFrame: boolean;
  13653. /**
  13654. * Creates a new NodeMaterialBlock
  13655. * @param name defines the block name
  13656. * @param target defines the target of that block (Vertex by default)
  13657. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13658. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13659. */
  13660. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13661. /**
  13662. * Initialize the block and prepare the context for build
  13663. * @param state defines the state that will be used for the build
  13664. */
  13665. initialize(state: NodeMaterialBuildState): void;
  13666. /**
  13667. * Bind data to effect. Will only be called for blocks with isBindable === true
  13668. * @param effect defines the effect to bind data to
  13669. * @param nodeMaterial defines the hosting NodeMaterial
  13670. * @param mesh defines the mesh that will be rendered
  13671. * @param subMesh defines the submesh that will be rendered
  13672. */
  13673. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13674. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13675. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13676. protected _writeFloat(value: number): string;
  13677. /**
  13678. * Gets the current class name e.g. "NodeMaterialBlock"
  13679. * @returns the class name
  13680. */
  13681. getClassName(): string;
  13682. /**
  13683. * Register a new input. Must be called inside a block constructor
  13684. * @param name defines the connection point name
  13685. * @param type defines the connection point type
  13686. * @param isOptional defines a boolean indicating that this input can be omitted
  13687. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13688. * @param point an already created connection point. If not provided, create a new one
  13689. * @returns the current block
  13690. */
  13691. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13692. /**
  13693. * Register a new output. Must be called inside a block constructor
  13694. * @param name defines the connection point name
  13695. * @param type defines the connection point type
  13696. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13697. * @param point an already created connection point. If not provided, create a new one
  13698. * @returns the current block
  13699. */
  13700. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13701. /**
  13702. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13703. * @param forOutput defines an optional connection point to check compatibility with
  13704. * @returns the first available input or null
  13705. */
  13706. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13707. /**
  13708. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13709. * @param forBlock defines an optional block to check compatibility with
  13710. * @returns the first available input or null
  13711. */
  13712. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13713. /**
  13714. * Gets the sibling of the given output
  13715. * @param current defines the current output
  13716. * @returns the next output in the list or null
  13717. */
  13718. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13719. /**
  13720. * Connect current block with another block
  13721. * @param other defines the block to connect with
  13722. * @param options define the various options to help pick the right connections
  13723. * @returns the current block
  13724. */
  13725. connectTo(other: NodeMaterialBlock, options?: {
  13726. input?: string;
  13727. output?: string;
  13728. outputSwizzle?: string;
  13729. }): this | undefined;
  13730. protected _buildBlock(state: NodeMaterialBuildState): void;
  13731. /**
  13732. * Add uniforms, samplers and uniform buffers at compilation time
  13733. * @param state defines the state to update
  13734. * @param nodeMaterial defines the node material requesting the update
  13735. * @param defines defines the material defines to update
  13736. * @param uniformBuffers defines the list of uniform buffer names
  13737. */
  13738. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13739. /**
  13740. * Add potential fallbacks if shader compilation fails
  13741. * @param mesh defines the mesh to be rendered
  13742. * @param fallbacks defines the current prioritized list of fallbacks
  13743. */
  13744. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13745. /**
  13746. * Initialize defines for shader compilation
  13747. * @param mesh defines the mesh to be rendered
  13748. * @param nodeMaterial defines the node material requesting the update
  13749. * @param defines defines the material defines to update
  13750. * @param useInstances specifies that instances should be used
  13751. */
  13752. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13753. /**
  13754. * Update defines for shader compilation
  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. * @param subMesh defines which submesh to render
  13760. */
  13761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13762. /**
  13763. * Lets the block try to connect some inputs automatically
  13764. * @param material defines the hosting NodeMaterial
  13765. */
  13766. autoConfigure(material: NodeMaterial): void;
  13767. /**
  13768. * Function called when a block is declared as repeatable content generator
  13769. * @param vertexShaderState defines the current compilation state for the vertex shader
  13770. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13771. * @param mesh defines the mesh to be rendered
  13772. * @param defines defines the material defines to update
  13773. */
  13774. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13775. /**
  13776. * Checks if the block is ready
  13777. * @param mesh defines the mesh to be rendered
  13778. * @param nodeMaterial defines the node material requesting the update
  13779. * @param defines defines the material defines to update
  13780. * @param useInstances specifies that instances should be used
  13781. * @returns true if the block is ready
  13782. */
  13783. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13784. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13785. private _processBuild;
  13786. /**
  13787. * Validates the new name for the block node.
  13788. * @param newName the new name to be given to the node.
  13789. * @returns false if the name is a reserve word, else true.
  13790. */
  13791. validateBlockName(newName: string): boolean;
  13792. /**
  13793. * Compile the current node and generate the shader code
  13794. * @param state defines the current compilation state (uniforms, samplers, current string)
  13795. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13796. * @returns true if already built
  13797. */
  13798. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13799. protected _inputRename(name: string): string;
  13800. protected _outputRename(name: string): string;
  13801. protected _dumpPropertiesCode(): string;
  13802. /** @hidden */
  13803. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13804. /** @hidden */
  13805. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13806. /**
  13807. * Clone the current block to a new identical block
  13808. * @param scene defines the hosting scene
  13809. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13810. * @returns a copy of the current block
  13811. */
  13812. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13813. /**
  13814. * Serializes this block in a JSON representation
  13815. * @returns the serialized block object
  13816. */
  13817. serialize(): any;
  13818. /** @hidden */
  13819. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13820. private _deserializePortDisplayNamesAndExposedOnFrame;
  13821. /**
  13822. * Release resources
  13823. */
  13824. dispose(): void;
  13825. }
  13826. }
  13827. declare module BABYLON {
  13828. /**
  13829. * Base class of materials working in push mode in babylon JS
  13830. * @hidden
  13831. */
  13832. export class PushMaterial extends Material {
  13833. protected _activeEffect: Effect;
  13834. protected _normalMatrix: Matrix;
  13835. constructor(name: string, scene: Scene);
  13836. getEffect(): Effect;
  13837. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13838. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13839. /**
  13840. * Binds the given world matrix to the active effect
  13841. *
  13842. * @param world the matrix to bind
  13843. */
  13844. bindOnlyWorldMatrix(world: Matrix): void;
  13845. /**
  13846. * Binds the given normal matrix to the active effect
  13847. *
  13848. * @param normalMatrix the matrix to bind
  13849. */
  13850. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13851. bind(world: Matrix, mesh?: Mesh): void;
  13852. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13853. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13854. }
  13855. }
  13856. declare module BABYLON {
  13857. /**
  13858. * Root class for all node material optimizers
  13859. */
  13860. export class NodeMaterialOptimizer {
  13861. /**
  13862. * Function used to optimize a NodeMaterial graph
  13863. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13864. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13865. */
  13866. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13867. }
  13868. }
  13869. declare module BABYLON {
  13870. /**
  13871. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13872. */
  13873. export class TransformBlock extends NodeMaterialBlock {
  13874. /**
  13875. * Defines the value to use to complement W value to transform it to a Vector4
  13876. */
  13877. complementW: number;
  13878. /**
  13879. * Defines the value to use to complement z value to transform it to a Vector4
  13880. */
  13881. complementZ: number;
  13882. /**
  13883. * Creates a new TransformBlock
  13884. * @param name defines the block name
  13885. */
  13886. constructor(name: string);
  13887. /**
  13888. * Gets the current class name
  13889. * @returns the class name
  13890. */
  13891. getClassName(): string;
  13892. /**
  13893. * Gets the vector input
  13894. */
  13895. get vector(): NodeMaterialConnectionPoint;
  13896. /**
  13897. * Gets the output component
  13898. */
  13899. get output(): NodeMaterialConnectionPoint;
  13900. /**
  13901. * Gets the xyz output component
  13902. */
  13903. get xyz(): NodeMaterialConnectionPoint;
  13904. /**
  13905. * Gets the matrix transform input
  13906. */
  13907. get transform(): NodeMaterialConnectionPoint;
  13908. protected _buildBlock(state: NodeMaterialBuildState): this;
  13909. /**
  13910. * Update defines for shader compilation
  13911. * @param mesh defines the mesh to be rendered
  13912. * @param nodeMaterial defines the node material requesting the update
  13913. * @param defines defines the material defines to update
  13914. * @param useInstances specifies that instances should be used
  13915. * @param subMesh defines which submesh to render
  13916. */
  13917. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13918. serialize(): any;
  13919. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13920. protected _dumpPropertiesCode(): string;
  13921. }
  13922. }
  13923. declare module BABYLON {
  13924. /**
  13925. * Block used to output the vertex position
  13926. */
  13927. export class VertexOutputBlock extends NodeMaterialBlock {
  13928. /**
  13929. * Creates a new VertexOutputBlock
  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 vector input component
  13940. */
  13941. get vector(): NodeMaterialConnectionPoint;
  13942. protected _buildBlock(state: NodeMaterialBuildState): this;
  13943. }
  13944. }
  13945. declare module BABYLON {
  13946. /**
  13947. * Block used to output the final color
  13948. */
  13949. export class FragmentOutputBlock extends NodeMaterialBlock {
  13950. /**
  13951. * Create a new FragmentOutputBlock
  13952. * @param name defines the block name
  13953. */
  13954. constructor(name: string);
  13955. /**
  13956. * Gets the current class name
  13957. * @returns the class name
  13958. */
  13959. getClassName(): string;
  13960. /**
  13961. * Gets the rgba input component
  13962. */
  13963. get rgba(): NodeMaterialConnectionPoint;
  13964. /**
  13965. * Gets the rgb input component
  13966. */
  13967. get rgb(): NodeMaterialConnectionPoint;
  13968. /**
  13969. * Gets the a input component
  13970. */
  13971. get a(): NodeMaterialConnectionPoint;
  13972. protected _buildBlock(state: NodeMaterialBuildState): this;
  13973. }
  13974. }
  13975. declare module BABYLON {
  13976. /**
  13977. * Block used for the particle ramp gradient section
  13978. */
  13979. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13980. /**
  13981. * Create a new ParticleRampGradientBlock
  13982. * @param name defines the block name
  13983. */
  13984. constructor(name: string);
  13985. /**
  13986. * Gets the current class name
  13987. * @returns the class name
  13988. */
  13989. getClassName(): string;
  13990. /**
  13991. * Gets the color input component
  13992. */
  13993. get color(): NodeMaterialConnectionPoint;
  13994. /**
  13995. * Gets the rampColor output component
  13996. */
  13997. get rampColor(): NodeMaterialConnectionPoint;
  13998. /**
  13999. * Initialize the block and prepare the context for build
  14000. * @param state defines the state that will be used for the build
  14001. */
  14002. initialize(state: NodeMaterialBuildState): void;
  14003. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14004. }
  14005. }
  14006. declare module BABYLON {
  14007. /**
  14008. * Block used for the particle blend multiply section
  14009. */
  14010. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14011. /**
  14012. * Create a new ParticleBlendMultiplyBlock
  14013. * @param name defines the block name
  14014. */
  14015. constructor(name: string);
  14016. /**
  14017. * Gets the current class name
  14018. * @returns the class name
  14019. */
  14020. getClassName(): string;
  14021. /**
  14022. * Gets the color input component
  14023. */
  14024. get color(): NodeMaterialConnectionPoint;
  14025. /**
  14026. * Gets the alphaTexture input component
  14027. */
  14028. get alphaTexture(): NodeMaterialConnectionPoint;
  14029. /**
  14030. * Gets the alphaColor input component
  14031. */
  14032. get alphaColor(): NodeMaterialConnectionPoint;
  14033. /**
  14034. * Gets the blendColor output component
  14035. */
  14036. get blendColor(): NodeMaterialConnectionPoint;
  14037. /**
  14038. * Initialize the block and prepare the context for build
  14039. * @param state defines the state that will be used for the build
  14040. */
  14041. initialize(state: NodeMaterialBuildState): void;
  14042. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14043. }
  14044. }
  14045. declare module BABYLON {
  14046. /**
  14047. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14048. */
  14049. export class VectorMergerBlock extends NodeMaterialBlock {
  14050. /**
  14051. * Create a new VectorMergerBlock
  14052. * @param name defines the block name
  14053. */
  14054. constructor(name: string);
  14055. /**
  14056. * Gets the current class name
  14057. * @returns the class name
  14058. */
  14059. getClassName(): string;
  14060. /**
  14061. * Gets the xyz component (input)
  14062. */
  14063. get xyzIn(): NodeMaterialConnectionPoint;
  14064. /**
  14065. * Gets the xy component (input)
  14066. */
  14067. get xyIn(): NodeMaterialConnectionPoint;
  14068. /**
  14069. * Gets the x component (input)
  14070. */
  14071. get x(): NodeMaterialConnectionPoint;
  14072. /**
  14073. * Gets the y component (input)
  14074. */
  14075. get y(): NodeMaterialConnectionPoint;
  14076. /**
  14077. * Gets the z component (input)
  14078. */
  14079. get z(): NodeMaterialConnectionPoint;
  14080. /**
  14081. * Gets the w component (input)
  14082. */
  14083. get w(): NodeMaterialConnectionPoint;
  14084. /**
  14085. * Gets the xyzw component (output)
  14086. */
  14087. get xyzw(): NodeMaterialConnectionPoint;
  14088. /**
  14089. * Gets the xyz component (output)
  14090. */
  14091. get xyzOut(): NodeMaterialConnectionPoint;
  14092. /**
  14093. * Gets the xy component (output)
  14094. */
  14095. get xyOut(): NodeMaterialConnectionPoint;
  14096. /**
  14097. * Gets the xy component (output)
  14098. * @deprecated Please use xyOut instead.
  14099. */
  14100. get xy(): NodeMaterialConnectionPoint;
  14101. /**
  14102. * Gets the xyz component (output)
  14103. * @deprecated Please use xyzOut instead.
  14104. */
  14105. get xyz(): NodeMaterialConnectionPoint;
  14106. protected _buildBlock(state: NodeMaterialBuildState): this;
  14107. }
  14108. }
  14109. declare module BABYLON {
  14110. /**
  14111. * Block used to remap a float from a range to a new one
  14112. */
  14113. export class RemapBlock extends NodeMaterialBlock {
  14114. /**
  14115. * Gets or sets the source range
  14116. */
  14117. sourceRange: Vector2;
  14118. /**
  14119. * Gets or sets the target range
  14120. */
  14121. targetRange: Vector2;
  14122. /**
  14123. * Creates a new RemapBlock
  14124. * @param name defines the block name
  14125. */
  14126. constructor(name: string);
  14127. /**
  14128. * Gets the current class name
  14129. * @returns the class name
  14130. */
  14131. getClassName(): string;
  14132. /**
  14133. * Gets the input component
  14134. */
  14135. get input(): NodeMaterialConnectionPoint;
  14136. /**
  14137. * Gets the source min input component
  14138. */
  14139. get sourceMin(): NodeMaterialConnectionPoint;
  14140. /**
  14141. * Gets the source max input component
  14142. */
  14143. get sourceMax(): NodeMaterialConnectionPoint;
  14144. /**
  14145. * Gets the target min input component
  14146. */
  14147. get targetMin(): NodeMaterialConnectionPoint;
  14148. /**
  14149. * Gets the target max input component
  14150. */
  14151. get targetMax(): NodeMaterialConnectionPoint;
  14152. /**
  14153. * Gets the output component
  14154. */
  14155. get output(): NodeMaterialConnectionPoint;
  14156. protected _buildBlock(state: NodeMaterialBuildState): this;
  14157. protected _dumpPropertiesCode(): string;
  14158. serialize(): any;
  14159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14160. }
  14161. }
  14162. declare module BABYLON {
  14163. /**
  14164. * Block used to multiply 2 values
  14165. */
  14166. export class MultiplyBlock extends NodeMaterialBlock {
  14167. /**
  14168. * Creates a new MultiplyBlock
  14169. * @param name defines the block name
  14170. */
  14171. constructor(name: string);
  14172. /**
  14173. * Gets the current class name
  14174. * @returns the class name
  14175. */
  14176. getClassName(): string;
  14177. /**
  14178. * Gets the left operand input component
  14179. */
  14180. get left(): NodeMaterialConnectionPoint;
  14181. /**
  14182. * Gets the right operand input component
  14183. */
  14184. get right(): NodeMaterialConnectionPoint;
  14185. /**
  14186. * Gets the output component
  14187. */
  14188. get output(): NodeMaterialConnectionPoint;
  14189. protected _buildBlock(state: NodeMaterialBuildState): this;
  14190. }
  14191. }
  14192. declare module BABYLON {
  14193. /** Interface used by value gradients (color, factor, ...) */
  14194. export interface IValueGradient {
  14195. /**
  14196. * Gets or sets the gradient value (between 0 and 1)
  14197. */
  14198. gradient: number;
  14199. }
  14200. /** Class used to store color4 gradient */
  14201. export class ColorGradient implements IValueGradient {
  14202. /**
  14203. * Gets or sets the gradient value (between 0 and 1)
  14204. */
  14205. gradient: number;
  14206. /**
  14207. * Gets or sets first associated color
  14208. */
  14209. color1: Color4;
  14210. /**
  14211. * Gets or sets second associated color
  14212. */
  14213. color2?: Color4 | undefined;
  14214. /**
  14215. * Creates a new color4 gradient
  14216. * @param gradient gets or sets the gradient value (between 0 and 1)
  14217. * @param color1 gets or sets first associated color
  14218. * @param color2 gets or sets first second color
  14219. */
  14220. constructor(
  14221. /**
  14222. * Gets or sets the gradient value (between 0 and 1)
  14223. */
  14224. gradient: number,
  14225. /**
  14226. * Gets or sets first associated color
  14227. */
  14228. color1: Color4,
  14229. /**
  14230. * Gets or sets second associated color
  14231. */
  14232. color2?: Color4 | undefined);
  14233. /**
  14234. * Will get a color picked randomly between color1 and color2.
  14235. * If color2 is undefined then color1 will be used
  14236. * @param result defines the target Color4 to store the result in
  14237. */
  14238. getColorToRef(result: Color4): void;
  14239. }
  14240. /** Class used to store color 3 gradient */
  14241. export class Color3Gradient implements IValueGradient {
  14242. /**
  14243. * Gets or sets the gradient value (between 0 and 1)
  14244. */
  14245. gradient: number;
  14246. /**
  14247. * Gets or sets the associated color
  14248. */
  14249. color: Color3;
  14250. /**
  14251. * Creates a new color3 gradient
  14252. * @param gradient gets or sets the gradient value (between 0 and 1)
  14253. * @param color gets or sets associated color
  14254. */
  14255. constructor(
  14256. /**
  14257. * Gets or sets the gradient value (between 0 and 1)
  14258. */
  14259. gradient: number,
  14260. /**
  14261. * Gets or sets the associated color
  14262. */
  14263. color: Color3);
  14264. }
  14265. /** Class used to store factor gradient */
  14266. export class FactorGradient implements IValueGradient {
  14267. /**
  14268. * Gets or sets the gradient value (between 0 and 1)
  14269. */
  14270. gradient: number;
  14271. /**
  14272. * Gets or sets first associated factor
  14273. */
  14274. factor1: number;
  14275. /**
  14276. * Gets or sets second associated factor
  14277. */
  14278. factor2?: number | undefined;
  14279. /**
  14280. * Creates a new factor gradient
  14281. * @param gradient gets or sets the gradient value (between 0 and 1)
  14282. * @param factor1 gets or sets first associated factor
  14283. * @param factor2 gets or sets second associated factor
  14284. */
  14285. constructor(
  14286. /**
  14287. * Gets or sets the gradient value (between 0 and 1)
  14288. */
  14289. gradient: number,
  14290. /**
  14291. * Gets or sets first associated factor
  14292. */
  14293. factor1: number,
  14294. /**
  14295. * Gets or sets second associated factor
  14296. */
  14297. factor2?: number | undefined);
  14298. /**
  14299. * Will get a number picked randomly between factor1 and factor2.
  14300. * If factor2 is undefined then factor1 will be used
  14301. * @returns the picked number
  14302. */
  14303. getFactor(): number;
  14304. }
  14305. /**
  14306. * Helper used to simplify some generic gradient tasks
  14307. */
  14308. export class GradientHelper {
  14309. /**
  14310. * Gets the current gradient from an array of IValueGradient
  14311. * @param ratio defines the current ratio to get
  14312. * @param gradients defines the array of IValueGradient
  14313. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14314. */
  14315. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14316. }
  14317. }
  14318. declare module BABYLON {
  14319. interface ThinEngine {
  14320. /**
  14321. * Creates a raw texture
  14322. * @param data defines the data to store in the texture
  14323. * @param width defines the width of the texture
  14324. * @param height defines the height of the texture
  14325. * @param format defines the format of the data
  14326. * @param generateMipMaps defines if the engine should generate the mip levels
  14327. * @param invertY defines if data must be stored with Y axis inverted
  14328. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14329. * @param compression defines the compression used (null by default)
  14330. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14331. * @returns the raw texture inside an InternalTexture
  14332. */
  14333. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14334. /**
  14335. * Update a raw texture
  14336. * @param texture defines the texture to update
  14337. * @param data defines the data to store in the texture
  14338. * @param format defines the format of the data
  14339. * @param invertY defines if data must be stored with Y axis inverted
  14340. */
  14341. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14342. /**
  14343. * Update a raw texture
  14344. * @param texture defines the texture to update
  14345. * @param data defines the data to store in the texture
  14346. * @param format defines the format of the data
  14347. * @param invertY defines if data must be stored with Y axis inverted
  14348. * @param compression defines the compression used (null by default)
  14349. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14350. */
  14351. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14352. /**
  14353. * Creates a new raw cube texture
  14354. * @param data defines the array of data to use to create each face
  14355. * @param size defines the size of the textures
  14356. * @param format defines the format of the data
  14357. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14358. * @param generateMipMaps defines if the engine should generate the mip levels
  14359. * @param invertY defines if data must be stored with Y axis inverted
  14360. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14361. * @param compression defines the compression used (null by default)
  14362. * @returns the cube texture as an InternalTexture
  14363. */
  14364. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14365. /**
  14366. * Update a raw cube texture
  14367. * @param texture defines the texture to udpdate
  14368. * @param data defines the data to store
  14369. * @param format defines the data format
  14370. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14371. * @param invertY defines if data must be stored with Y axis inverted
  14372. */
  14373. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14374. /**
  14375. * Update a raw cube texture
  14376. * @param texture defines the texture to udpdate
  14377. * @param data defines the data to store
  14378. * @param format defines the data format
  14379. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14380. * @param invertY defines if data must be stored with Y axis inverted
  14381. * @param compression defines the compression used (null by default)
  14382. */
  14383. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14384. /**
  14385. * Update a raw cube texture
  14386. * @param texture defines the texture to udpdate
  14387. * @param data defines the data to store
  14388. * @param format defines the data format
  14389. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14390. * @param invertY defines if data must be stored with Y axis inverted
  14391. * @param compression defines the compression used (null by default)
  14392. * @param level defines which level of the texture to update
  14393. */
  14394. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14395. /**
  14396. * Creates a new raw cube texture from a specified url
  14397. * @param url defines the url where the data is located
  14398. * @param scene defines the current scene
  14399. * @param size defines the size of the textures
  14400. * @param format defines the format of the data
  14401. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14402. * @param noMipmap defines if the engine should avoid generating the mip levels
  14403. * @param callback defines a callback used to extract texture data from loaded data
  14404. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14405. * @param onLoad defines a callback called when texture is loaded
  14406. * @param onError defines a callback called if there is an error
  14407. * @returns the cube texture as an InternalTexture
  14408. */
  14409. 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;
  14410. /**
  14411. * Creates a new raw cube texture from a specified url
  14412. * @param url defines the url where the data is located
  14413. * @param scene defines the current scene
  14414. * @param size defines the size of the textures
  14415. * @param format defines the format of the data
  14416. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14417. * @param noMipmap defines if the engine should avoid generating the mip levels
  14418. * @param callback defines a callback used to extract texture data from loaded data
  14419. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14420. * @param onLoad defines a callback called when texture is loaded
  14421. * @param onError defines a callback called if there is an error
  14422. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14423. * @param invertY defines if data must be stored with Y axis inverted
  14424. * @returns the cube texture as an InternalTexture
  14425. */
  14426. 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;
  14427. /**
  14428. * Creates a new raw 3D texture
  14429. * @param data defines the data used to create the texture
  14430. * @param width defines the width of the texture
  14431. * @param height defines the height of the texture
  14432. * @param depth defines the depth of the texture
  14433. * @param format defines the format of the texture
  14434. * @param generateMipMaps defines if the engine must generate mip levels
  14435. * @param invertY defines if data must be stored with Y axis inverted
  14436. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14437. * @param compression defines the compressed used (can be null)
  14438. * @param textureType defines the compressed used (can be null)
  14439. * @returns a new raw 3D texture (stored in an InternalTexture)
  14440. */
  14441. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14442. /**
  14443. * Update a raw 3D texture
  14444. * @param texture defines the texture to update
  14445. * @param data defines the data to store
  14446. * @param format defines the data format
  14447. * @param invertY defines if data must be stored with Y axis inverted
  14448. */
  14449. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14450. /**
  14451. * Update a raw 3D texture
  14452. * @param texture defines the texture to update
  14453. * @param data defines the data to store
  14454. * @param format defines the data format
  14455. * @param invertY defines if data must be stored with Y axis inverted
  14456. * @param compression defines the used compression (can be null)
  14457. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14458. */
  14459. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14460. /**
  14461. * Creates a new raw 2D array texture
  14462. * @param data defines the data used to create the texture
  14463. * @param width defines the width of the texture
  14464. * @param height defines the height of the texture
  14465. * @param depth defines the number of layers of the texture
  14466. * @param format defines the format of the texture
  14467. * @param generateMipMaps defines if the engine must generate mip levels
  14468. * @param invertY defines if data must be stored with Y axis inverted
  14469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14470. * @param compression defines the compressed used (can be null)
  14471. * @param textureType defines the compressed used (can be null)
  14472. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14473. */
  14474. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14475. /**
  14476. * Update a raw 2D array texture
  14477. * @param texture defines the texture to update
  14478. * @param data defines the data to store
  14479. * @param format defines the data format
  14480. * @param invertY defines if data must be stored with Y axis inverted
  14481. */
  14482. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14483. /**
  14484. * Update a raw 2D array texture
  14485. * @param texture defines the texture to update
  14486. * @param data defines the data to store
  14487. * @param format defines the data format
  14488. * @param invertY defines if data must be stored with Y axis inverted
  14489. * @param compression defines the used compression (can be null)
  14490. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14491. */
  14492. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14493. }
  14494. }
  14495. declare module BABYLON {
  14496. /**
  14497. * Raw texture can help creating a texture directly from an array of data.
  14498. * This can be super useful if you either get the data from an uncompressed source or
  14499. * if you wish to create your texture pixel by pixel.
  14500. */
  14501. export class RawTexture extends Texture {
  14502. /**
  14503. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14504. */
  14505. format: number;
  14506. /**
  14507. * Instantiates a new RawTexture.
  14508. * Raw texture can help creating a texture directly from an array of data.
  14509. * This can be super useful if you either get the data from an uncompressed source or
  14510. * if you wish to create your texture pixel by pixel.
  14511. * @param data define the array of data to use to create the texture
  14512. * @param width define the width of the texture
  14513. * @param height define the height of the texture
  14514. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14515. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14516. * @param generateMipMaps define whether mip maps should be generated or not
  14517. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14518. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14519. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14520. */
  14521. constructor(data: ArrayBufferView, width: number, height: number,
  14522. /**
  14523. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14524. */
  14525. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14526. /**
  14527. * Updates the texture underlying data.
  14528. * @param data Define the new data of the texture
  14529. */
  14530. update(data: ArrayBufferView): void;
  14531. /**
  14532. * Creates a luminance texture from some data.
  14533. * @param data Define the texture data
  14534. * @param width Define the width of the texture
  14535. * @param height Define the height of the texture
  14536. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14537. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14538. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14539. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14540. * @returns the luminance texture
  14541. */
  14542. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14543. /**
  14544. * Creates a luminance alpha texture from some data.
  14545. * @param data Define the texture data
  14546. * @param width Define the width of the texture
  14547. * @param height Define the height of the texture
  14548. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14549. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14550. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14551. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14552. * @returns the luminance alpha texture
  14553. */
  14554. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14555. /**
  14556. * Creates an alpha texture from some data.
  14557. * @param data Define the texture data
  14558. * @param width Define the width of the texture
  14559. * @param height Define the height of the texture
  14560. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14561. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14562. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14563. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14564. * @returns the alpha texture
  14565. */
  14566. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14567. /**
  14568. * Creates a RGB texture from some data.
  14569. * @param data Define the texture data
  14570. * @param width Define the width of the texture
  14571. * @param height Define the height of the texture
  14572. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14573. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14574. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14575. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14576. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14577. * @returns the RGB alpha texture
  14578. */
  14579. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14580. /**
  14581. * Creates a RGBA texture from some data.
  14582. * @param data Define the texture data
  14583. * @param width Define the width of the texture
  14584. * @param height Define the height of the texture
  14585. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14586. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14587. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14588. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14589. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14590. * @returns the RGBA texture
  14591. */
  14592. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14593. /**
  14594. * Creates a R texture from some data.
  14595. * @param data Define the texture data
  14596. * @param width Define the width of the texture
  14597. * @param height Define the height of the texture
  14598. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14599. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14600. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14601. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14602. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14603. * @returns the R texture
  14604. */
  14605. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14606. }
  14607. }
  14608. declare module BABYLON {
  14609. interface ThinEngine {
  14610. /**
  14611. * Update a dynamic index buffer
  14612. * @param indexBuffer defines the target index buffer
  14613. * @param indices defines the data to update
  14614. * @param offset defines the offset in the target index buffer where update should start
  14615. */
  14616. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14617. /**
  14618. * Updates a dynamic vertex buffer.
  14619. * @param vertexBuffer the vertex buffer to update
  14620. * @param data the data used to update the vertex buffer
  14621. * @param byteOffset the byte offset of the data
  14622. * @param byteLength the byte length of the data
  14623. */
  14624. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14625. }
  14626. }
  14627. declare module BABYLON {
  14628. interface AbstractScene {
  14629. /**
  14630. * The list of procedural textures added to the scene
  14631. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14632. */
  14633. proceduralTextures: Array<ProceduralTexture>;
  14634. }
  14635. /**
  14636. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14637. * in a given scene.
  14638. */
  14639. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14640. /**
  14641. * The component name helpfull to identify the component in the list of scene components.
  14642. */
  14643. readonly name: string;
  14644. /**
  14645. * The scene the component belongs to.
  14646. */
  14647. scene: Scene;
  14648. /**
  14649. * Creates a new instance of the component for the given scene
  14650. * @param scene Defines the scene to register the component in
  14651. */
  14652. constructor(scene: Scene);
  14653. /**
  14654. * Registers the component in a given scene
  14655. */
  14656. register(): void;
  14657. /**
  14658. * Rebuilds the elements related to this component in case of
  14659. * context lost for instance.
  14660. */
  14661. rebuild(): void;
  14662. /**
  14663. * Disposes the component and the associated ressources.
  14664. */
  14665. dispose(): void;
  14666. private _beforeClear;
  14667. }
  14668. }
  14669. declare module BABYLON {
  14670. interface ThinEngine {
  14671. /**
  14672. * Creates a new render target cube texture
  14673. * @param size defines the size of the texture
  14674. * @param options defines the options used to create the texture
  14675. * @returns a new render target cube texture stored in an InternalTexture
  14676. */
  14677. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14678. }
  14679. }
  14680. declare module BABYLON {
  14681. /** @hidden */
  14682. export var proceduralVertexShader: {
  14683. name: string;
  14684. shader: string;
  14685. };
  14686. }
  14687. declare module BABYLON {
  14688. /**
  14689. * 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.
  14690. * This is the base class of any Procedural texture and contains most of the shareable code.
  14691. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14692. */
  14693. export class ProceduralTexture extends Texture {
  14694. /**
  14695. * Define if the texture is enabled or not (disabled texture will not render)
  14696. */
  14697. isEnabled: boolean;
  14698. /**
  14699. * Define if the texture must be cleared before rendering (default is true)
  14700. */
  14701. autoClear: boolean;
  14702. /**
  14703. * Callback called when the texture is generated
  14704. */
  14705. onGenerated: () => void;
  14706. /**
  14707. * Event raised when the texture is generated
  14708. */
  14709. onGeneratedObservable: Observable<ProceduralTexture>;
  14710. /**
  14711. * Event raised before the texture is generated
  14712. */
  14713. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14714. /**
  14715. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14716. */
  14717. nodeMaterialSource: Nullable<NodeMaterial>;
  14718. /** @hidden */
  14719. _generateMipMaps: boolean;
  14720. /** @hidden **/
  14721. _effect: Effect;
  14722. /** @hidden */
  14723. _textures: {
  14724. [key: string]: Texture;
  14725. };
  14726. /** @hidden */
  14727. protected _fallbackTexture: Nullable<Texture>;
  14728. private _size;
  14729. private _textureType;
  14730. private _currentRefreshId;
  14731. private _frameId;
  14732. private _refreshRate;
  14733. private _vertexBuffers;
  14734. private _indexBuffer;
  14735. private _uniforms;
  14736. private _samplers;
  14737. private _fragment;
  14738. private _floats;
  14739. private _ints;
  14740. private _floatsArrays;
  14741. private _colors3;
  14742. private _colors4;
  14743. private _vectors2;
  14744. private _vectors3;
  14745. private _matrices;
  14746. private _fallbackTextureUsed;
  14747. private _fullEngine;
  14748. private _cachedDefines;
  14749. private _contentUpdateId;
  14750. private _contentData;
  14751. /**
  14752. * Instantiates a new procedural texture.
  14753. * 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.
  14754. * This is the base class of any Procedural texture and contains most of the shareable code.
  14755. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14756. * @param name Define the name of the texture
  14757. * @param size Define the size of the texture to create
  14758. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14759. * @param scene Define the scene the texture belongs to
  14760. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14761. * @param generateMipMaps Define if the texture should creates mip maps or not
  14762. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14763. * @param textureType The FBO internal texture type
  14764. */
  14765. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14766. /**
  14767. * The effect that is created when initializing the post process.
  14768. * @returns The created effect corresponding the the postprocess.
  14769. */
  14770. getEffect(): Effect;
  14771. /**
  14772. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14773. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14774. */
  14775. getContent(): Nullable<Promise<ArrayBufferView>>;
  14776. private _createIndexBuffer;
  14777. /** @hidden */
  14778. _rebuild(): void;
  14779. /**
  14780. * Resets the texture in order to recreate its associated resources.
  14781. * This can be called in case of context loss
  14782. */
  14783. reset(): void;
  14784. protected _getDefines(): string;
  14785. /**
  14786. * Is the texture ready to be used ? (rendered at least once)
  14787. * @returns true if ready, otherwise, false.
  14788. */
  14789. isReady(): boolean;
  14790. /**
  14791. * Resets the refresh counter of the texture and start bak from scratch.
  14792. * Could be useful to regenerate the texture if it is setup to render only once.
  14793. */
  14794. resetRefreshCounter(): void;
  14795. /**
  14796. * Set the fragment shader to use in order to render the texture.
  14797. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14798. */
  14799. setFragment(fragment: any): void;
  14800. /**
  14801. * Define the refresh rate of the texture or the rendering frequency.
  14802. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14803. */
  14804. get refreshRate(): number;
  14805. set refreshRate(value: number);
  14806. /** @hidden */
  14807. _shouldRender(): boolean;
  14808. /**
  14809. * Get the size the texture is rendering at.
  14810. * @returns the size (on cube texture it is always squared)
  14811. */
  14812. getRenderSize(): RenderTargetTextureSize;
  14813. /**
  14814. * Resize the texture to new value.
  14815. * @param size Define the new size the texture should have
  14816. * @param generateMipMaps Define whether the new texture should create mip maps
  14817. */
  14818. resize(size: number, generateMipMaps: boolean): void;
  14819. private _checkUniform;
  14820. /**
  14821. * Set a texture in the shader program used to render.
  14822. * @param name Define the name of the uniform samplers as defined in the shader
  14823. * @param texture Define the texture to bind to this sampler
  14824. * @return the texture itself allowing "fluent" like uniform updates
  14825. */
  14826. setTexture(name: string, texture: Texture): ProceduralTexture;
  14827. /**
  14828. * Set a float in the shader.
  14829. * @param name Define the name of the uniform as defined in the shader
  14830. * @param value Define the value to give to the uniform
  14831. * @return the texture itself allowing "fluent" like uniform updates
  14832. */
  14833. setFloat(name: string, value: number): ProceduralTexture;
  14834. /**
  14835. * Set a int in the shader.
  14836. * @param name Define the name of the uniform as defined in the shader
  14837. * @param value Define the value to give to the uniform
  14838. * @return the texture itself allowing "fluent" like uniform updates
  14839. */
  14840. setInt(name: string, value: number): ProceduralTexture;
  14841. /**
  14842. * Set an array of floats in the shader.
  14843. * @param name Define the name of the uniform as defined in the shader
  14844. * @param value Define the value to give to the uniform
  14845. * @return the texture itself allowing "fluent" like uniform updates
  14846. */
  14847. setFloats(name: string, value: number[]): ProceduralTexture;
  14848. /**
  14849. * Set a vec3 in the shader from a Color3.
  14850. * @param name Define the name of the uniform as defined in the shader
  14851. * @param value Define the value to give to the uniform
  14852. * @return the texture itself allowing "fluent" like uniform updates
  14853. */
  14854. setColor3(name: string, value: Color3): ProceduralTexture;
  14855. /**
  14856. * Set a vec4 in the shader from a Color4.
  14857. * @param name Define the name of the uniform as defined in the shader
  14858. * @param value Define the value to give to the uniform
  14859. * @return the texture itself allowing "fluent" like uniform updates
  14860. */
  14861. setColor4(name: string, value: Color4): ProceduralTexture;
  14862. /**
  14863. * Set a vec2 in the shader from a Vector2.
  14864. * @param name Define the name of the uniform as defined in the shader
  14865. * @param value Define the value to give to the uniform
  14866. * @return the texture itself allowing "fluent" like uniform updates
  14867. */
  14868. setVector2(name: string, value: Vector2): ProceduralTexture;
  14869. /**
  14870. * Set a vec3 in the shader from a Vector3.
  14871. * @param name Define the name of the uniform as defined in the shader
  14872. * @param value Define the value to give to the uniform
  14873. * @return the texture itself allowing "fluent" like uniform updates
  14874. */
  14875. setVector3(name: string, value: Vector3): ProceduralTexture;
  14876. /**
  14877. * Set a mat4 in the shader from a MAtrix.
  14878. * @param name Define the name of the uniform as defined in the shader
  14879. * @param value Define the value to give to the uniform
  14880. * @return the texture itself allowing "fluent" like uniform updates
  14881. */
  14882. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14883. /**
  14884. * Render the texture to its associated render target.
  14885. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14886. */
  14887. render(useCameraPostProcess?: boolean): void;
  14888. /**
  14889. * Clone the texture.
  14890. * @returns the cloned texture
  14891. */
  14892. clone(): ProceduralTexture;
  14893. /**
  14894. * Dispose the texture and release its asoociated resources.
  14895. */
  14896. dispose(): void;
  14897. }
  14898. }
  14899. declare module BABYLON {
  14900. /**
  14901. * This represents the base class for particle system in Babylon.
  14902. * 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.
  14903. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14904. * @example https://doc.babylonjs.com/babylon101/particles
  14905. */
  14906. export class BaseParticleSystem {
  14907. /**
  14908. * Source color is added to the destination color without alpha affecting the result
  14909. */
  14910. static BLENDMODE_ONEONE: number;
  14911. /**
  14912. * Blend current color and particle color using particle’s alpha
  14913. */
  14914. static BLENDMODE_STANDARD: number;
  14915. /**
  14916. * Add current color and particle color multiplied by particle’s alpha
  14917. */
  14918. static BLENDMODE_ADD: number;
  14919. /**
  14920. * Multiply current color with particle color
  14921. */
  14922. static BLENDMODE_MULTIPLY: number;
  14923. /**
  14924. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14925. */
  14926. static BLENDMODE_MULTIPLYADD: number;
  14927. /**
  14928. * List of animations used by the particle system.
  14929. */
  14930. animations: Animation[];
  14931. /**
  14932. * Gets or sets the unique id of the particle system
  14933. */
  14934. uniqueId: number;
  14935. /**
  14936. * The id of the Particle system.
  14937. */
  14938. id: string;
  14939. /**
  14940. * The friendly name of the Particle system.
  14941. */
  14942. name: string;
  14943. /**
  14944. * Snippet ID if the particle system was created from the snippet server
  14945. */
  14946. snippetId: string;
  14947. /**
  14948. * The rendering group used by the Particle system to chose when to render.
  14949. */
  14950. renderingGroupId: number;
  14951. /**
  14952. * The emitter represents the Mesh or position we are attaching the particle system to.
  14953. */
  14954. emitter: Nullable<AbstractMesh | Vector3>;
  14955. /**
  14956. * The maximum number of particles to emit per frame
  14957. */
  14958. emitRate: number;
  14959. /**
  14960. * If you want to launch only a few particles at once, that can be done, as well.
  14961. */
  14962. manualEmitCount: number;
  14963. /**
  14964. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14965. */
  14966. updateSpeed: number;
  14967. /**
  14968. * The amount of time the particle system is running (depends of the overall update speed).
  14969. */
  14970. targetStopDuration: number;
  14971. /**
  14972. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14973. */
  14974. disposeOnStop: boolean;
  14975. /**
  14976. * Minimum power of emitting particles.
  14977. */
  14978. minEmitPower: number;
  14979. /**
  14980. * Maximum power of emitting particles.
  14981. */
  14982. maxEmitPower: number;
  14983. /**
  14984. * Minimum life time of emitting particles.
  14985. */
  14986. minLifeTime: number;
  14987. /**
  14988. * Maximum life time of emitting particles.
  14989. */
  14990. maxLifeTime: number;
  14991. /**
  14992. * Minimum Size of emitting particles.
  14993. */
  14994. minSize: number;
  14995. /**
  14996. * Maximum Size of emitting particles.
  14997. */
  14998. maxSize: number;
  14999. /**
  15000. * Minimum scale of emitting particles on X axis.
  15001. */
  15002. minScaleX: number;
  15003. /**
  15004. * Maximum scale of emitting particles on X axis.
  15005. */
  15006. maxScaleX: number;
  15007. /**
  15008. * Minimum scale of emitting particles on Y axis.
  15009. */
  15010. minScaleY: number;
  15011. /**
  15012. * Maximum scale of emitting particles on Y axis.
  15013. */
  15014. maxScaleY: number;
  15015. /**
  15016. * Gets or sets the minimal initial rotation in radians.
  15017. */
  15018. minInitialRotation: number;
  15019. /**
  15020. * Gets or sets the maximal initial rotation in radians.
  15021. */
  15022. maxInitialRotation: number;
  15023. /**
  15024. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15025. */
  15026. minAngularSpeed: number;
  15027. /**
  15028. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15029. */
  15030. maxAngularSpeed: number;
  15031. /**
  15032. * The texture used to render each particle. (this can be a spritesheet)
  15033. */
  15034. particleTexture: Nullable<BaseTexture>;
  15035. /**
  15036. * The layer mask we are rendering the particles through.
  15037. */
  15038. layerMask: number;
  15039. /**
  15040. * This can help using your own shader to render the particle system.
  15041. * The according effect will be created
  15042. */
  15043. customShader: any;
  15044. /**
  15045. * By default particle system starts as soon as they are created. This prevents the
  15046. * automatic start to happen and let you decide when to start emitting particles.
  15047. */
  15048. preventAutoStart: boolean;
  15049. private _noiseTexture;
  15050. /**
  15051. * Gets or sets a texture used to add random noise to particle positions
  15052. */
  15053. get noiseTexture(): Nullable<ProceduralTexture>;
  15054. set noiseTexture(value: Nullable<ProceduralTexture>);
  15055. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15056. noiseStrength: Vector3;
  15057. /**
  15058. * Callback triggered when the particle animation is ending.
  15059. */
  15060. onAnimationEnd: Nullable<() => void>;
  15061. /**
  15062. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15063. */
  15064. blendMode: number;
  15065. /**
  15066. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15067. * to override the particles.
  15068. */
  15069. forceDepthWrite: boolean;
  15070. /** 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 */
  15071. preWarmCycles: number;
  15072. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15073. preWarmStepOffset: number;
  15074. /**
  15075. * 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)
  15076. */
  15077. spriteCellChangeSpeed: number;
  15078. /**
  15079. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15080. */
  15081. startSpriteCellID: number;
  15082. /**
  15083. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15084. */
  15085. endSpriteCellID: number;
  15086. /**
  15087. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15088. */
  15089. spriteCellWidth: number;
  15090. /**
  15091. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15092. */
  15093. spriteCellHeight: number;
  15094. /**
  15095. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15096. */
  15097. spriteRandomStartCell: boolean;
  15098. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15099. translationPivot: Vector2;
  15100. /** @hidden */
  15101. protected _isAnimationSheetEnabled: boolean;
  15102. /**
  15103. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15104. */
  15105. beginAnimationOnStart: boolean;
  15106. /**
  15107. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15108. */
  15109. beginAnimationFrom: number;
  15110. /**
  15111. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15112. */
  15113. beginAnimationTo: number;
  15114. /**
  15115. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15116. */
  15117. beginAnimationLoop: boolean;
  15118. /**
  15119. * Gets or sets a world offset applied to all particles
  15120. */
  15121. worldOffset: Vector3;
  15122. /**
  15123. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15124. */
  15125. get isAnimationSheetEnabled(): boolean;
  15126. set isAnimationSheetEnabled(value: boolean);
  15127. /**
  15128. * Get hosting scene
  15129. * @returns the scene
  15130. */
  15131. getScene(): Nullable<Scene>;
  15132. /**
  15133. * You can use gravity if you want to give an orientation to your particles.
  15134. */
  15135. gravity: Vector3;
  15136. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15137. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15138. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15139. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15140. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15141. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15142. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15143. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15144. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15145. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15146. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15147. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15148. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15149. /**
  15150. * Defines the delay in milliseconds before starting the system (0 by default)
  15151. */
  15152. startDelay: number;
  15153. /**
  15154. * Gets the current list of drag gradients.
  15155. * You must use addDragGradient and removeDragGradient to udpate this list
  15156. * @returns the list of drag gradients
  15157. */
  15158. getDragGradients(): Nullable<Array<FactorGradient>>;
  15159. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15160. limitVelocityDamping: number;
  15161. /**
  15162. * Gets the current list of limit velocity gradients.
  15163. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15164. * @returns the list of limit velocity gradients
  15165. */
  15166. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15167. /**
  15168. * Gets the current list of color gradients.
  15169. * You must use addColorGradient and removeColorGradient to udpate this list
  15170. * @returns the list of color gradients
  15171. */
  15172. getColorGradients(): Nullable<Array<ColorGradient>>;
  15173. /**
  15174. * Gets the current list of size gradients.
  15175. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15176. * @returns the list of size gradients
  15177. */
  15178. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15179. /**
  15180. * Gets the current list of color remap gradients.
  15181. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15182. * @returns the list of color remap gradients
  15183. */
  15184. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15185. /**
  15186. * Gets the current list of alpha remap gradients.
  15187. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15188. * @returns the list of alpha remap gradients
  15189. */
  15190. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15191. /**
  15192. * Gets the current list of life time gradients.
  15193. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15194. * @returns the list of life time gradients
  15195. */
  15196. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15197. /**
  15198. * Gets the current list of angular speed gradients.
  15199. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15200. * @returns the list of angular speed gradients
  15201. */
  15202. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15203. /**
  15204. * Gets the current list of velocity gradients.
  15205. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15206. * @returns the list of velocity gradients
  15207. */
  15208. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15209. /**
  15210. * Gets the current list of start size gradients.
  15211. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15212. * @returns the list of start size gradients
  15213. */
  15214. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15215. /**
  15216. * Gets the current list of emit rate gradients.
  15217. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15218. * @returns the list of emit rate gradients
  15219. */
  15220. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15221. /**
  15222. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15223. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15224. */
  15225. get direction1(): Vector3;
  15226. set direction1(value: Vector3);
  15227. /**
  15228. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15229. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15230. */
  15231. get direction2(): Vector3;
  15232. set direction2(value: Vector3);
  15233. /**
  15234. * 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.
  15235. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15236. */
  15237. get minEmitBox(): Vector3;
  15238. set minEmitBox(value: Vector3);
  15239. /**
  15240. * 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.
  15241. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15242. */
  15243. get maxEmitBox(): Vector3;
  15244. set maxEmitBox(value: Vector3);
  15245. /**
  15246. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15247. */
  15248. color1: Color4;
  15249. /**
  15250. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15251. */
  15252. color2: Color4;
  15253. /**
  15254. * Color the particle will have at the end of its lifetime
  15255. */
  15256. colorDead: Color4;
  15257. /**
  15258. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15259. */
  15260. textureMask: Color4;
  15261. /**
  15262. * The particle emitter type defines the emitter used by the particle system.
  15263. * It can be for example box, sphere, or cone...
  15264. */
  15265. particleEmitterType: IParticleEmitterType;
  15266. /** @hidden */
  15267. _isSubEmitter: boolean;
  15268. /**
  15269. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15270. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15271. */
  15272. billboardMode: number;
  15273. protected _isBillboardBased: boolean;
  15274. /**
  15275. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15276. */
  15277. get isBillboardBased(): boolean;
  15278. set isBillboardBased(value: boolean);
  15279. /**
  15280. * The scene the particle system belongs to.
  15281. */
  15282. protected _scene: Nullable<Scene>;
  15283. /**
  15284. * The engine the particle system belongs to.
  15285. */
  15286. protected _engine: ThinEngine;
  15287. /**
  15288. * Local cache of defines for image processing.
  15289. */
  15290. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15291. /**
  15292. * Default configuration related to image processing available in the standard Material.
  15293. */
  15294. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15295. /**
  15296. * Gets the image processing configuration used either in this material.
  15297. */
  15298. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15299. /**
  15300. * Sets the Default image processing configuration used either in the this material.
  15301. *
  15302. * If sets to null, the scene one is in use.
  15303. */
  15304. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15305. /**
  15306. * Attaches a new image processing configuration to the Standard Material.
  15307. * @param configuration
  15308. */
  15309. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15310. /** @hidden */
  15311. protected _reset(): void;
  15312. /** @hidden */
  15313. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15314. /**
  15315. * Instantiates a particle system.
  15316. * 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.
  15317. * @param name The name of the particle system
  15318. */
  15319. constructor(name: string);
  15320. /**
  15321. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15322. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15323. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15324. * @returns the emitter
  15325. */
  15326. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15327. /**
  15328. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15329. * @param radius The radius of the hemisphere to emit from
  15330. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15331. * @returns the emitter
  15332. */
  15333. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15334. /**
  15335. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15336. * @param radius The radius of the sphere to emit from
  15337. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15338. * @returns the emitter
  15339. */
  15340. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15341. /**
  15342. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15343. * @param radius The radius of the sphere to emit from
  15344. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15345. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15346. * @returns the emitter
  15347. */
  15348. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15349. /**
  15350. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15351. * @param radius The radius of the emission cylinder
  15352. * @param height The height of the emission cylinder
  15353. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15354. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15355. * @returns the emitter
  15356. */
  15357. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15358. /**
  15359. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15360. * @param radius The radius of the cylinder to emit from
  15361. * @param height The height of the emission cylinder
  15362. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15363. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15364. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15365. * @returns the emitter
  15366. */
  15367. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15368. /**
  15369. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15370. * @param radius The radius of the cone to emit from
  15371. * @param angle The base angle of the cone
  15372. * @returns the emitter
  15373. */
  15374. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15375. /**
  15376. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15377. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15378. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15379. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15380. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15381. * @returns the emitter
  15382. */
  15383. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15384. }
  15385. }
  15386. declare module BABYLON {
  15387. /**
  15388. * Type of sub emitter
  15389. */
  15390. export enum SubEmitterType {
  15391. /**
  15392. * Attached to the particle over it's lifetime
  15393. */
  15394. ATTACHED = 0,
  15395. /**
  15396. * Created when the particle dies
  15397. */
  15398. END = 1
  15399. }
  15400. /**
  15401. * Sub emitter class used to emit particles from an existing particle
  15402. */
  15403. export class SubEmitter {
  15404. /**
  15405. * the particle system to be used by the sub emitter
  15406. */
  15407. particleSystem: ParticleSystem;
  15408. /**
  15409. * Type of the submitter (Default: END)
  15410. */
  15411. type: SubEmitterType;
  15412. /**
  15413. * 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)
  15414. * Note: This only is supported when using an emitter of type Mesh
  15415. */
  15416. inheritDirection: boolean;
  15417. /**
  15418. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15419. */
  15420. inheritedVelocityAmount: number;
  15421. /**
  15422. * Creates a sub emitter
  15423. * @param particleSystem the particle system to be used by the sub emitter
  15424. */
  15425. constructor(
  15426. /**
  15427. * the particle system to be used by the sub emitter
  15428. */
  15429. particleSystem: ParticleSystem);
  15430. /**
  15431. * Clones the sub emitter
  15432. * @returns the cloned sub emitter
  15433. */
  15434. clone(): SubEmitter;
  15435. /**
  15436. * Serialize current object to a JSON object
  15437. * @returns the serialized object
  15438. */
  15439. serialize(): any;
  15440. /** @hidden */
  15441. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15442. /**
  15443. * Creates a new SubEmitter from a serialized JSON version
  15444. * @param serializationObject defines the JSON object to read from
  15445. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15446. * @param rootUrl defines the rootUrl for data loading
  15447. * @returns a new SubEmitter
  15448. */
  15449. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15450. /** Release associated resources */
  15451. dispose(): void;
  15452. }
  15453. }
  15454. declare module BABYLON {
  15455. /** @hidden */
  15456. export var clipPlaneFragmentDeclaration: {
  15457. name: string;
  15458. shader: string;
  15459. };
  15460. }
  15461. declare module BABYLON {
  15462. /** @hidden */
  15463. export var imageProcessingDeclaration: {
  15464. name: string;
  15465. shader: string;
  15466. };
  15467. }
  15468. declare module BABYLON {
  15469. /** @hidden */
  15470. export var imageProcessingFunctions: {
  15471. name: string;
  15472. shader: string;
  15473. };
  15474. }
  15475. declare module BABYLON {
  15476. /** @hidden */
  15477. export var clipPlaneFragment: {
  15478. name: string;
  15479. shader: string;
  15480. };
  15481. }
  15482. declare module BABYLON {
  15483. /** @hidden */
  15484. export var particlesPixelShader: {
  15485. name: string;
  15486. shader: string;
  15487. };
  15488. }
  15489. declare module BABYLON {
  15490. /** @hidden */
  15491. export var clipPlaneVertexDeclaration: {
  15492. name: string;
  15493. shader: string;
  15494. };
  15495. }
  15496. declare module BABYLON {
  15497. /** @hidden */
  15498. export var clipPlaneVertex: {
  15499. name: string;
  15500. shader: string;
  15501. };
  15502. }
  15503. declare module BABYLON {
  15504. /** @hidden */
  15505. export var particlesVertexShader: {
  15506. name: string;
  15507. shader: string;
  15508. };
  15509. }
  15510. declare module BABYLON {
  15511. /**
  15512. * Interface used to define entities containing multiple clip planes
  15513. */
  15514. export interface IClipPlanesHolder {
  15515. /**
  15516. * Gets or sets the active clipplane 1
  15517. */
  15518. clipPlane: Nullable<Plane>;
  15519. /**
  15520. * Gets or sets the active clipplane 2
  15521. */
  15522. clipPlane2: Nullable<Plane>;
  15523. /**
  15524. * Gets or sets the active clipplane 3
  15525. */
  15526. clipPlane3: Nullable<Plane>;
  15527. /**
  15528. * Gets or sets the active clipplane 4
  15529. */
  15530. clipPlane4: Nullable<Plane>;
  15531. /**
  15532. * Gets or sets the active clipplane 5
  15533. */
  15534. clipPlane5: Nullable<Plane>;
  15535. /**
  15536. * Gets or sets the active clipplane 6
  15537. */
  15538. clipPlane6: Nullable<Plane>;
  15539. }
  15540. }
  15541. declare module BABYLON {
  15542. /**
  15543. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15544. *
  15545. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15546. *
  15547. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15548. */
  15549. export class ThinMaterialHelper {
  15550. /**
  15551. * Binds the clip plane information from the holder to the effect.
  15552. * @param effect The effect we are binding the data to
  15553. * @param holder The entity containing the clip plane information
  15554. */
  15555. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15556. }
  15557. }
  15558. declare module BABYLON {
  15559. interface ThinEngine {
  15560. /**
  15561. * Sets alpha constants used by some alpha blending modes
  15562. * @param r defines the red component
  15563. * @param g defines the green component
  15564. * @param b defines the blue component
  15565. * @param a defines the alpha component
  15566. */
  15567. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15568. /**
  15569. * Sets the current alpha mode
  15570. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15571. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15572. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15573. */
  15574. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15575. /**
  15576. * Gets the current alpha mode
  15577. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15578. * @returns the current alpha mode
  15579. */
  15580. getAlphaMode(): number;
  15581. /**
  15582. * Sets the current alpha equation
  15583. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15584. */
  15585. setAlphaEquation(equation: number): void;
  15586. /**
  15587. * Gets the current alpha equation.
  15588. * @returns the current alpha equation
  15589. */
  15590. getAlphaEquation(): number;
  15591. }
  15592. }
  15593. declare module BABYLON {
  15594. /**
  15595. * This represents a particle system in Babylon.
  15596. * 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.
  15597. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15598. * @example https://doc.babylonjs.com/babylon101/particles
  15599. */
  15600. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15601. /**
  15602. * Billboard mode will only apply to Y axis
  15603. */
  15604. static readonly BILLBOARDMODE_Y: number;
  15605. /**
  15606. * Billboard mode will apply to all axes
  15607. */
  15608. static readonly BILLBOARDMODE_ALL: number;
  15609. /**
  15610. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15611. */
  15612. static readonly BILLBOARDMODE_STRETCHED: number;
  15613. /**
  15614. * This function can be defined to provide custom update for active particles.
  15615. * This function will be called instead of regular update (age, position, color, etc.).
  15616. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15617. */
  15618. updateFunction: (particles: Particle[]) => void;
  15619. private _emitterWorldMatrix;
  15620. /**
  15621. * This function can be defined to specify initial direction for every new particle.
  15622. * It by default use the emitterType defined function
  15623. */
  15624. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15625. /**
  15626. * This function can be defined to specify initial position for every new particle.
  15627. * It by default use the emitterType defined function
  15628. */
  15629. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15630. /**
  15631. * @hidden
  15632. */
  15633. _inheritedVelocityOffset: Vector3;
  15634. /**
  15635. * An event triggered when the system is disposed
  15636. */
  15637. onDisposeObservable: Observable<IParticleSystem>;
  15638. /**
  15639. * An event triggered when the system is stopped
  15640. */
  15641. onStoppedObservable: Observable<IParticleSystem>;
  15642. private _onDisposeObserver;
  15643. /**
  15644. * Sets a callback that will be triggered when the system is disposed
  15645. */
  15646. set onDispose(callback: () => void);
  15647. private _particles;
  15648. private _epsilon;
  15649. private _capacity;
  15650. private _stockParticles;
  15651. private _newPartsExcess;
  15652. private _vertexData;
  15653. private _vertexBuffer;
  15654. private _vertexBuffers;
  15655. private _spriteBuffer;
  15656. private _indexBuffer;
  15657. private _effect;
  15658. private _customEffect;
  15659. private _cachedDefines;
  15660. private _scaledColorStep;
  15661. private _colorDiff;
  15662. private _scaledDirection;
  15663. private _scaledGravity;
  15664. private _currentRenderId;
  15665. private _alive;
  15666. private _useInstancing;
  15667. private _vertexArrayObject;
  15668. private _started;
  15669. private _stopped;
  15670. private _actualFrame;
  15671. private _scaledUpdateSpeed;
  15672. private _vertexBufferSize;
  15673. /** @hidden */
  15674. _currentEmitRateGradient: Nullable<FactorGradient>;
  15675. /** @hidden */
  15676. _currentEmitRate1: number;
  15677. /** @hidden */
  15678. _currentEmitRate2: number;
  15679. /** @hidden */
  15680. _currentStartSizeGradient: Nullable<FactorGradient>;
  15681. /** @hidden */
  15682. _currentStartSize1: number;
  15683. /** @hidden */
  15684. _currentStartSize2: number;
  15685. private readonly _rawTextureWidth;
  15686. private _rampGradientsTexture;
  15687. private _useRampGradients;
  15688. /** Gets or sets a matrix to use to compute projection */
  15689. defaultProjectionMatrix: Matrix;
  15690. /** Gets or sets a matrix to use to compute view */
  15691. defaultViewMatrix: Matrix;
  15692. /** Gets or sets a boolean indicating that ramp gradients must be used
  15693. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15694. */
  15695. get useRampGradients(): boolean;
  15696. set useRampGradients(value: boolean);
  15697. /**
  15698. * 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.
  15699. * 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: [])
  15700. */
  15701. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15702. private _subEmitters;
  15703. /**
  15704. * @hidden
  15705. * If the particle systems emitter should be disposed when the particle system is disposed
  15706. */
  15707. _disposeEmitterOnDispose: boolean;
  15708. /**
  15709. * The current active Sub-systems, this property is used by the root particle system only.
  15710. */
  15711. activeSubSystems: Array<ParticleSystem>;
  15712. /**
  15713. * Specifies if the particles are updated in emitter local space or world space
  15714. */
  15715. isLocal: boolean;
  15716. private _rootParticleSystem;
  15717. /**
  15718. * Gets the current list of active particles
  15719. */
  15720. get particles(): Particle[];
  15721. /**
  15722. * Gets the number of particles active at the same time.
  15723. * @returns The number of active particles.
  15724. */
  15725. getActiveCount(): number;
  15726. /**
  15727. * Returns the string "ParticleSystem"
  15728. * @returns a string containing the class name
  15729. */
  15730. getClassName(): string;
  15731. /**
  15732. * Gets a boolean indicating that the system is stopping
  15733. * @returns true if the system is currently stopping
  15734. */
  15735. isStopping(): boolean;
  15736. /**
  15737. * Gets the custom effect used to render the particles
  15738. * @param blendMode Blend mode for which the effect should be retrieved
  15739. * @returns The effect
  15740. */
  15741. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15742. /**
  15743. * Sets the custom effect used to render the particles
  15744. * @param effect The effect to set
  15745. * @param blendMode Blend mode for which the effect should be set
  15746. */
  15747. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15748. /** @hidden */
  15749. private _onBeforeDrawParticlesObservable;
  15750. /**
  15751. * Observable that will be called just before the particles are drawn
  15752. */
  15753. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15754. /**
  15755. * Gets the name of the particle vertex shader
  15756. */
  15757. get vertexShaderName(): string;
  15758. /**
  15759. * Instantiates a particle system.
  15760. * 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.
  15761. * @param name The name of the particle system
  15762. * @param capacity The max number of particles alive at the same time
  15763. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15764. * @param customEffect a custom effect used to change the way particles are rendered by default
  15765. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15766. * @param epsilon Offset used to render the particles
  15767. */
  15768. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15769. private _addFactorGradient;
  15770. private _removeFactorGradient;
  15771. /**
  15772. * Adds a new life time gradient
  15773. * @param gradient defines the gradient to use (between 0 and 1)
  15774. * @param factor defines the life time factor to affect to the specified gradient
  15775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15776. * @returns the current particle system
  15777. */
  15778. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15779. /**
  15780. * Remove a specific life time gradient
  15781. * @param gradient defines the gradient to remove
  15782. * @returns the current particle system
  15783. */
  15784. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15785. /**
  15786. * Adds a new size gradient
  15787. * @param gradient defines the gradient to use (between 0 and 1)
  15788. * @param factor defines the size factor to affect to the specified gradient
  15789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15790. * @returns the current particle system
  15791. */
  15792. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15793. /**
  15794. * Remove a specific size gradient
  15795. * @param gradient defines the gradient to remove
  15796. * @returns the current particle system
  15797. */
  15798. removeSizeGradient(gradient: number): IParticleSystem;
  15799. /**
  15800. * Adds a new color remap gradient
  15801. * @param gradient defines the gradient to use (between 0 and 1)
  15802. * @param min defines the color remap minimal range
  15803. * @param max defines the color remap maximal range
  15804. * @returns the current particle system
  15805. */
  15806. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15807. /**
  15808. * Remove a specific color remap gradient
  15809. * @param gradient defines the gradient to remove
  15810. * @returns the current particle system
  15811. */
  15812. removeColorRemapGradient(gradient: number): IParticleSystem;
  15813. /**
  15814. * Adds a new alpha remap gradient
  15815. * @param gradient defines the gradient to use (between 0 and 1)
  15816. * @param min defines the alpha remap minimal range
  15817. * @param max defines the alpha remap maximal range
  15818. * @returns the current particle system
  15819. */
  15820. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15821. /**
  15822. * Remove a specific alpha remap gradient
  15823. * @param gradient defines the gradient to remove
  15824. * @returns the current particle system
  15825. */
  15826. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15827. /**
  15828. * Adds a new angular speed gradient
  15829. * @param gradient defines the gradient to use (between 0 and 1)
  15830. * @param factor defines the angular speed to affect to the specified gradient
  15831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15832. * @returns the current particle system
  15833. */
  15834. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15835. /**
  15836. * Remove a specific angular speed gradient
  15837. * @param gradient defines the gradient to remove
  15838. * @returns the current particle system
  15839. */
  15840. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15841. /**
  15842. * Adds a new velocity gradient
  15843. * @param gradient defines the gradient to use (between 0 and 1)
  15844. * @param factor defines the velocity to affect to the specified gradient
  15845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15846. * @returns the current particle system
  15847. */
  15848. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15849. /**
  15850. * Remove a specific velocity gradient
  15851. * @param gradient defines the gradient to remove
  15852. * @returns the current particle system
  15853. */
  15854. removeVelocityGradient(gradient: number): IParticleSystem;
  15855. /**
  15856. * Adds a new limit velocity gradient
  15857. * @param gradient defines the gradient to use (between 0 and 1)
  15858. * @param factor defines the limit velocity value to affect to the specified gradient
  15859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15860. * @returns the current particle system
  15861. */
  15862. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15863. /**
  15864. * Remove a specific limit velocity gradient
  15865. * @param gradient defines the gradient to remove
  15866. * @returns the current particle system
  15867. */
  15868. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15869. /**
  15870. * Adds a new drag gradient
  15871. * @param gradient defines the gradient to use (between 0 and 1)
  15872. * @param factor defines the drag value to affect to the specified gradient
  15873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15874. * @returns the current particle system
  15875. */
  15876. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15877. /**
  15878. * Remove a specific drag gradient
  15879. * @param gradient defines the gradient to remove
  15880. * @returns the current particle system
  15881. */
  15882. removeDragGradient(gradient: number): IParticleSystem;
  15883. /**
  15884. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15885. * @param gradient defines the gradient to use (between 0 and 1)
  15886. * @param factor defines the emit rate value to affect to the specified gradient
  15887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15888. * @returns the current particle system
  15889. */
  15890. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15891. /**
  15892. * Remove a specific emit rate gradient
  15893. * @param gradient defines the gradient to remove
  15894. * @returns the current particle system
  15895. */
  15896. removeEmitRateGradient(gradient: number): IParticleSystem;
  15897. /**
  15898. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15899. * @param gradient defines the gradient to use (between 0 and 1)
  15900. * @param factor defines the start size value to affect to the specified gradient
  15901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15902. * @returns the current particle system
  15903. */
  15904. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15905. /**
  15906. * Remove a specific start size gradient
  15907. * @param gradient defines the gradient to remove
  15908. * @returns the current particle system
  15909. */
  15910. removeStartSizeGradient(gradient: number): IParticleSystem;
  15911. private _createRampGradientTexture;
  15912. /**
  15913. * Gets the current list of ramp gradients.
  15914. * You must use addRampGradient and removeRampGradient to udpate this list
  15915. * @returns the list of ramp gradients
  15916. */
  15917. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15918. /** Force the system to rebuild all gradients that need to be resync */
  15919. forceRefreshGradients(): void;
  15920. private _syncRampGradientTexture;
  15921. /**
  15922. * Adds a new ramp gradient used to remap particle colors
  15923. * @param gradient defines the gradient to use (between 0 and 1)
  15924. * @param color defines the color to affect to the specified gradient
  15925. * @returns the current particle system
  15926. */
  15927. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15928. /**
  15929. * Remove a specific ramp gradient
  15930. * @param gradient defines the gradient to remove
  15931. * @returns the current particle system
  15932. */
  15933. removeRampGradient(gradient: number): ParticleSystem;
  15934. /**
  15935. * Adds a new color gradient
  15936. * @param gradient defines the gradient to use (between 0 and 1)
  15937. * @param color1 defines the color to affect to the specified gradient
  15938. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15939. * @returns this particle system
  15940. */
  15941. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15942. /**
  15943. * Remove a specific color gradient
  15944. * @param gradient defines the gradient to remove
  15945. * @returns this particle system
  15946. */
  15947. removeColorGradient(gradient: number): IParticleSystem;
  15948. private _fetchR;
  15949. protected _reset(): void;
  15950. private _resetEffect;
  15951. private _createVertexBuffers;
  15952. private _createIndexBuffer;
  15953. /**
  15954. * Gets the maximum number of particles active at the same time.
  15955. * @returns The max number of active particles.
  15956. */
  15957. getCapacity(): number;
  15958. /**
  15959. * Gets whether there are still active particles in the system.
  15960. * @returns True if it is alive, otherwise false.
  15961. */
  15962. isAlive(): boolean;
  15963. /**
  15964. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15965. * @returns True if it has been started, otherwise false.
  15966. */
  15967. isStarted(): boolean;
  15968. private _prepareSubEmitterInternalArray;
  15969. /**
  15970. * Starts the particle system and begins to emit
  15971. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15972. */
  15973. start(delay?: number): void;
  15974. /**
  15975. * Stops the particle system.
  15976. * @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.
  15977. */
  15978. stop(stopSubEmitters?: boolean): void;
  15979. /**
  15980. * Remove all active particles
  15981. */
  15982. reset(): void;
  15983. /**
  15984. * @hidden (for internal use only)
  15985. */
  15986. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15987. /**
  15988. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15989. * Its lifetime will start back at 0.
  15990. */
  15991. recycleParticle: (particle: Particle) => void;
  15992. private _stopSubEmitters;
  15993. private _createParticle;
  15994. private _removeFromRoot;
  15995. private _emitFromParticle;
  15996. private _update;
  15997. /** @hidden */
  15998. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15999. /** @hidden */
  16000. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16001. /**
  16002. * Fill the defines array according to the current settings of the particle system
  16003. * @param defines Array to be updated
  16004. * @param blendMode blend mode to take into account when updating the array
  16005. */
  16006. fillDefines(defines: Array<string>, blendMode: number): void;
  16007. /**
  16008. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16009. * @param uniforms Uniforms array to fill
  16010. * @param attributes Attributes array to fill
  16011. * @param samplers Samplers array to fill
  16012. */
  16013. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16014. /** @hidden */
  16015. private _getEffect;
  16016. /**
  16017. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16018. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16019. */
  16020. animate(preWarmOnly?: boolean): void;
  16021. private _appendParticleVertices;
  16022. /**
  16023. * Rebuilds the particle system.
  16024. */
  16025. rebuild(): void;
  16026. /**
  16027. * Is this system ready to be used/rendered
  16028. * @return true if the system is ready
  16029. */
  16030. isReady(): boolean;
  16031. private _render;
  16032. /**
  16033. * Renders the particle system in its current state.
  16034. * @returns the current number of particles
  16035. */
  16036. render(): number;
  16037. /**
  16038. * Disposes the particle system and free the associated resources
  16039. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16040. */
  16041. dispose(disposeTexture?: boolean): void;
  16042. /**
  16043. * Clones the particle system.
  16044. * @param name The name of the cloned object
  16045. * @param newEmitter The new emitter to use
  16046. * @returns the cloned particle system
  16047. */
  16048. clone(name: string, newEmitter: any): ParticleSystem;
  16049. /**
  16050. * Serializes the particle system to a JSON object
  16051. * @param serializeTexture defines if the texture must be serialized as well
  16052. * @returns the JSON object
  16053. */
  16054. serialize(serializeTexture?: boolean): any;
  16055. /** @hidden */
  16056. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16057. /** @hidden */
  16058. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16059. /**
  16060. * Parses a JSON object to create a particle system.
  16061. * @param parsedParticleSystem The JSON object to parse
  16062. * @param sceneOrEngine The scene or the engine to create the particle system in
  16063. * @param rootUrl The root url to use to load external dependencies like texture
  16064. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16065. * @returns the Parsed particle system
  16066. */
  16067. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16068. }
  16069. }
  16070. declare module BABYLON {
  16071. /**
  16072. * A particle represents one of the element emitted by a particle system.
  16073. * This is mainly define by its coordinates, direction, velocity and age.
  16074. */
  16075. export class Particle {
  16076. /**
  16077. * The particle system the particle belongs to.
  16078. */
  16079. particleSystem: ParticleSystem;
  16080. private static _Count;
  16081. /**
  16082. * Unique ID of the particle
  16083. */
  16084. id: number;
  16085. /**
  16086. * The world position of the particle in the scene.
  16087. */
  16088. position: Vector3;
  16089. /**
  16090. * The world direction of the particle in the scene.
  16091. */
  16092. direction: Vector3;
  16093. /**
  16094. * The color of the particle.
  16095. */
  16096. color: Color4;
  16097. /**
  16098. * The color change of the particle per step.
  16099. */
  16100. colorStep: Color4;
  16101. /**
  16102. * Defines how long will the life of the particle be.
  16103. */
  16104. lifeTime: number;
  16105. /**
  16106. * The current age of the particle.
  16107. */
  16108. age: number;
  16109. /**
  16110. * The current size of the particle.
  16111. */
  16112. size: number;
  16113. /**
  16114. * The current scale of the particle.
  16115. */
  16116. scale: Vector2;
  16117. /**
  16118. * The current angle of the particle.
  16119. */
  16120. angle: number;
  16121. /**
  16122. * Defines how fast is the angle changing.
  16123. */
  16124. angularSpeed: number;
  16125. /**
  16126. * Defines the cell index used by the particle to be rendered from a sprite.
  16127. */
  16128. cellIndex: number;
  16129. /**
  16130. * The information required to support color remapping
  16131. */
  16132. remapData: Vector4;
  16133. /** @hidden */
  16134. _randomCellOffset?: number;
  16135. /** @hidden */
  16136. _initialDirection: Nullable<Vector3>;
  16137. /** @hidden */
  16138. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16139. /** @hidden */
  16140. _initialStartSpriteCellID: number;
  16141. /** @hidden */
  16142. _initialEndSpriteCellID: number;
  16143. /** @hidden */
  16144. _currentColorGradient: Nullable<ColorGradient>;
  16145. /** @hidden */
  16146. _currentColor1: Color4;
  16147. /** @hidden */
  16148. _currentColor2: Color4;
  16149. /** @hidden */
  16150. _currentSizeGradient: Nullable<FactorGradient>;
  16151. /** @hidden */
  16152. _currentSize1: number;
  16153. /** @hidden */
  16154. _currentSize2: number;
  16155. /** @hidden */
  16156. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16157. /** @hidden */
  16158. _currentAngularSpeed1: number;
  16159. /** @hidden */
  16160. _currentAngularSpeed2: number;
  16161. /** @hidden */
  16162. _currentVelocityGradient: Nullable<FactorGradient>;
  16163. /** @hidden */
  16164. _currentVelocity1: number;
  16165. /** @hidden */
  16166. _currentVelocity2: number;
  16167. /** @hidden */
  16168. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16169. /** @hidden */
  16170. _currentLimitVelocity1: number;
  16171. /** @hidden */
  16172. _currentLimitVelocity2: number;
  16173. /** @hidden */
  16174. _currentDragGradient: Nullable<FactorGradient>;
  16175. /** @hidden */
  16176. _currentDrag1: number;
  16177. /** @hidden */
  16178. _currentDrag2: number;
  16179. /** @hidden */
  16180. _randomNoiseCoordinates1: Vector3;
  16181. /** @hidden */
  16182. _randomNoiseCoordinates2: Vector3;
  16183. /** @hidden */
  16184. _localPosition?: Vector3;
  16185. /**
  16186. * Creates a new instance Particle
  16187. * @param particleSystem the particle system the particle belongs to
  16188. */
  16189. constructor(
  16190. /**
  16191. * The particle system the particle belongs to.
  16192. */
  16193. particleSystem: ParticleSystem);
  16194. private updateCellInfoFromSystem;
  16195. /**
  16196. * Defines how the sprite cell index is updated for the particle
  16197. */
  16198. updateCellIndex(): void;
  16199. /** @hidden */
  16200. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16201. /** @hidden */
  16202. _inheritParticleInfoToSubEmitters(): void;
  16203. /** @hidden */
  16204. _reset(): void;
  16205. /**
  16206. * Copy the properties of particle to another one.
  16207. * @param other the particle to copy the information to.
  16208. */
  16209. copyTo(other: Particle): void;
  16210. }
  16211. }
  16212. declare module BABYLON {
  16213. /**
  16214. * Particle emitter represents a volume emitting particles.
  16215. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16216. */
  16217. export interface IParticleEmitterType {
  16218. /**
  16219. * Called by the particle System when the direction is computed for the created particle.
  16220. * @param worldMatrix is the world matrix of the particle system
  16221. * @param directionToUpdate is the direction vector to update with the result
  16222. * @param particle is the particle we are computed the direction for
  16223. * @param isLocal defines if the direction should be set in local space
  16224. */
  16225. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16226. /**
  16227. * Called by the particle System when the position is computed for the created particle.
  16228. * @param worldMatrix is the world matrix of the particle system
  16229. * @param positionToUpdate is the position vector to update with the result
  16230. * @param particle is the particle we are computed the position for
  16231. * @param isLocal defines if the position should be set in local space
  16232. */
  16233. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16234. /**
  16235. * Clones the current emitter and returns a copy of it
  16236. * @returns the new emitter
  16237. */
  16238. clone(): IParticleEmitterType;
  16239. /**
  16240. * Called by the GPUParticleSystem to setup the update shader
  16241. * @param effect defines the update shader
  16242. */
  16243. applyToShader(effect: Effect): void;
  16244. /**
  16245. * Returns a string to use to update the GPU particles update shader
  16246. * @returns the effect defines string
  16247. */
  16248. getEffectDefines(): string;
  16249. /**
  16250. * Returns a string representing the class name
  16251. * @returns a string containing the class name
  16252. */
  16253. getClassName(): string;
  16254. /**
  16255. * Serializes the particle system to a JSON object.
  16256. * @returns the JSON object
  16257. */
  16258. serialize(): any;
  16259. /**
  16260. * Parse properties from a JSON object
  16261. * @param serializationObject defines the JSON object
  16262. * @param scene defines the hosting scene
  16263. */
  16264. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16265. }
  16266. }
  16267. declare module BABYLON {
  16268. /**
  16269. * Particle emitter emitting particles from the inside of a box.
  16270. * It emits the particles randomly between 2 given directions.
  16271. */
  16272. export class BoxParticleEmitter implements IParticleEmitterType {
  16273. /**
  16274. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16275. */
  16276. direction1: Vector3;
  16277. /**
  16278. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16279. */
  16280. direction2: Vector3;
  16281. /**
  16282. * 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.
  16283. */
  16284. minEmitBox: Vector3;
  16285. /**
  16286. * 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.
  16287. */
  16288. maxEmitBox: Vector3;
  16289. /**
  16290. * Creates a new instance BoxParticleEmitter
  16291. */
  16292. constructor();
  16293. /**
  16294. * Called by the particle System when the direction is computed for the created particle.
  16295. * @param worldMatrix is the world matrix of the particle system
  16296. * @param directionToUpdate is the direction vector to update with the result
  16297. * @param particle is the particle we are computed the direction for
  16298. * @param isLocal defines if the direction should be set in local space
  16299. */
  16300. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16301. /**
  16302. * Called by the particle System when the position is computed for the created particle.
  16303. * @param worldMatrix is the world matrix of the particle system
  16304. * @param positionToUpdate is the position vector to update with the result
  16305. * @param particle is the particle we are computed the position for
  16306. * @param isLocal defines if the position should be set in local space
  16307. */
  16308. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16309. /**
  16310. * Clones the current emitter and returns a copy of it
  16311. * @returns the new emitter
  16312. */
  16313. clone(): BoxParticleEmitter;
  16314. /**
  16315. * Called by the GPUParticleSystem to setup the update shader
  16316. * @param effect defines the update shader
  16317. */
  16318. applyToShader(effect: Effect): void;
  16319. /**
  16320. * Returns a string to use to update the GPU particles update shader
  16321. * @returns a string containng the defines string
  16322. */
  16323. getEffectDefines(): string;
  16324. /**
  16325. * Returns the string "BoxParticleEmitter"
  16326. * @returns a string containing the class name
  16327. */
  16328. getClassName(): string;
  16329. /**
  16330. * Serializes the particle system to a JSON object.
  16331. * @returns the JSON object
  16332. */
  16333. serialize(): any;
  16334. /**
  16335. * Parse properties from a JSON object
  16336. * @param serializationObject defines the JSON object
  16337. */
  16338. parse(serializationObject: any): void;
  16339. }
  16340. }
  16341. declare module BABYLON {
  16342. /**
  16343. * Particle emitter emitting particles from the inside of a cone.
  16344. * It emits the particles alongside the cone volume from the base to the particle.
  16345. * The emission direction might be randomized.
  16346. */
  16347. export class ConeParticleEmitter implements IParticleEmitterType {
  16348. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16349. directionRandomizer: number;
  16350. private _radius;
  16351. private _angle;
  16352. private _height;
  16353. /**
  16354. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16355. */
  16356. radiusRange: number;
  16357. /**
  16358. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16359. */
  16360. heightRange: number;
  16361. /**
  16362. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16363. */
  16364. emitFromSpawnPointOnly: boolean;
  16365. /**
  16366. * Gets or sets the radius of the emission cone
  16367. */
  16368. get radius(): number;
  16369. set radius(value: number);
  16370. /**
  16371. * Gets or sets the angle of the emission cone
  16372. */
  16373. get angle(): number;
  16374. set angle(value: number);
  16375. private _buildHeight;
  16376. /**
  16377. * Creates a new instance ConeParticleEmitter
  16378. * @param radius the radius of the emission cone (1 by default)
  16379. * @param angle the cone base angle (PI by default)
  16380. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16381. */
  16382. constructor(radius?: number, angle?: number,
  16383. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16384. directionRandomizer?: number);
  16385. /**
  16386. * Called by the particle System when the direction is computed for the created particle.
  16387. * @param worldMatrix is the world matrix of the particle system
  16388. * @param directionToUpdate is the direction vector to update with the result
  16389. * @param particle is the particle we are computed the direction for
  16390. * @param isLocal defines if the direction should be set in local space
  16391. */
  16392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16393. /**
  16394. * Called by the particle System when the position is computed for the created particle.
  16395. * @param worldMatrix is the world matrix of the particle system
  16396. * @param positionToUpdate is the position vector to update with the result
  16397. * @param particle is the particle we are computed the position for
  16398. * @param isLocal defines if the position should be set in local space
  16399. */
  16400. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16401. /**
  16402. * Clones the current emitter and returns a copy of it
  16403. * @returns the new emitter
  16404. */
  16405. clone(): ConeParticleEmitter;
  16406. /**
  16407. * Called by the GPUParticleSystem to setup the update shader
  16408. * @param effect defines the update shader
  16409. */
  16410. applyToShader(effect: Effect): void;
  16411. /**
  16412. * Returns a string to use to update the GPU particles update shader
  16413. * @returns a string containng the defines string
  16414. */
  16415. getEffectDefines(): string;
  16416. /**
  16417. * Returns the string "ConeParticleEmitter"
  16418. * @returns a string containing the class name
  16419. */
  16420. getClassName(): string;
  16421. /**
  16422. * Serializes the particle system to a JSON object.
  16423. * @returns the JSON object
  16424. */
  16425. serialize(): any;
  16426. /**
  16427. * Parse properties from a JSON object
  16428. * @param serializationObject defines the JSON object
  16429. */
  16430. parse(serializationObject: any): void;
  16431. }
  16432. }
  16433. declare module BABYLON {
  16434. /**
  16435. * Particle emitter emitting particles from the inside of a cylinder.
  16436. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16437. */
  16438. export class CylinderParticleEmitter implements IParticleEmitterType {
  16439. /**
  16440. * The radius of the emission cylinder.
  16441. */
  16442. radius: number;
  16443. /**
  16444. * The height of the emission cylinder.
  16445. */
  16446. height: number;
  16447. /**
  16448. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16449. */
  16450. radiusRange: number;
  16451. /**
  16452. * How much to randomize the particle direction [0-1].
  16453. */
  16454. directionRandomizer: number;
  16455. /**
  16456. * Creates a new instance CylinderParticleEmitter
  16457. * @param radius the radius of the emission cylinder (1 by default)
  16458. * @param height the height of the emission cylinder (1 by default)
  16459. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16460. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16461. */
  16462. constructor(
  16463. /**
  16464. * The radius of the emission cylinder.
  16465. */
  16466. radius?: number,
  16467. /**
  16468. * The height of the emission cylinder.
  16469. */
  16470. height?: number,
  16471. /**
  16472. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16473. */
  16474. radiusRange?: number,
  16475. /**
  16476. * How much to randomize the particle direction [0-1].
  16477. */
  16478. directionRandomizer?: number);
  16479. /**
  16480. * Called by the particle System when the direction is computed for the created particle.
  16481. * @param worldMatrix is the world matrix of the particle system
  16482. * @param directionToUpdate is the direction vector to update with the result
  16483. * @param particle is the particle we are computed the direction for
  16484. * @param isLocal defines if the direction should be set in local space
  16485. */
  16486. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16487. /**
  16488. * Called by the particle System when the position is computed for the created particle.
  16489. * @param worldMatrix is the world matrix of the particle system
  16490. * @param positionToUpdate is the position vector to update with the result
  16491. * @param particle is the particle we are computed the position for
  16492. * @param isLocal defines if the position should be set in local space
  16493. */
  16494. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16495. /**
  16496. * Clones the current emitter and returns a copy of it
  16497. * @returns the new emitter
  16498. */
  16499. clone(): CylinderParticleEmitter;
  16500. /**
  16501. * Called by the GPUParticleSystem to setup the update shader
  16502. * @param effect defines the update shader
  16503. */
  16504. applyToShader(effect: Effect): void;
  16505. /**
  16506. * Returns a string to use to update the GPU particles update shader
  16507. * @returns a string containng the defines string
  16508. */
  16509. getEffectDefines(): string;
  16510. /**
  16511. * Returns the string "CylinderParticleEmitter"
  16512. * @returns a string containing the class name
  16513. */
  16514. getClassName(): string;
  16515. /**
  16516. * Serializes the particle system to a JSON object.
  16517. * @returns the JSON object
  16518. */
  16519. serialize(): any;
  16520. /**
  16521. * Parse properties from a JSON object
  16522. * @param serializationObject defines the JSON object
  16523. */
  16524. parse(serializationObject: any): void;
  16525. }
  16526. /**
  16527. * Particle emitter emitting particles from the inside of a cylinder.
  16528. * It emits the particles randomly between two vectors.
  16529. */
  16530. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16531. /**
  16532. * The min limit of the emission direction.
  16533. */
  16534. direction1: Vector3;
  16535. /**
  16536. * The max limit of the emission direction.
  16537. */
  16538. direction2: Vector3;
  16539. /**
  16540. * Creates a new instance CylinderDirectedParticleEmitter
  16541. * @param radius the radius of the emission cylinder (1 by default)
  16542. * @param height the height of the emission cylinder (1 by default)
  16543. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16544. * @param direction1 the min limit of the emission direction (up vector by default)
  16545. * @param direction2 the max limit of the emission direction (up vector by default)
  16546. */
  16547. constructor(radius?: number, height?: number, radiusRange?: number,
  16548. /**
  16549. * The min limit of the emission direction.
  16550. */
  16551. direction1?: Vector3,
  16552. /**
  16553. * The max limit of the emission direction.
  16554. */
  16555. direction2?: Vector3);
  16556. /**
  16557. * Called by the particle System when the direction is computed for the created particle.
  16558. * @param worldMatrix is the world matrix of the particle system
  16559. * @param directionToUpdate is the direction vector to update with the result
  16560. * @param particle is the particle we are computed the direction for
  16561. */
  16562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16563. /**
  16564. * Clones the current emitter and returns a copy of it
  16565. * @returns the new emitter
  16566. */
  16567. clone(): CylinderDirectedParticleEmitter;
  16568. /**
  16569. * Called by the GPUParticleSystem to setup the update shader
  16570. * @param effect defines the update shader
  16571. */
  16572. applyToShader(effect: Effect): void;
  16573. /**
  16574. * Returns a string to use to update the GPU particles update shader
  16575. * @returns a string containng the defines string
  16576. */
  16577. getEffectDefines(): string;
  16578. /**
  16579. * Returns the string "CylinderDirectedParticleEmitter"
  16580. * @returns a string containing the class name
  16581. */
  16582. getClassName(): string;
  16583. /**
  16584. * Serializes the particle system to a JSON object.
  16585. * @returns the JSON object
  16586. */
  16587. serialize(): any;
  16588. /**
  16589. * Parse properties from a JSON object
  16590. * @param serializationObject defines the JSON object
  16591. */
  16592. parse(serializationObject: any): void;
  16593. }
  16594. }
  16595. declare module BABYLON {
  16596. /**
  16597. * Particle emitter emitting particles from the inside of a hemisphere.
  16598. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16599. */
  16600. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16601. /**
  16602. * The radius of the emission hemisphere.
  16603. */
  16604. radius: number;
  16605. /**
  16606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16607. */
  16608. radiusRange: number;
  16609. /**
  16610. * How much to randomize the particle direction [0-1].
  16611. */
  16612. directionRandomizer: number;
  16613. /**
  16614. * Creates a new instance HemisphericParticleEmitter
  16615. * @param radius the radius of the emission hemisphere (1 by default)
  16616. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16617. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16618. */
  16619. constructor(
  16620. /**
  16621. * The radius of the emission hemisphere.
  16622. */
  16623. radius?: number,
  16624. /**
  16625. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16626. */
  16627. radiusRange?: number,
  16628. /**
  16629. * How much to randomize the particle direction [0-1].
  16630. */
  16631. directionRandomizer?: number);
  16632. /**
  16633. * Called by the particle System when the direction is computed for the created particle.
  16634. * @param worldMatrix is the world matrix of the particle system
  16635. * @param directionToUpdate is the direction vector to update with the result
  16636. * @param particle is the particle we are computed the direction for
  16637. * @param isLocal defines if the direction should be set in local space
  16638. */
  16639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16640. /**
  16641. * Called by the particle System when the position is computed for the created particle.
  16642. * @param worldMatrix is the world matrix of the particle system
  16643. * @param positionToUpdate is the position vector to update with the result
  16644. * @param particle is the particle we are computed the position for
  16645. * @param isLocal defines if the position should be set in local space
  16646. */
  16647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16648. /**
  16649. * Clones the current emitter and returns a copy of it
  16650. * @returns the new emitter
  16651. */
  16652. clone(): HemisphericParticleEmitter;
  16653. /**
  16654. * Called by the GPUParticleSystem to setup the update shader
  16655. * @param effect defines the update shader
  16656. */
  16657. applyToShader(effect: Effect): void;
  16658. /**
  16659. * Returns a string to use to update the GPU particles update shader
  16660. * @returns a string containng the defines string
  16661. */
  16662. getEffectDefines(): string;
  16663. /**
  16664. * Returns the string "HemisphericParticleEmitter"
  16665. * @returns a string containing the class name
  16666. */
  16667. getClassName(): string;
  16668. /**
  16669. * Serializes the particle system to a JSON object.
  16670. * @returns the JSON object
  16671. */
  16672. serialize(): any;
  16673. /**
  16674. * Parse properties from a JSON object
  16675. * @param serializationObject defines the JSON object
  16676. */
  16677. parse(serializationObject: any): void;
  16678. }
  16679. }
  16680. declare module BABYLON {
  16681. /**
  16682. * Particle emitter emitting particles from a point.
  16683. * It emits the particles randomly between 2 given directions.
  16684. */
  16685. export class PointParticleEmitter implements IParticleEmitterType {
  16686. /**
  16687. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16688. */
  16689. direction1: Vector3;
  16690. /**
  16691. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16692. */
  16693. direction2: Vector3;
  16694. /**
  16695. * Creates a new instance PointParticleEmitter
  16696. */
  16697. constructor();
  16698. /**
  16699. * Called by the particle System when the direction is computed for the created particle.
  16700. * @param worldMatrix is the world matrix of the particle system
  16701. * @param directionToUpdate is the direction vector to update with the result
  16702. * @param particle is the particle we are computed the direction for
  16703. * @param isLocal defines if the direction should be set in local space
  16704. */
  16705. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16706. /**
  16707. * Called by the particle System when the position is computed for the created particle.
  16708. * @param worldMatrix is the world matrix of the particle system
  16709. * @param positionToUpdate is the position vector to update with the result
  16710. * @param particle is the particle we are computed the position for
  16711. * @param isLocal defines if the position should be set in local space
  16712. */
  16713. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16714. /**
  16715. * Clones the current emitter and returns a copy of it
  16716. * @returns the new emitter
  16717. */
  16718. clone(): PointParticleEmitter;
  16719. /**
  16720. * Called by the GPUParticleSystem to setup the update shader
  16721. * @param effect defines the update shader
  16722. */
  16723. applyToShader(effect: Effect): void;
  16724. /**
  16725. * Returns a string to use to update the GPU particles update shader
  16726. * @returns a string containng the defines string
  16727. */
  16728. getEffectDefines(): string;
  16729. /**
  16730. * Returns the string "PointParticleEmitter"
  16731. * @returns a string containing the class name
  16732. */
  16733. getClassName(): string;
  16734. /**
  16735. * Serializes the particle system to a JSON object.
  16736. * @returns the JSON object
  16737. */
  16738. serialize(): any;
  16739. /**
  16740. * Parse properties from a JSON object
  16741. * @param serializationObject defines the JSON object
  16742. */
  16743. parse(serializationObject: any): void;
  16744. }
  16745. }
  16746. declare module BABYLON {
  16747. /**
  16748. * Particle emitter emitting particles from the inside of a sphere.
  16749. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16750. */
  16751. export class SphereParticleEmitter implements IParticleEmitterType {
  16752. /**
  16753. * The radius of the emission sphere.
  16754. */
  16755. radius: number;
  16756. /**
  16757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16758. */
  16759. radiusRange: number;
  16760. /**
  16761. * How much to randomize the particle direction [0-1].
  16762. */
  16763. directionRandomizer: number;
  16764. /**
  16765. * Creates a new instance SphereParticleEmitter
  16766. * @param radius the radius of the emission sphere (1 by default)
  16767. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16768. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16769. */
  16770. constructor(
  16771. /**
  16772. * The radius of the emission sphere.
  16773. */
  16774. radius?: number,
  16775. /**
  16776. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16777. */
  16778. radiusRange?: number,
  16779. /**
  16780. * How much to randomize the particle direction [0-1].
  16781. */
  16782. directionRandomizer?: number);
  16783. /**
  16784. * Called by the particle System when the direction is computed for the created particle.
  16785. * @param worldMatrix is the world matrix of the particle system
  16786. * @param directionToUpdate is the direction vector to update with the result
  16787. * @param particle is the particle we are computed the direction for
  16788. * @param isLocal defines if the direction should be set in local space
  16789. */
  16790. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16791. /**
  16792. * Called by the particle System when the position is computed for the created particle.
  16793. * @param worldMatrix is the world matrix of the particle system
  16794. * @param positionToUpdate is the position vector to update with the result
  16795. * @param particle is the particle we are computed the position for
  16796. * @param isLocal defines if the position should be set in local space
  16797. */
  16798. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16799. /**
  16800. * Clones the current emitter and returns a copy of it
  16801. * @returns the new emitter
  16802. */
  16803. clone(): SphereParticleEmitter;
  16804. /**
  16805. * Called by the GPUParticleSystem to setup the update shader
  16806. * @param effect defines the update shader
  16807. */
  16808. applyToShader(effect: Effect): void;
  16809. /**
  16810. * Returns a string to use to update the GPU particles update shader
  16811. * @returns a string containng the defines string
  16812. */
  16813. getEffectDefines(): string;
  16814. /**
  16815. * Returns the string "SphereParticleEmitter"
  16816. * @returns a string containing the class name
  16817. */
  16818. getClassName(): string;
  16819. /**
  16820. * Serializes the particle system to a JSON object.
  16821. * @returns the JSON object
  16822. */
  16823. serialize(): any;
  16824. /**
  16825. * Parse properties from a JSON object
  16826. * @param serializationObject defines the JSON object
  16827. */
  16828. parse(serializationObject: any): void;
  16829. }
  16830. /**
  16831. * Particle emitter emitting particles from the inside of a sphere.
  16832. * It emits the particles randomly between two vectors.
  16833. */
  16834. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16835. /**
  16836. * The min limit of the emission direction.
  16837. */
  16838. direction1: Vector3;
  16839. /**
  16840. * The max limit of the emission direction.
  16841. */
  16842. direction2: Vector3;
  16843. /**
  16844. * Creates a new instance SphereDirectedParticleEmitter
  16845. * @param radius the radius of the emission sphere (1 by default)
  16846. * @param direction1 the min limit of the emission direction (up vector by default)
  16847. * @param direction2 the max limit of the emission direction (up vector by default)
  16848. */
  16849. constructor(radius?: number,
  16850. /**
  16851. * The min limit of the emission direction.
  16852. */
  16853. direction1?: Vector3,
  16854. /**
  16855. * The max limit of the emission direction.
  16856. */
  16857. direction2?: Vector3);
  16858. /**
  16859. * Called by the particle System when the direction is computed for the created particle.
  16860. * @param worldMatrix is the world matrix of the particle system
  16861. * @param directionToUpdate is the direction vector to update with the result
  16862. * @param particle is the particle we are computed the direction for
  16863. */
  16864. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16865. /**
  16866. * Clones the current emitter and returns a copy of it
  16867. * @returns the new emitter
  16868. */
  16869. clone(): SphereDirectedParticleEmitter;
  16870. /**
  16871. * Called by the GPUParticleSystem to setup the update shader
  16872. * @param effect defines the update shader
  16873. */
  16874. applyToShader(effect: Effect): void;
  16875. /**
  16876. * Returns a string to use to update the GPU particles update shader
  16877. * @returns a string containng the defines string
  16878. */
  16879. getEffectDefines(): string;
  16880. /**
  16881. * Returns the string "SphereDirectedParticleEmitter"
  16882. * @returns a string containing the class name
  16883. */
  16884. getClassName(): string;
  16885. /**
  16886. * Serializes the particle system to a JSON object.
  16887. * @returns the JSON object
  16888. */
  16889. serialize(): any;
  16890. /**
  16891. * Parse properties from a JSON object
  16892. * @param serializationObject defines the JSON object
  16893. */
  16894. parse(serializationObject: any): void;
  16895. }
  16896. }
  16897. declare module BABYLON {
  16898. /**
  16899. * Particle emitter emitting particles from a custom list of positions.
  16900. */
  16901. export class CustomParticleEmitter implements IParticleEmitterType {
  16902. /**
  16903. * Gets or sets the position generator that will create the inital position of each particle.
  16904. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16905. */
  16906. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16907. /**
  16908. * Gets or sets the destination generator that will create the final destination of each particle.
  16909. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16910. */
  16911. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16912. /**
  16913. * Creates a new instance CustomParticleEmitter
  16914. */
  16915. constructor();
  16916. /**
  16917. * Called by the particle System when the direction is computed for the created particle.
  16918. * @param worldMatrix is the world matrix of the particle system
  16919. * @param directionToUpdate is the direction vector to update with the result
  16920. * @param particle is the particle we are computed the direction for
  16921. * @param isLocal defines if the direction should be set in local space
  16922. */
  16923. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16924. /**
  16925. * Called by the particle System when the position is computed for the created particle.
  16926. * @param worldMatrix is the world matrix of the particle system
  16927. * @param positionToUpdate is the position vector to update with the result
  16928. * @param particle is the particle we are computed the position for
  16929. * @param isLocal defines if the position should be set in local space
  16930. */
  16931. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16932. /**
  16933. * Clones the current emitter and returns a copy of it
  16934. * @returns the new emitter
  16935. */
  16936. clone(): CustomParticleEmitter;
  16937. /**
  16938. * Called by the GPUParticleSystem to setup the update shader
  16939. * @param effect defines the update shader
  16940. */
  16941. applyToShader(effect: Effect): void;
  16942. /**
  16943. * Returns a string to use to update the GPU particles update shader
  16944. * @returns a string containng the defines string
  16945. */
  16946. getEffectDefines(): string;
  16947. /**
  16948. * Returns the string "PointParticleEmitter"
  16949. * @returns a string containing the class name
  16950. */
  16951. getClassName(): string;
  16952. /**
  16953. * Serializes the particle system to a JSON object.
  16954. * @returns the JSON object
  16955. */
  16956. serialize(): any;
  16957. /**
  16958. * Parse properties from a JSON object
  16959. * @param serializationObject defines the JSON object
  16960. */
  16961. parse(serializationObject: any): void;
  16962. }
  16963. }
  16964. declare module BABYLON {
  16965. /**
  16966. * Particle emitter emitting particles from the inside of a box.
  16967. * It emits the particles randomly between 2 given directions.
  16968. */
  16969. export class MeshParticleEmitter implements IParticleEmitterType {
  16970. private _indices;
  16971. private _positions;
  16972. private _normals;
  16973. private _storedNormal;
  16974. private _mesh;
  16975. /**
  16976. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16977. */
  16978. direction1: Vector3;
  16979. /**
  16980. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16981. */
  16982. direction2: Vector3;
  16983. /**
  16984. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16985. */
  16986. useMeshNormalsForDirection: boolean;
  16987. /** Defines the mesh to use as source */
  16988. get mesh(): Nullable<AbstractMesh>;
  16989. set mesh(value: Nullable<AbstractMesh>);
  16990. /**
  16991. * Creates a new instance MeshParticleEmitter
  16992. * @param mesh defines the mesh to use as source
  16993. */
  16994. constructor(mesh?: Nullable<AbstractMesh>);
  16995. /**
  16996. * Called by the particle System when the direction is computed for the created particle.
  16997. * @param worldMatrix is the world matrix of the particle system
  16998. * @param directionToUpdate is the direction vector to update with the result
  16999. * @param particle is the particle we are computed the direction for
  17000. * @param isLocal defines if the direction should be set in local space
  17001. */
  17002. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17003. /**
  17004. * Called by the particle System when the position is computed for the created particle.
  17005. * @param worldMatrix is the world matrix of the particle system
  17006. * @param positionToUpdate is the position vector to update with the result
  17007. * @param particle is the particle we are computed the position for
  17008. * @param isLocal defines if the position should be set in local space
  17009. */
  17010. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17011. /**
  17012. * Clones the current emitter and returns a copy of it
  17013. * @returns the new emitter
  17014. */
  17015. clone(): MeshParticleEmitter;
  17016. /**
  17017. * Called by the GPUParticleSystem to setup the update shader
  17018. * @param effect defines the update shader
  17019. */
  17020. applyToShader(effect: Effect): void;
  17021. /**
  17022. * Returns a string to use to update the GPU particles update shader
  17023. * @returns a string containng the defines string
  17024. */
  17025. getEffectDefines(): string;
  17026. /**
  17027. * Returns the string "BoxParticleEmitter"
  17028. * @returns a string containing the class name
  17029. */
  17030. getClassName(): string;
  17031. /**
  17032. * Serializes the particle system to a JSON object.
  17033. * @returns the JSON object
  17034. */
  17035. serialize(): any;
  17036. /**
  17037. * Parse properties from a JSON object
  17038. * @param serializationObject defines the JSON object
  17039. * @param scene defines the hosting scene
  17040. */
  17041. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17042. }
  17043. }
  17044. declare module BABYLON {
  17045. /**
  17046. * Interface representing a particle system in Babylon.js.
  17047. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17048. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17049. */
  17050. export interface IParticleSystem {
  17051. /**
  17052. * List of animations used by the particle system.
  17053. */
  17054. animations: Animation[];
  17055. /**
  17056. * The id of the Particle system.
  17057. */
  17058. id: string;
  17059. /**
  17060. * The name of the Particle system.
  17061. */
  17062. name: string;
  17063. /**
  17064. * The emitter represents the Mesh or position we are attaching the particle system to.
  17065. */
  17066. emitter: Nullable<AbstractMesh | Vector3>;
  17067. /**
  17068. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17069. */
  17070. isBillboardBased: boolean;
  17071. /**
  17072. * The rendering group used by the Particle system to chose when to render.
  17073. */
  17074. renderingGroupId: number;
  17075. /**
  17076. * The layer mask we are rendering the particles through.
  17077. */
  17078. layerMask: number;
  17079. /**
  17080. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17081. */
  17082. updateSpeed: number;
  17083. /**
  17084. * The amount of time the particle system is running (depends of the overall update speed).
  17085. */
  17086. targetStopDuration: number;
  17087. /**
  17088. * The texture used to render each particle. (this can be a spritesheet)
  17089. */
  17090. particleTexture: Nullable<BaseTexture>;
  17091. /**
  17092. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17093. */
  17094. blendMode: number;
  17095. /**
  17096. * Minimum life time of emitting particles.
  17097. */
  17098. minLifeTime: number;
  17099. /**
  17100. * Maximum life time of emitting particles.
  17101. */
  17102. maxLifeTime: number;
  17103. /**
  17104. * Minimum Size of emitting particles.
  17105. */
  17106. minSize: number;
  17107. /**
  17108. * Maximum Size of emitting particles.
  17109. */
  17110. maxSize: number;
  17111. /**
  17112. * Minimum scale of emitting particles on X axis.
  17113. */
  17114. minScaleX: number;
  17115. /**
  17116. * Maximum scale of emitting particles on X axis.
  17117. */
  17118. maxScaleX: number;
  17119. /**
  17120. * Minimum scale of emitting particles on Y axis.
  17121. */
  17122. minScaleY: number;
  17123. /**
  17124. * Maximum scale of emitting particles on Y axis.
  17125. */
  17126. maxScaleY: number;
  17127. /**
  17128. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17129. */
  17130. color1: Color4;
  17131. /**
  17132. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17133. */
  17134. color2: Color4;
  17135. /**
  17136. * Color the particle will have at the end of its lifetime.
  17137. */
  17138. colorDead: Color4;
  17139. /**
  17140. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17141. */
  17142. emitRate: number;
  17143. /**
  17144. * You can use gravity if you want to give an orientation to your particles.
  17145. */
  17146. gravity: Vector3;
  17147. /**
  17148. * Minimum power of emitting particles.
  17149. */
  17150. minEmitPower: number;
  17151. /**
  17152. * Maximum power of emitting particles.
  17153. */
  17154. maxEmitPower: number;
  17155. /**
  17156. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17157. */
  17158. minAngularSpeed: number;
  17159. /**
  17160. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17161. */
  17162. maxAngularSpeed: number;
  17163. /**
  17164. * Gets or sets the minimal initial rotation in radians.
  17165. */
  17166. minInitialRotation: number;
  17167. /**
  17168. * Gets or sets the maximal initial rotation in radians.
  17169. */
  17170. maxInitialRotation: number;
  17171. /**
  17172. * The particle emitter type defines the emitter used by the particle system.
  17173. * It can be for example box, sphere, or cone...
  17174. */
  17175. particleEmitterType: Nullable<IParticleEmitterType>;
  17176. /**
  17177. * Defines the delay in milliseconds before starting the system (0 by default)
  17178. */
  17179. startDelay: number;
  17180. /**
  17181. * 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
  17182. */
  17183. preWarmCycles: number;
  17184. /**
  17185. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17186. */
  17187. preWarmStepOffset: number;
  17188. /**
  17189. * 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)
  17190. */
  17191. spriteCellChangeSpeed: number;
  17192. /**
  17193. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17194. */
  17195. startSpriteCellID: number;
  17196. /**
  17197. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17198. */
  17199. endSpriteCellID: number;
  17200. /**
  17201. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17202. */
  17203. spriteCellWidth: number;
  17204. /**
  17205. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17206. */
  17207. spriteCellHeight: number;
  17208. /**
  17209. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17210. */
  17211. spriteRandomStartCell: boolean;
  17212. /**
  17213. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17214. */
  17215. isAnimationSheetEnabled: boolean;
  17216. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17217. translationPivot: Vector2;
  17218. /**
  17219. * Gets or sets a texture used to add random noise to particle positions
  17220. */
  17221. noiseTexture: Nullable<BaseTexture>;
  17222. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17223. noiseStrength: Vector3;
  17224. /**
  17225. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17226. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17227. */
  17228. billboardMode: number;
  17229. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17230. limitVelocityDamping: number;
  17231. /**
  17232. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17233. */
  17234. beginAnimationOnStart: boolean;
  17235. /**
  17236. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17237. */
  17238. beginAnimationFrom: number;
  17239. /**
  17240. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17241. */
  17242. beginAnimationTo: number;
  17243. /**
  17244. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17245. */
  17246. beginAnimationLoop: boolean;
  17247. /**
  17248. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17249. */
  17250. disposeOnStop: boolean;
  17251. /**
  17252. * Specifies if the particles are updated in emitter local space or world space
  17253. */
  17254. isLocal: boolean;
  17255. /** Snippet ID if the particle system was created from the snippet server */
  17256. snippetId: string;
  17257. /** Gets or sets a matrix to use to compute projection */
  17258. defaultProjectionMatrix: Matrix;
  17259. /**
  17260. * Gets the maximum number of particles active at the same time.
  17261. * @returns The max number of active particles.
  17262. */
  17263. getCapacity(): number;
  17264. /**
  17265. * Gets the number of particles active at the same time.
  17266. * @returns The number of active particles.
  17267. */
  17268. getActiveCount(): number;
  17269. /**
  17270. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17271. * @returns True if it has been started, otherwise false.
  17272. */
  17273. isStarted(): boolean;
  17274. /**
  17275. * Animates the particle system for this frame.
  17276. */
  17277. animate(): void;
  17278. /**
  17279. * Renders the particle system in its current state.
  17280. * @returns the current number of particles
  17281. */
  17282. render(): number;
  17283. /**
  17284. * Dispose the particle system and frees its associated resources.
  17285. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17286. */
  17287. dispose(disposeTexture?: boolean): void;
  17288. /**
  17289. * An event triggered when the system is disposed
  17290. */
  17291. onDisposeObservable: Observable<IParticleSystem>;
  17292. /**
  17293. * An event triggered when the system is stopped
  17294. */
  17295. onStoppedObservable: Observable<IParticleSystem>;
  17296. /**
  17297. * Clones the particle system.
  17298. * @param name The name of the cloned object
  17299. * @param newEmitter The new emitter to use
  17300. * @returns the cloned particle system
  17301. */
  17302. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17303. /**
  17304. * Serializes the particle system to a JSON object
  17305. * @param serializeTexture defines if the texture must be serialized as well
  17306. * @returns the JSON object
  17307. */
  17308. serialize(serializeTexture: boolean): any;
  17309. /**
  17310. * Rebuild the particle system
  17311. */
  17312. rebuild(): void;
  17313. /** Force the system to rebuild all gradients that need to be resync */
  17314. forceRefreshGradients(): void;
  17315. /**
  17316. * Starts the particle system and begins to emit
  17317. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17318. */
  17319. start(delay?: number): void;
  17320. /**
  17321. * Stops the particle system.
  17322. */
  17323. stop(): void;
  17324. /**
  17325. * Remove all active particles
  17326. */
  17327. reset(): void;
  17328. /**
  17329. * Gets a boolean indicating that the system is stopping
  17330. * @returns true if the system is currently stopping
  17331. */
  17332. isStopping(): boolean;
  17333. /**
  17334. * Is this system ready to be used/rendered
  17335. * @return true if the system is ready
  17336. */
  17337. isReady(): boolean;
  17338. /**
  17339. * Returns the string "ParticleSystem"
  17340. * @returns a string containing the class name
  17341. */
  17342. getClassName(): string;
  17343. /**
  17344. * Gets the custom effect used to render the particles
  17345. * @param blendMode Blend mode for which the effect should be retrieved
  17346. * @returns The effect
  17347. */
  17348. getCustomEffect(blendMode: number): Nullable<Effect>;
  17349. /**
  17350. * Sets the custom effect used to render the particles
  17351. * @param effect The effect to set
  17352. * @param blendMode Blend mode for which the effect should be set
  17353. */
  17354. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17355. /**
  17356. * Fill the defines array according to the current settings of the particle system
  17357. * @param defines Array to be updated
  17358. * @param blendMode blend mode to take into account when updating the array
  17359. */
  17360. fillDefines(defines: Array<string>, blendMode: number): void;
  17361. /**
  17362. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17363. * @param uniforms Uniforms array to fill
  17364. * @param attributes Attributes array to fill
  17365. * @param samplers Samplers array to fill
  17366. */
  17367. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17368. /**
  17369. * Observable that will be called just before the particles are drawn
  17370. */
  17371. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17372. /**
  17373. * Gets the name of the particle vertex shader
  17374. */
  17375. vertexShaderName: string;
  17376. /**
  17377. * Adds a new color gradient
  17378. * @param gradient defines the gradient to use (between 0 and 1)
  17379. * @param color1 defines the color to affect to the specified gradient
  17380. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17381. * @returns the current particle system
  17382. */
  17383. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17384. /**
  17385. * Remove a specific color gradient
  17386. * @param gradient defines the gradient to remove
  17387. * @returns the current particle system
  17388. */
  17389. removeColorGradient(gradient: number): IParticleSystem;
  17390. /**
  17391. * Adds a new size gradient
  17392. * @param gradient defines the gradient to use (between 0 and 1)
  17393. * @param factor defines the size factor to affect to the specified gradient
  17394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17395. * @returns the current particle system
  17396. */
  17397. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17398. /**
  17399. * Remove a specific size gradient
  17400. * @param gradient defines the gradient to remove
  17401. * @returns the current particle system
  17402. */
  17403. removeSizeGradient(gradient: number): IParticleSystem;
  17404. /**
  17405. * Gets the current list of color gradients.
  17406. * You must use addColorGradient and removeColorGradient to udpate this list
  17407. * @returns the list of color gradients
  17408. */
  17409. getColorGradients(): Nullable<Array<ColorGradient>>;
  17410. /**
  17411. * Gets the current list of size gradients.
  17412. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17413. * @returns the list of size gradients
  17414. */
  17415. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17416. /**
  17417. * Gets the current list of angular speed gradients.
  17418. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17419. * @returns the list of angular speed gradients
  17420. */
  17421. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17422. /**
  17423. * Adds a new angular speed gradient
  17424. * @param gradient defines the gradient to use (between 0 and 1)
  17425. * @param factor defines the angular speed to affect to the specified gradient
  17426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17427. * @returns the current particle system
  17428. */
  17429. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17430. /**
  17431. * Remove a specific angular speed gradient
  17432. * @param gradient defines the gradient to remove
  17433. * @returns the current particle system
  17434. */
  17435. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17436. /**
  17437. * Gets the current list of velocity gradients.
  17438. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17439. * @returns the list of velocity gradients
  17440. */
  17441. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17442. /**
  17443. * Adds a new velocity gradient
  17444. * @param gradient defines the gradient to use (between 0 and 1)
  17445. * @param factor defines the velocity to affect to the specified gradient
  17446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17447. * @returns the current particle system
  17448. */
  17449. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17450. /**
  17451. * Remove a specific velocity gradient
  17452. * @param gradient defines the gradient to remove
  17453. * @returns the current particle system
  17454. */
  17455. removeVelocityGradient(gradient: number): IParticleSystem;
  17456. /**
  17457. * Gets the current list of limit velocity gradients.
  17458. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17459. * @returns the list of limit velocity gradients
  17460. */
  17461. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17462. /**
  17463. * Adds a new limit velocity gradient
  17464. * @param gradient defines the gradient to use (between 0 and 1)
  17465. * @param factor defines the limit velocity to affect to the specified gradient
  17466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17467. * @returns the current particle system
  17468. */
  17469. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17470. /**
  17471. * Remove a specific limit velocity gradient
  17472. * @param gradient defines the gradient to remove
  17473. * @returns the current particle system
  17474. */
  17475. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17476. /**
  17477. * Adds a new drag gradient
  17478. * @param gradient defines the gradient to use (between 0 and 1)
  17479. * @param factor defines the drag to affect to the specified gradient
  17480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17481. * @returns the current particle system
  17482. */
  17483. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17484. /**
  17485. * Remove a specific drag gradient
  17486. * @param gradient defines the gradient to remove
  17487. * @returns the current particle system
  17488. */
  17489. removeDragGradient(gradient: number): IParticleSystem;
  17490. /**
  17491. * Gets the current list of drag gradients.
  17492. * You must use addDragGradient and removeDragGradient to udpate this list
  17493. * @returns the list of drag gradients
  17494. */
  17495. getDragGradients(): Nullable<Array<FactorGradient>>;
  17496. /**
  17497. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17498. * @param gradient defines the gradient to use (between 0 and 1)
  17499. * @param factor defines the emit rate to affect to the specified gradient
  17500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17501. * @returns the current particle system
  17502. */
  17503. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17504. /**
  17505. * Remove a specific emit rate gradient
  17506. * @param gradient defines the gradient to remove
  17507. * @returns the current particle system
  17508. */
  17509. removeEmitRateGradient(gradient: number): IParticleSystem;
  17510. /**
  17511. * Gets the current list of emit rate gradients.
  17512. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17513. * @returns the list of emit rate gradients
  17514. */
  17515. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17516. /**
  17517. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17518. * @param gradient defines the gradient to use (between 0 and 1)
  17519. * @param factor defines the start size to affect to the specified gradient
  17520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17521. * @returns the current particle system
  17522. */
  17523. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17524. /**
  17525. * Remove a specific start size gradient
  17526. * @param gradient defines the gradient to remove
  17527. * @returns the current particle system
  17528. */
  17529. removeStartSizeGradient(gradient: number): IParticleSystem;
  17530. /**
  17531. * Gets the current list of start size gradients.
  17532. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17533. * @returns the list of start size gradients
  17534. */
  17535. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17536. /**
  17537. * Adds a new life time gradient
  17538. * @param gradient defines the gradient to use (between 0 and 1)
  17539. * @param factor defines the life time factor to affect to the specified gradient
  17540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17541. * @returns the current particle system
  17542. */
  17543. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17544. /**
  17545. * Remove a specific life time gradient
  17546. * @param gradient defines the gradient to remove
  17547. * @returns the current particle system
  17548. */
  17549. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17550. /**
  17551. * Gets the current list of life time gradients.
  17552. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17553. * @returns the list of life time gradients
  17554. */
  17555. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17556. /**
  17557. * Gets the current list of color gradients.
  17558. * You must use addColorGradient and removeColorGradient to udpate this list
  17559. * @returns the list of color gradients
  17560. */
  17561. getColorGradients(): Nullable<Array<ColorGradient>>;
  17562. /**
  17563. * Adds a new ramp gradient used to remap particle colors
  17564. * @param gradient defines the gradient to use (between 0 and 1)
  17565. * @param color defines the color to affect to the specified gradient
  17566. * @returns the current particle system
  17567. */
  17568. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17569. /**
  17570. * Gets the current list of ramp gradients.
  17571. * You must use addRampGradient and removeRampGradient to udpate this list
  17572. * @returns the list of ramp gradients
  17573. */
  17574. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17575. /** Gets or sets a boolean indicating that ramp gradients must be used
  17576. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17577. */
  17578. useRampGradients: boolean;
  17579. /**
  17580. * Adds a new color remap gradient
  17581. * @param gradient defines the gradient to use (between 0 and 1)
  17582. * @param min defines the color remap minimal range
  17583. * @param max defines the color remap maximal range
  17584. * @returns the current particle system
  17585. */
  17586. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17587. /**
  17588. * Gets the current list of color remap gradients.
  17589. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17590. * @returns the list of color remap gradients
  17591. */
  17592. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17593. /**
  17594. * Adds a new alpha remap gradient
  17595. * @param gradient defines the gradient to use (between 0 and 1)
  17596. * @param min defines the alpha remap minimal range
  17597. * @param max defines the alpha remap maximal range
  17598. * @returns the current particle system
  17599. */
  17600. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17601. /**
  17602. * Gets the current list of alpha remap gradients.
  17603. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17604. * @returns the list of alpha remap gradients
  17605. */
  17606. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17607. /**
  17608. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17611. * @returns the emitter
  17612. */
  17613. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17614. /**
  17615. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17616. * @param radius The radius of the hemisphere to emit from
  17617. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17618. * @returns the emitter
  17619. */
  17620. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17621. /**
  17622. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17623. * @param radius The radius of the sphere to emit from
  17624. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17625. * @returns the emitter
  17626. */
  17627. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17628. /**
  17629. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17630. * @param radius The radius of the sphere to emit from
  17631. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17632. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17633. * @returns the emitter
  17634. */
  17635. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17636. /**
  17637. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17638. * @param radius The radius of the emission cylinder
  17639. * @param height The height of the emission cylinder
  17640. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17641. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17642. * @returns the emitter
  17643. */
  17644. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17645. /**
  17646. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17647. * @param radius The radius of the cylinder to emit from
  17648. * @param height The height of the emission cylinder
  17649. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17650. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17651. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17652. * @returns the emitter
  17653. */
  17654. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17655. /**
  17656. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17657. * @param radius The radius of the cone to emit from
  17658. * @param angle The base angle of the cone
  17659. * @returns the emitter
  17660. */
  17661. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17662. /**
  17663. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17664. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17665. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17666. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17667. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17668. * @returns the emitter
  17669. */
  17670. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17671. /**
  17672. * Get hosting scene
  17673. * @returns the scene
  17674. */
  17675. getScene(): Nullable<Scene>;
  17676. }
  17677. }
  17678. declare module BABYLON {
  17679. /**
  17680. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17681. */
  17682. export class ColorSplitterBlock extends NodeMaterialBlock {
  17683. /**
  17684. * Create a new ColorSplitterBlock
  17685. * @param name defines the block name
  17686. */
  17687. constructor(name: string);
  17688. /**
  17689. * Gets the current class name
  17690. * @returns the class name
  17691. */
  17692. getClassName(): string;
  17693. /**
  17694. * Gets the rgba component (input)
  17695. */
  17696. get rgba(): NodeMaterialConnectionPoint;
  17697. /**
  17698. * Gets the rgb component (input)
  17699. */
  17700. get rgbIn(): NodeMaterialConnectionPoint;
  17701. /**
  17702. * Gets the rgb component (output)
  17703. */
  17704. get rgbOut(): NodeMaterialConnectionPoint;
  17705. /**
  17706. * Gets the r component (output)
  17707. */
  17708. get r(): NodeMaterialConnectionPoint;
  17709. /**
  17710. * Gets the g component (output)
  17711. */
  17712. get g(): NodeMaterialConnectionPoint;
  17713. /**
  17714. * Gets the b component (output)
  17715. */
  17716. get b(): NodeMaterialConnectionPoint;
  17717. /**
  17718. * Gets the a component (output)
  17719. */
  17720. get a(): NodeMaterialConnectionPoint;
  17721. protected _inputRename(name: string): string;
  17722. protected _outputRename(name: string): string;
  17723. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17724. }
  17725. }
  17726. declare module BABYLON {
  17727. /**
  17728. * Operations supported by the Trigonometry block
  17729. */
  17730. export enum TrigonometryBlockOperations {
  17731. /** Cos */
  17732. Cos = 0,
  17733. /** Sin */
  17734. Sin = 1,
  17735. /** Abs */
  17736. Abs = 2,
  17737. /** Exp */
  17738. Exp = 3,
  17739. /** Exp2 */
  17740. Exp2 = 4,
  17741. /** Round */
  17742. Round = 5,
  17743. /** Floor */
  17744. Floor = 6,
  17745. /** Ceiling */
  17746. Ceiling = 7,
  17747. /** Square root */
  17748. Sqrt = 8,
  17749. /** Log */
  17750. Log = 9,
  17751. /** Tangent */
  17752. Tan = 10,
  17753. /** Arc tangent */
  17754. ArcTan = 11,
  17755. /** Arc cosinus */
  17756. ArcCos = 12,
  17757. /** Arc sinus */
  17758. ArcSin = 13,
  17759. /** Fraction */
  17760. Fract = 14,
  17761. /** Sign */
  17762. Sign = 15,
  17763. /** To radians (from degrees) */
  17764. Radians = 16,
  17765. /** To degrees (from radians) */
  17766. Degrees = 17
  17767. }
  17768. /**
  17769. * Block used to apply trigonometry operation to floats
  17770. */
  17771. export class TrigonometryBlock extends NodeMaterialBlock {
  17772. /**
  17773. * Gets or sets the operation applied by the block
  17774. */
  17775. operation: TrigonometryBlockOperations;
  17776. /**
  17777. * Creates a new TrigonometryBlock
  17778. * @param name defines the block name
  17779. */
  17780. constructor(name: string);
  17781. /**
  17782. * Gets the current class name
  17783. * @returns the class name
  17784. */
  17785. getClassName(): string;
  17786. /**
  17787. * Gets the input component
  17788. */
  17789. get input(): NodeMaterialConnectionPoint;
  17790. /**
  17791. * Gets the output component
  17792. */
  17793. get output(): NodeMaterialConnectionPoint;
  17794. protected _buildBlock(state: NodeMaterialBuildState): this;
  17795. serialize(): any;
  17796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17797. protected _dumpPropertiesCode(): string;
  17798. }
  17799. }
  17800. declare module BABYLON {
  17801. /**
  17802. * Interface used to configure the node material editor
  17803. */
  17804. export interface INodeMaterialEditorOptions {
  17805. /** Define the URl to load node editor script */
  17806. editorURL?: string;
  17807. }
  17808. /** @hidden */
  17809. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17810. NORMAL: boolean;
  17811. TANGENT: boolean;
  17812. UV1: boolean;
  17813. /** BONES */
  17814. NUM_BONE_INFLUENCERS: number;
  17815. BonesPerMesh: number;
  17816. BONETEXTURE: boolean;
  17817. /** MORPH TARGETS */
  17818. MORPHTARGETS: boolean;
  17819. MORPHTARGETS_NORMAL: boolean;
  17820. MORPHTARGETS_TANGENT: boolean;
  17821. MORPHTARGETS_UV: boolean;
  17822. NUM_MORPH_INFLUENCERS: number;
  17823. /** IMAGE PROCESSING */
  17824. IMAGEPROCESSING: boolean;
  17825. VIGNETTE: boolean;
  17826. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17827. VIGNETTEBLENDMODEOPAQUE: boolean;
  17828. TONEMAPPING: boolean;
  17829. TONEMAPPING_ACES: boolean;
  17830. CONTRAST: boolean;
  17831. EXPOSURE: boolean;
  17832. COLORCURVES: boolean;
  17833. COLORGRADING: boolean;
  17834. COLORGRADING3D: boolean;
  17835. SAMPLER3DGREENDEPTH: boolean;
  17836. SAMPLER3DBGRMAP: boolean;
  17837. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17838. /** MISC. */
  17839. BUMPDIRECTUV: number;
  17840. constructor();
  17841. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17842. }
  17843. /**
  17844. * Class used to configure NodeMaterial
  17845. */
  17846. export interface INodeMaterialOptions {
  17847. /**
  17848. * Defines if blocks should emit comments
  17849. */
  17850. emitComments: boolean;
  17851. }
  17852. /**
  17853. * Class used to create a node based material built by assembling shader blocks
  17854. */
  17855. export class NodeMaterial extends PushMaterial {
  17856. private static _BuildIdGenerator;
  17857. private _options;
  17858. private _vertexCompilationState;
  17859. private _fragmentCompilationState;
  17860. private _sharedData;
  17861. private _buildId;
  17862. private _buildWasSuccessful;
  17863. private _cachedWorldViewMatrix;
  17864. private _cachedWorldViewProjectionMatrix;
  17865. private _optimizers;
  17866. private _animationFrame;
  17867. /** Define the Url to load node editor script */
  17868. static EditorURL: string;
  17869. /** Define the Url to load snippets */
  17870. static SnippetUrl: string;
  17871. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17872. static IgnoreTexturesAtLoadTime: boolean;
  17873. private BJSNODEMATERIALEDITOR;
  17874. /** Get the inspector from bundle or global */
  17875. private _getGlobalNodeMaterialEditor;
  17876. /**
  17877. * Snippet ID if the material was created from the snippet server
  17878. */
  17879. snippetId: string;
  17880. /**
  17881. * Gets or sets data used by visual editor
  17882. * @see https://nme.babylonjs.com
  17883. */
  17884. editorData: any;
  17885. /**
  17886. * 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)
  17887. */
  17888. ignoreAlpha: boolean;
  17889. /**
  17890. * Defines the maximum number of lights that can be used in the material
  17891. */
  17892. maxSimultaneousLights: number;
  17893. /**
  17894. * Observable raised when the material is built
  17895. */
  17896. onBuildObservable: Observable<NodeMaterial>;
  17897. /**
  17898. * Gets or sets the root nodes of the material vertex shader
  17899. */
  17900. _vertexOutputNodes: NodeMaterialBlock[];
  17901. /**
  17902. * Gets or sets the root nodes of the material fragment (pixel) shader
  17903. */
  17904. _fragmentOutputNodes: NodeMaterialBlock[];
  17905. /** Gets or sets options to control the node material overall behavior */
  17906. get options(): INodeMaterialOptions;
  17907. set options(options: INodeMaterialOptions);
  17908. /**
  17909. * Default configuration related to image processing available in the standard Material.
  17910. */
  17911. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17912. /**
  17913. * Gets the image processing configuration used either in this material.
  17914. */
  17915. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17916. /**
  17917. * Sets the Default image processing configuration used either in the this material.
  17918. *
  17919. * If sets to null, the scene one is in use.
  17920. */
  17921. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17922. /**
  17923. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17924. */
  17925. attachedBlocks: NodeMaterialBlock[];
  17926. /**
  17927. * Specifies the mode of the node material
  17928. * @hidden
  17929. */
  17930. _mode: NodeMaterialModes;
  17931. /**
  17932. * Gets the mode property
  17933. */
  17934. get mode(): NodeMaterialModes;
  17935. /**
  17936. * A free comment about the material
  17937. */
  17938. comment: string;
  17939. /**
  17940. * Create a new node based material
  17941. * @param name defines the material name
  17942. * @param scene defines the hosting scene
  17943. * @param options defines creation option
  17944. */
  17945. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17946. /**
  17947. * Gets the current class name of the material e.g. "NodeMaterial"
  17948. * @returns the class name
  17949. */
  17950. getClassName(): string;
  17951. /**
  17952. * Keep track of the image processing observer to allow dispose and replace.
  17953. */
  17954. private _imageProcessingObserver;
  17955. /**
  17956. * Attaches a new image processing configuration to the Standard Material.
  17957. * @param configuration
  17958. */
  17959. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17960. /**
  17961. * Get a block by its name
  17962. * @param name defines the name of the block to retrieve
  17963. * @returns the required block or null if not found
  17964. */
  17965. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17966. /**
  17967. * Get a block by its name
  17968. * @param predicate defines the predicate used to find the good candidate
  17969. * @returns the required block or null if not found
  17970. */
  17971. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17972. /**
  17973. * Get an input block by its name
  17974. * @param predicate defines the predicate used to find the good candidate
  17975. * @returns the required input block or null if not found
  17976. */
  17977. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17978. /**
  17979. * Gets the list of input blocks attached to this material
  17980. * @returns an array of InputBlocks
  17981. */
  17982. getInputBlocks(): InputBlock[];
  17983. /**
  17984. * Adds a new optimizer to the list of optimizers
  17985. * @param optimizer defines the optimizers to add
  17986. * @returns the current material
  17987. */
  17988. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17989. /**
  17990. * Remove an optimizer from the list of optimizers
  17991. * @param optimizer defines the optimizers to remove
  17992. * @returns the current material
  17993. */
  17994. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17995. /**
  17996. * Add a new block to the list of output nodes
  17997. * @param node defines the node to add
  17998. * @returns the current material
  17999. */
  18000. addOutputNode(node: NodeMaterialBlock): this;
  18001. /**
  18002. * Remove a block from the list of root nodes
  18003. * @param node defines the node to remove
  18004. * @returns the current material
  18005. */
  18006. removeOutputNode(node: NodeMaterialBlock): this;
  18007. private _addVertexOutputNode;
  18008. private _removeVertexOutputNode;
  18009. private _addFragmentOutputNode;
  18010. private _removeFragmentOutputNode;
  18011. /**
  18012. * Specifies if the material will require alpha blending
  18013. * @returns a boolean specifying if alpha blending is needed
  18014. */
  18015. needAlphaBlending(): boolean;
  18016. /**
  18017. * Specifies if this material should be rendered in alpha test mode
  18018. * @returns a boolean specifying if an alpha test is needed.
  18019. */
  18020. needAlphaTesting(): boolean;
  18021. private _initializeBlock;
  18022. private _resetDualBlocks;
  18023. /**
  18024. * Remove a block from the current node material
  18025. * @param block defines the block to remove
  18026. */
  18027. removeBlock(block: NodeMaterialBlock): void;
  18028. /**
  18029. * Build the material and generates the inner effect
  18030. * @param verbose defines if the build should log activity
  18031. */
  18032. build(verbose?: boolean): void;
  18033. /**
  18034. * Runs an otpimization phase to try to improve the shader code
  18035. */
  18036. optimize(): void;
  18037. private _prepareDefinesForAttributes;
  18038. /**
  18039. * Create a post process from the material
  18040. * @param camera The camera to apply the render pass to.
  18041. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18043. * @param engine The engine which the post process will be applied. (default: current engine)
  18044. * @param reusable If the post process can be reused on the same frame. (default: false)
  18045. * @param textureType Type of textures used when performing the post process. (default: 0)
  18046. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18047. * @returns the post process created
  18048. */
  18049. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18050. /**
  18051. * Create the post process effect from the material
  18052. * @param postProcess The post process to create the effect for
  18053. */
  18054. createEffectForPostProcess(postProcess: PostProcess): void;
  18055. private _createEffectForPostProcess;
  18056. /**
  18057. * Create a new procedural texture based on this node material
  18058. * @param size defines the size of the texture
  18059. * @param scene defines the hosting scene
  18060. * @returns the new procedural texture attached to this node material
  18061. */
  18062. createProceduralTexture(size: number | {
  18063. width: number;
  18064. height: number;
  18065. layers?: number;
  18066. }, scene: Scene): Nullable<ProceduralTexture>;
  18067. private _createEffectForParticles;
  18068. private _checkInternals;
  18069. /**
  18070. * Create the effect to be used as the custom effect for a particle system
  18071. * @param particleSystem Particle system to create the effect for
  18072. * @param onCompiled defines a function to call when the effect creation is successful
  18073. * @param onError defines a function to call when the effect creation has failed
  18074. */
  18075. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18076. private _processDefines;
  18077. /**
  18078. * Get if the submesh is ready to be used and all its information available.
  18079. * Child classes can use it to update shaders
  18080. * @param mesh defines the mesh to check
  18081. * @param subMesh defines which submesh to check
  18082. * @param useInstances specifies that instances should be used
  18083. * @returns a boolean indicating that the submesh is ready or not
  18084. */
  18085. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18086. /**
  18087. * Get a string representing the shaders built by the current node graph
  18088. */
  18089. get compiledShaders(): string;
  18090. /**
  18091. * Binds the world matrix to the material
  18092. * @param world defines the world transformation matrix
  18093. */
  18094. bindOnlyWorldMatrix(world: Matrix): void;
  18095. /**
  18096. * Binds the submesh to this material by preparing the effect and shader to draw
  18097. * @param world defines the world transformation matrix
  18098. * @param mesh defines the mesh containing the submesh
  18099. * @param subMesh defines the submesh to bind the material to
  18100. */
  18101. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18102. /**
  18103. * Gets the active textures from the material
  18104. * @returns an array of textures
  18105. */
  18106. getActiveTextures(): BaseTexture[];
  18107. /**
  18108. * Gets the list of texture blocks
  18109. * @returns an array of texture blocks
  18110. */
  18111. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18112. /**
  18113. * Specifies if the material uses a texture
  18114. * @param texture defines the texture to check against the material
  18115. * @returns a boolean specifying if the material uses the texture
  18116. */
  18117. hasTexture(texture: BaseTexture): boolean;
  18118. /**
  18119. * Disposes the material
  18120. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18121. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18122. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18123. */
  18124. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18125. /** Creates the node editor window. */
  18126. private _createNodeEditor;
  18127. /**
  18128. * Launch the node material editor
  18129. * @param config Define the configuration of the editor
  18130. * @return a promise fulfilled when the node editor is visible
  18131. */
  18132. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18133. /**
  18134. * Clear the current material
  18135. */
  18136. clear(): void;
  18137. /**
  18138. * Clear the current material and set it to a default state
  18139. */
  18140. setToDefault(): void;
  18141. /**
  18142. * Clear the current material and set it to a default state for post process
  18143. */
  18144. setToDefaultPostProcess(): void;
  18145. /**
  18146. * Clear the current material and set it to a default state for procedural texture
  18147. */
  18148. setToDefaultProceduralTexture(): void;
  18149. /**
  18150. * Clear the current material and set it to a default state for particle
  18151. */
  18152. setToDefaultParticle(): void;
  18153. /**
  18154. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18155. * @param url defines the url to load from
  18156. * @returns a promise that will fullfil when the material is fully loaded
  18157. */
  18158. loadAsync(url: string): Promise<void>;
  18159. private _gatherBlocks;
  18160. /**
  18161. * Generate a string containing the code declaration required to create an equivalent of this material
  18162. * @returns a string
  18163. */
  18164. generateCode(): string;
  18165. /**
  18166. * Serializes this material in a JSON representation
  18167. * @returns the serialized material object
  18168. */
  18169. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18170. private _restoreConnections;
  18171. /**
  18172. * Clear the current graph and load a new one from a serialization object
  18173. * @param source defines the JSON representation of the material
  18174. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18175. * @param merge defines whether or not the source must be merged or replace the current content
  18176. */
  18177. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18178. /**
  18179. * Makes a duplicate of the current material.
  18180. * @param name - name to use for the new material.
  18181. */
  18182. clone(name: string): NodeMaterial;
  18183. /**
  18184. * Creates a node material from parsed material data
  18185. * @param source defines the JSON representation of the material
  18186. * @param scene defines the hosting scene
  18187. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18188. * @returns a new node material
  18189. */
  18190. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18191. /**
  18192. * Creates a node material from a snippet saved in a remote file
  18193. * @param name defines the name of the material to create
  18194. * @param url defines the url to load from
  18195. * @param scene defines the hosting scene
  18196. * @returns a promise that will resolve to the new node material
  18197. */
  18198. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18199. /**
  18200. * Creates a node material from a snippet saved by the node material editor
  18201. * @param snippetId defines the snippet to load
  18202. * @param scene defines the hosting scene
  18203. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18204. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18205. * @returns a promise that will resolve to the new node material
  18206. */
  18207. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18208. /**
  18209. * Creates a new node material set to default basic configuration
  18210. * @param name defines the name of the material
  18211. * @param scene defines the hosting scene
  18212. * @returns a new NodeMaterial
  18213. */
  18214. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18215. }
  18216. }
  18217. declare module BABYLON {
  18218. interface ThinEngine {
  18219. /**
  18220. * Unbind a list of render target textures from the webGL context
  18221. * This is used only when drawBuffer extension or webGL2 are active
  18222. * @param textures defines the render target textures to unbind
  18223. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18224. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18225. */
  18226. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18227. /**
  18228. * Create a multi render target texture
  18229. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18230. * @param size defines the size of the texture
  18231. * @param options defines the creation options
  18232. * @returns the cube texture as an InternalTexture
  18233. */
  18234. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18235. /**
  18236. * Update the sample count for a given multiple render target texture
  18237. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18238. * @param textures defines the textures to update
  18239. * @param samples defines the sample count to set
  18240. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18241. */
  18242. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18243. /**
  18244. * Select a subsets of attachments to draw to.
  18245. * @param attachments gl attachments
  18246. */
  18247. bindAttachments(attachments: number[]): void;
  18248. /**
  18249. * Creates a layout object to draw/clear on specific textures in a MRT
  18250. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18251. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18252. */
  18253. buildTextureLayout(textureStatus: boolean[]): number[];
  18254. /**
  18255. * Restores the webgl state to only draw on the main color attachment
  18256. */
  18257. restoreSingleAttachment(): void;
  18258. /**
  18259. * Clears a list of attachments
  18260. * @param attachments list of the attachments
  18261. * @param colorMain clear color for the main attachment (the first one)
  18262. * @param colorOthers clear color for the other attachments
  18263. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18264. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18265. */
  18266. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18267. }
  18268. }
  18269. declare module BABYLON {
  18270. /**
  18271. * Creation options of the multi render target texture.
  18272. */
  18273. export interface IMultiRenderTargetOptions {
  18274. /**
  18275. * Define if the texture needs to create mip maps after render.
  18276. */
  18277. generateMipMaps?: boolean;
  18278. /**
  18279. * Define the types of all the draw buffers we want to create
  18280. */
  18281. types?: number[];
  18282. /**
  18283. * Define the sampling modes of all the draw buffers we want to create
  18284. */
  18285. samplingModes?: number[];
  18286. /**
  18287. * Define if a depth buffer is required
  18288. */
  18289. generateDepthBuffer?: boolean;
  18290. /**
  18291. * Define if a stencil buffer is required
  18292. */
  18293. generateStencilBuffer?: boolean;
  18294. /**
  18295. * Define if a depth texture is required instead of a depth buffer
  18296. */
  18297. generateDepthTexture?: boolean;
  18298. /**
  18299. * Define the number of desired draw buffers
  18300. */
  18301. textureCount?: number;
  18302. /**
  18303. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18304. */
  18305. doNotChangeAspectRatio?: boolean;
  18306. /**
  18307. * Define the default type of the buffers we are creating
  18308. */
  18309. defaultType?: number;
  18310. }
  18311. /**
  18312. * A multi render target, like a render target provides the ability to render to a texture.
  18313. * Unlike the render target, it can render to several draw buffers in one draw.
  18314. * This is specially interesting in deferred rendering or for any effects requiring more than
  18315. * just one color from a single pass.
  18316. */
  18317. export class MultiRenderTarget extends RenderTargetTexture {
  18318. private _internalTextures;
  18319. private _textures;
  18320. private _multiRenderTargetOptions;
  18321. private _count;
  18322. /**
  18323. * Get if draw buffers are currently supported by the used hardware and browser.
  18324. */
  18325. get isSupported(): boolean;
  18326. /**
  18327. * Get the list of textures generated by the multi render target.
  18328. */
  18329. get textures(): Texture[];
  18330. /**
  18331. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18332. */
  18333. get count(): number;
  18334. /**
  18335. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18336. */
  18337. get depthTexture(): Texture;
  18338. /**
  18339. * Set the wrapping mode on U of all the textures we are rendering to.
  18340. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18341. */
  18342. set wrapU(wrap: number);
  18343. /**
  18344. * Set the wrapping mode on V of all the textures we are rendering to.
  18345. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18346. */
  18347. set wrapV(wrap: number);
  18348. /**
  18349. * Instantiate a new multi render target texture.
  18350. * A multi render target, like a render target provides the ability to render to a texture.
  18351. * Unlike the render target, it can render to several draw buffers in one draw.
  18352. * This is specially interesting in deferred rendering or for any effects requiring more than
  18353. * just one color from a single pass.
  18354. * @param name Define the name of the texture
  18355. * @param size Define the size of the buffers to render to
  18356. * @param count Define the number of target we are rendering into
  18357. * @param scene Define the scene the texture belongs to
  18358. * @param options Define the options used to create the multi render target
  18359. */
  18360. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18361. private _initTypes;
  18362. /** @hidden */
  18363. _rebuild(forceFullRebuild?: boolean): void;
  18364. private _createInternalTextures;
  18365. private _createTextures;
  18366. /**
  18367. * Replaces a texture within the MRT.
  18368. * @param texture The new texture to insert in the MRT
  18369. * @param index The index of the texture to replace
  18370. */
  18371. replaceTexture(texture: Texture, index: number): void;
  18372. /**
  18373. * Define the number of samples used if MSAA is enabled.
  18374. */
  18375. get samples(): number;
  18376. set samples(value: number);
  18377. /**
  18378. * Resize all the textures in the multi render target.
  18379. * Be careful as it will recreate all the data in the new texture.
  18380. * @param size Define the new size
  18381. */
  18382. resize(size: any): void;
  18383. /**
  18384. * Changes the number of render targets in this MRT
  18385. * Be careful as it will recreate all the data in the new texture.
  18386. * @param count new texture count
  18387. * @param options Specifies texture types and sampling modes for new textures
  18388. */
  18389. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18390. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18391. /**
  18392. * Dispose the render targets and their associated resources
  18393. */
  18394. dispose(): void;
  18395. /**
  18396. * Release all the underlying texture used as draw buffers.
  18397. */
  18398. releaseInternalTextures(): void;
  18399. }
  18400. }
  18401. declare module BABYLON {
  18402. /** @hidden */
  18403. export var imageProcessingPixelShader: {
  18404. name: string;
  18405. shader: string;
  18406. };
  18407. }
  18408. declare module BABYLON {
  18409. /**
  18410. * ImageProcessingPostProcess
  18411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18412. */
  18413. export class ImageProcessingPostProcess extends PostProcess {
  18414. /**
  18415. * Default configuration related to image processing available in the PBR Material.
  18416. */
  18417. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18418. /**
  18419. * Gets the image processing configuration used either in this material.
  18420. */
  18421. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18422. /**
  18423. * Sets the Default image processing configuration used either in the this material.
  18424. *
  18425. * If sets to null, the scene one is in use.
  18426. */
  18427. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18428. /**
  18429. * Keep track of the image processing observer to allow dispose and replace.
  18430. */
  18431. private _imageProcessingObserver;
  18432. /**
  18433. * Attaches a new image processing configuration to the PBR Material.
  18434. * @param configuration
  18435. */
  18436. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18437. /**
  18438. * If the post process is supported.
  18439. */
  18440. get isSupported(): boolean;
  18441. /**
  18442. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18443. */
  18444. get colorCurves(): Nullable<ColorCurves>;
  18445. /**
  18446. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18447. */
  18448. set colorCurves(value: Nullable<ColorCurves>);
  18449. /**
  18450. * Gets wether the color curves effect is enabled.
  18451. */
  18452. get colorCurvesEnabled(): boolean;
  18453. /**
  18454. * Sets wether the color curves effect is enabled.
  18455. */
  18456. set colorCurvesEnabled(value: boolean);
  18457. /**
  18458. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18459. */
  18460. get colorGradingTexture(): Nullable<BaseTexture>;
  18461. /**
  18462. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18463. */
  18464. set colorGradingTexture(value: Nullable<BaseTexture>);
  18465. /**
  18466. * Gets wether the color grading effect is enabled.
  18467. */
  18468. get colorGradingEnabled(): boolean;
  18469. /**
  18470. * Gets wether the color grading effect is enabled.
  18471. */
  18472. set colorGradingEnabled(value: boolean);
  18473. /**
  18474. * Gets exposure used in the effect.
  18475. */
  18476. get exposure(): number;
  18477. /**
  18478. * Sets exposure used in the effect.
  18479. */
  18480. set exposure(value: number);
  18481. /**
  18482. * Gets wether tonemapping is enabled or not.
  18483. */
  18484. get toneMappingEnabled(): boolean;
  18485. /**
  18486. * Sets wether tonemapping is enabled or not
  18487. */
  18488. set toneMappingEnabled(value: boolean);
  18489. /**
  18490. * Gets the type of tone mapping effect.
  18491. */
  18492. get toneMappingType(): number;
  18493. /**
  18494. * Sets the type of tone mapping effect.
  18495. */
  18496. set toneMappingType(value: number);
  18497. /**
  18498. * Gets contrast used in the effect.
  18499. */
  18500. get contrast(): number;
  18501. /**
  18502. * Sets contrast used in the effect.
  18503. */
  18504. set contrast(value: number);
  18505. /**
  18506. * Gets Vignette stretch size.
  18507. */
  18508. get vignetteStretch(): number;
  18509. /**
  18510. * Sets Vignette stretch size.
  18511. */
  18512. set vignetteStretch(value: number);
  18513. /**
  18514. * Gets Vignette centre X Offset.
  18515. */
  18516. get vignetteCentreX(): number;
  18517. /**
  18518. * Sets Vignette centre X Offset.
  18519. */
  18520. set vignetteCentreX(value: number);
  18521. /**
  18522. * Gets Vignette centre Y Offset.
  18523. */
  18524. get vignetteCentreY(): number;
  18525. /**
  18526. * Sets Vignette centre Y Offset.
  18527. */
  18528. set vignetteCentreY(value: number);
  18529. /**
  18530. * Gets Vignette weight or intensity of the vignette effect.
  18531. */
  18532. get vignetteWeight(): number;
  18533. /**
  18534. * Sets Vignette weight or intensity of the vignette effect.
  18535. */
  18536. set vignetteWeight(value: number);
  18537. /**
  18538. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18539. * if vignetteEnabled is set to true.
  18540. */
  18541. get vignetteColor(): Color4;
  18542. /**
  18543. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18544. * if vignetteEnabled is set to true.
  18545. */
  18546. set vignetteColor(value: Color4);
  18547. /**
  18548. * Gets Camera field of view used by the Vignette effect.
  18549. */
  18550. get vignetteCameraFov(): number;
  18551. /**
  18552. * Sets Camera field of view used by the Vignette effect.
  18553. */
  18554. set vignetteCameraFov(value: number);
  18555. /**
  18556. * Gets the vignette blend mode allowing different kind of effect.
  18557. */
  18558. get vignetteBlendMode(): number;
  18559. /**
  18560. * Sets the vignette blend mode allowing different kind of effect.
  18561. */
  18562. set vignetteBlendMode(value: number);
  18563. /**
  18564. * Gets wether the vignette effect is enabled.
  18565. */
  18566. get vignetteEnabled(): boolean;
  18567. /**
  18568. * Sets wether the vignette effect is enabled.
  18569. */
  18570. set vignetteEnabled(value: boolean);
  18571. private _fromLinearSpace;
  18572. /**
  18573. * Gets wether the input of the processing is in Gamma or Linear Space.
  18574. */
  18575. get fromLinearSpace(): boolean;
  18576. /**
  18577. * Sets wether the input of the processing is in Gamma or Linear Space.
  18578. */
  18579. set fromLinearSpace(value: boolean);
  18580. /**
  18581. * Defines cache preventing GC.
  18582. */
  18583. private _defines;
  18584. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18585. /**
  18586. * "ImageProcessingPostProcess"
  18587. * @returns "ImageProcessingPostProcess"
  18588. */
  18589. getClassName(): string;
  18590. /**
  18591. * @hidden
  18592. */
  18593. _updateParameters(): void;
  18594. dispose(camera?: Camera): void;
  18595. }
  18596. }
  18597. declare module BABYLON {
  18598. /**
  18599. * Interface for defining prepass effects in the prepass post-process pipeline
  18600. */
  18601. export interface PrePassEffectConfiguration {
  18602. /**
  18603. * Name of the effect
  18604. */
  18605. name: string;
  18606. /**
  18607. * Post process to attach for this effect
  18608. */
  18609. postProcess?: PostProcess;
  18610. /**
  18611. * Textures required in the MRT
  18612. */
  18613. texturesRequired: number[];
  18614. /**
  18615. * Is the effect enabled
  18616. */
  18617. enabled: boolean;
  18618. /**
  18619. * Disposes the effect configuration
  18620. */
  18621. dispose?: () => void;
  18622. /**
  18623. * Creates the associated post process
  18624. */
  18625. createPostProcess?: () => PostProcess;
  18626. }
  18627. }
  18628. declare module BABYLON {
  18629. /**
  18630. * Options to be used when creating a FresnelParameters.
  18631. */
  18632. export type IFresnelParametersCreationOptions = {
  18633. /**
  18634. * Define the color used on edges (grazing angle)
  18635. */
  18636. leftColor?: Color3;
  18637. /**
  18638. * Define the color used on center
  18639. */
  18640. rightColor?: Color3;
  18641. /**
  18642. * Define bias applied to computed fresnel term
  18643. */
  18644. bias?: number;
  18645. /**
  18646. * Defined the power exponent applied to fresnel term
  18647. */
  18648. power?: number;
  18649. /**
  18650. * Define if the fresnel effect is enable or not.
  18651. */
  18652. isEnabled?: boolean;
  18653. };
  18654. /**
  18655. * Serialized format for FresnelParameters.
  18656. */
  18657. export type IFresnelParametersSerialized = {
  18658. /**
  18659. * Define the color used on edges (grazing angle) [as an array]
  18660. */
  18661. leftColor: number[];
  18662. /**
  18663. * Define the color used on center [as an array]
  18664. */
  18665. rightColor: number[];
  18666. /**
  18667. * Define bias applied to computed fresnel term
  18668. */
  18669. bias: number;
  18670. /**
  18671. * Defined the power exponent applied to fresnel term
  18672. */
  18673. power?: number;
  18674. /**
  18675. * Define if the fresnel effect is enable or not.
  18676. */
  18677. isEnabled: boolean;
  18678. };
  18679. /**
  18680. * This represents all the required information to add a fresnel effect on a material:
  18681. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18682. */
  18683. export class FresnelParameters {
  18684. private _isEnabled;
  18685. /**
  18686. * Define if the fresnel effect is enable or not.
  18687. */
  18688. get isEnabled(): boolean;
  18689. set isEnabled(value: boolean);
  18690. /**
  18691. * Define the color used on edges (grazing angle)
  18692. */
  18693. leftColor: Color3;
  18694. /**
  18695. * Define the color used on center
  18696. */
  18697. rightColor: Color3;
  18698. /**
  18699. * Define bias applied to computed fresnel term
  18700. */
  18701. bias: number;
  18702. /**
  18703. * Defined the power exponent applied to fresnel term
  18704. */
  18705. power: number;
  18706. /**
  18707. * Creates a new FresnelParameters object.
  18708. *
  18709. * @param options provide your own settings to optionally to override defaults
  18710. */
  18711. constructor(options?: IFresnelParametersCreationOptions);
  18712. /**
  18713. * Clones the current fresnel and its valuues
  18714. * @returns a clone fresnel configuration
  18715. */
  18716. clone(): FresnelParameters;
  18717. /**
  18718. * Determines equality between FresnelParameters objects
  18719. * @param otherFresnelParameters defines the second operand
  18720. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18721. */
  18722. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18723. /**
  18724. * Serializes the current fresnel parameters to a JSON representation.
  18725. * @return the JSON serialization
  18726. */
  18727. serialize(): IFresnelParametersSerialized;
  18728. /**
  18729. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18730. * @param parsedFresnelParameters Define the JSON representation
  18731. * @returns the parsed parameters
  18732. */
  18733. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18734. }
  18735. }
  18736. declare module BABYLON {
  18737. /**
  18738. * This groups all the flags used to control the materials channel.
  18739. */
  18740. export class MaterialFlags {
  18741. private static _DiffuseTextureEnabled;
  18742. /**
  18743. * Are diffuse textures enabled in the application.
  18744. */
  18745. static get DiffuseTextureEnabled(): boolean;
  18746. static set DiffuseTextureEnabled(value: boolean);
  18747. private static _DetailTextureEnabled;
  18748. /**
  18749. * Are detail textures enabled in the application.
  18750. */
  18751. static get DetailTextureEnabled(): boolean;
  18752. static set DetailTextureEnabled(value: boolean);
  18753. private static _AmbientTextureEnabled;
  18754. /**
  18755. * Are ambient textures enabled in the application.
  18756. */
  18757. static get AmbientTextureEnabled(): boolean;
  18758. static set AmbientTextureEnabled(value: boolean);
  18759. private static _OpacityTextureEnabled;
  18760. /**
  18761. * Are opacity textures enabled in the application.
  18762. */
  18763. static get OpacityTextureEnabled(): boolean;
  18764. static set OpacityTextureEnabled(value: boolean);
  18765. private static _ReflectionTextureEnabled;
  18766. /**
  18767. * Are reflection textures enabled in the application.
  18768. */
  18769. static get ReflectionTextureEnabled(): boolean;
  18770. static set ReflectionTextureEnabled(value: boolean);
  18771. private static _EmissiveTextureEnabled;
  18772. /**
  18773. * Are emissive textures enabled in the application.
  18774. */
  18775. static get EmissiveTextureEnabled(): boolean;
  18776. static set EmissiveTextureEnabled(value: boolean);
  18777. private static _SpecularTextureEnabled;
  18778. /**
  18779. * Are specular textures enabled in the application.
  18780. */
  18781. static get SpecularTextureEnabled(): boolean;
  18782. static set SpecularTextureEnabled(value: boolean);
  18783. private static _BumpTextureEnabled;
  18784. /**
  18785. * Are bump textures enabled in the application.
  18786. */
  18787. static get BumpTextureEnabled(): boolean;
  18788. static set BumpTextureEnabled(value: boolean);
  18789. private static _LightmapTextureEnabled;
  18790. /**
  18791. * Are lightmap textures enabled in the application.
  18792. */
  18793. static get LightmapTextureEnabled(): boolean;
  18794. static set LightmapTextureEnabled(value: boolean);
  18795. private static _RefractionTextureEnabled;
  18796. /**
  18797. * Are refraction textures enabled in the application.
  18798. */
  18799. static get RefractionTextureEnabled(): boolean;
  18800. static set RefractionTextureEnabled(value: boolean);
  18801. private static _ColorGradingTextureEnabled;
  18802. /**
  18803. * Are color grading textures enabled in the application.
  18804. */
  18805. static get ColorGradingTextureEnabled(): boolean;
  18806. static set ColorGradingTextureEnabled(value: boolean);
  18807. private static _FresnelEnabled;
  18808. /**
  18809. * Are fresnels enabled in the application.
  18810. */
  18811. static get FresnelEnabled(): boolean;
  18812. static set FresnelEnabled(value: boolean);
  18813. private static _ClearCoatTextureEnabled;
  18814. /**
  18815. * Are clear coat textures enabled in the application.
  18816. */
  18817. static get ClearCoatTextureEnabled(): boolean;
  18818. static set ClearCoatTextureEnabled(value: boolean);
  18819. private static _ClearCoatBumpTextureEnabled;
  18820. /**
  18821. * Are clear coat bump textures enabled in the application.
  18822. */
  18823. static get ClearCoatBumpTextureEnabled(): boolean;
  18824. static set ClearCoatBumpTextureEnabled(value: boolean);
  18825. private static _ClearCoatTintTextureEnabled;
  18826. /**
  18827. * Are clear coat tint textures enabled in the application.
  18828. */
  18829. static get ClearCoatTintTextureEnabled(): boolean;
  18830. static set ClearCoatTintTextureEnabled(value: boolean);
  18831. private static _SheenTextureEnabled;
  18832. /**
  18833. * Are sheen textures enabled in the application.
  18834. */
  18835. static get SheenTextureEnabled(): boolean;
  18836. static set SheenTextureEnabled(value: boolean);
  18837. private static _AnisotropicTextureEnabled;
  18838. /**
  18839. * Are anisotropic textures enabled in the application.
  18840. */
  18841. static get AnisotropicTextureEnabled(): boolean;
  18842. static set AnisotropicTextureEnabled(value: boolean);
  18843. private static _ThicknessTextureEnabled;
  18844. /**
  18845. * Are thickness textures enabled in the application.
  18846. */
  18847. static get ThicknessTextureEnabled(): boolean;
  18848. static set ThicknessTextureEnabled(value: boolean);
  18849. }
  18850. }
  18851. declare module BABYLON {
  18852. /** @hidden */
  18853. export var defaultFragmentDeclaration: {
  18854. name: string;
  18855. shader: string;
  18856. };
  18857. }
  18858. declare module BABYLON {
  18859. /** @hidden */
  18860. export var sceneUboDeclaration: {
  18861. name: string;
  18862. shader: string;
  18863. };
  18864. }
  18865. declare module BABYLON {
  18866. /** @hidden */
  18867. export var meshUboDeclaration: {
  18868. name: string;
  18869. shader: string;
  18870. };
  18871. }
  18872. declare module BABYLON {
  18873. /** @hidden */
  18874. export var defaultUboDeclaration: {
  18875. name: string;
  18876. shader: string;
  18877. };
  18878. }
  18879. declare module BABYLON {
  18880. /** @hidden */
  18881. export var prePassDeclaration: {
  18882. name: string;
  18883. shader: string;
  18884. };
  18885. }
  18886. declare module BABYLON {
  18887. /** @hidden */
  18888. export var lightFragmentDeclaration: {
  18889. name: string;
  18890. shader: string;
  18891. };
  18892. }
  18893. declare module BABYLON {
  18894. /** @hidden */
  18895. export var lightUboDeclaration: {
  18896. name: string;
  18897. shader: string;
  18898. };
  18899. }
  18900. declare module BABYLON {
  18901. /** @hidden */
  18902. export var lightsFragmentFunctions: {
  18903. name: string;
  18904. shader: string;
  18905. };
  18906. }
  18907. declare module BABYLON {
  18908. /** @hidden */
  18909. export var shadowsFragmentFunctions: {
  18910. name: string;
  18911. shader: string;
  18912. };
  18913. }
  18914. declare module BABYLON {
  18915. /** @hidden */
  18916. export var fresnelFunction: {
  18917. name: string;
  18918. shader: string;
  18919. };
  18920. }
  18921. declare module BABYLON {
  18922. /** @hidden */
  18923. export var bumpFragmentMainFunctions: {
  18924. name: string;
  18925. shader: string;
  18926. };
  18927. }
  18928. declare module BABYLON {
  18929. /** @hidden */
  18930. export var bumpFragmentFunctions: {
  18931. name: string;
  18932. shader: string;
  18933. };
  18934. }
  18935. declare module BABYLON {
  18936. /** @hidden */
  18937. export var logDepthDeclaration: {
  18938. name: string;
  18939. shader: string;
  18940. };
  18941. }
  18942. declare module BABYLON {
  18943. /** @hidden */
  18944. export var fogFragmentDeclaration: {
  18945. name: string;
  18946. shader: string;
  18947. };
  18948. }
  18949. declare module BABYLON {
  18950. /** @hidden */
  18951. export var bumpFragment: {
  18952. name: string;
  18953. shader: string;
  18954. };
  18955. }
  18956. declare module BABYLON {
  18957. /** @hidden */
  18958. export var depthPrePass: {
  18959. name: string;
  18960. shader: string;
  18961. };
  18962. }
  18963. declare module BABYLON {
  18964. /** @hidden */
  18965. export var lightFragment: {
  18966. name: string;
  18967. shader: string;
  18968. };
  18969. }
  18970. declare module BABYLON {
  18971. /** @hidden */
  18972. export var logDepthFragment: {
  18973. name: string;
  18974. shader: string;
  18975. };
  18976. }
  18977. declare module BABYLON {
  18978. /** @hidden */
  18979. export var fogFragment: {
  18980. name: string;
  18981. shader: string;
  18982. };
  18983. }
  18984. declare module BABYLON {
  18985. /** @hidden */
  18986. export var defaultPixelShader: {
  18987. name: string;
  18988. shader: string;
  18989. };
  18990. }
  18991. declare module BABYLON {
  18992. /** @hidden */
  18993. export var defaultVertexDeclaration: {
  18994. name: string;
  18995. shader: string;
  18996. };
  18997. }
  18998. declare module BABYLON {
  18999. /** @hidden */
  19000. export var bonesDeclaration: {
  19001. name: string;
  19002. shader: string;
  19003. };
  19004. }
  19005. declare module BABYLON {
  19006. /** @hidden */
  19007. export var prePassVertexDeclaration: {
  19008. name: string;
  19009. shader: string;
  19010. };
  19011. }
  19012. declare module BABYLON {
  19013. /** @hidden */
  19014. export var bumpVertexDeclaration: {
  19015. name: string;
  19016. shader: string;
  19017. };
  19018. }
  19019. declare module BABYLON {
  19020. /** @hidden */
  19021. export var fogVertexDeclaration: {
  19022. name: string;
  19023. shader: string;
  19024. };
  19025. }
  19026. declare module BABYLON {
  19027. /** @hidden */
  19028. export var lightVxFragmentDeclaration: {
  19029. name: string;
  19030. shader: string;
  19031. };
  19032. }
  19033. declare module BABYLON {
  19034. /** @hidden */
  19035. export var lightVxUboDeclaration: {
  19036. name: string;
  19037. shader: string;
  19038. };
  19039. }
  19040. declare module BABYLON {
  19041. /** @hidden */
  19042. export var morphTargetsVertexGlobalDeclaration: {
  19043. name: string;
  19044. shader: string;
  19045. };
  19046. }
  19047. declare module BABYLON {
  19048. /** @hidden */
  19049. export var morphTargetsVertexDeclaration: {
  19050. name: string;
  19051. shader: string;
  19052. };
  19053. }
  19054. declare module BABYLON {
  19055. /** @hidden */
  19056. export var morphTargetsVertex: {
  19057. name: string;
  19058. shader: string;
  19059. };
  19060. }
  19061. declare module BABYLON {
  19062. /** @hidden */
  19063. export var instancesVertex: {
  19064. name: string;
  19065. shader: string;
  19066. };
  19067. }
  19068. declare module BABYLON {
  19069. /** @hidden */
  19070. export var bonesVertex: {
  19071. name: string;
  19072. shader: string;
  19073. };
  19074. }
  19075. declare module BABYLON {
  19076. /** @hidden */
  19077. export var prePassVertex: {
  19078. name: string;
  19079. shader: string;
  19080. };
  19081. }
  19082. declare module BABYLON {
  19083. /** @hidden */
  19084. export var bumpVertex: {
  19085. name: string;
  19086. shader: string;
  19087. };
  19088. }
  19089. declare module BABYLON {
  19090. /** @hidden */
  19091. export var fogVertex: {
  19092. name: string;
  19093. shader: string;
  19094. };
  19095. }
  19096. declare module BABYLON {
  19097. /** @hidden */
  19098. export var shadowsVertex: {
  19099. name: string;
  19100. shader: string;
  19101. };
  19102. }
  19103. declare module BABYLON {
  19104. /** @hidden */
  19105. export var pointCloudVertex: {
  19106. name: string;
  19107. shader: string;
  19108. };
  19109. }
  19110. declare module BABYLON {
  19111. /** @hidden */
  19112. export var logDepthVertex: {
  19113. name: string;
  19114. shader: string;
  19115. };
  19116. }
  19117. declare module BABYLON {
  19118. /** @hidden */
  19119. export var defaultVertexShader: {
  19120. name: string;
  19121. shader: string;
  19122. };
  19123. }
  19124. declare module BABYLON {
  19125. /**
  19126. * @hidden
  19127. */
  19128. export interface IMaterialDetailMapDefines {
  19129. DETAIL: boolean;
  19130. DETAILDIRECTUV: number;
  19131. DETAIL_NORMALBLENDMETHOD: number;
  19132. /** @hidden */
  19133. _areTexturesDirty: boolean;
  19134. }
  19135. /**
  19136. * Define the code related to the detail map parameters of a material
  19137. *
  19138. * Inspired from:
  19139. * 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
  19140. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19141. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19142. */
  19143. export class DetailMapConfiguration {
  19144. private _texture;
  19145. /**
  19146. * The detail texture of the material.
  19147. */
  19148. texture: Nullable<BaseTexture>;
  19149. /**
  19150. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19151. * Bigger values mean stronger blending
  19152. */
  19153. diffuseBlendLevel: number;
  19154. /**
  19155. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19156. * Bigger values mean stronger blending. Only used with PBR materials
  19157. */
  19158. roughnessBlendLevel: number;
  19159. /**
  19160. * Defines how strong the bump effect from the detail map is
  19161. * Bigger values mean stronger effect
  19162. */
  19163. bumpLevel: number;
  19164. private _normalBlendMethod;
  19165. /**
  19166. * The method used to blend the bump and detail normals together
  19167. */
  19168. normalBlendMethod: number;
  19169. private _isEnabled;
  19170. /**
  19171. * Enable or disable the detail map on this material
  19172. */
  19173. isEnabled: boolean;
  19174. /** @hidden */
  19175. private _internalMarkAllSubMeshesAsTexturesDirty;
  19176. /** @hidden */
  19177. _markAllSubMeshesAsTexturesDirty(): void;
  19178. /**
  19179. * Instantiate a new detail map
  19180. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19181. */
  19182. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19183. /**
  19184. * Gets whether the submesh is ready to be used or not.
  19185. * @param defines the list of "defines" to update.
  19186. * @param scene defines the scene the material belongs to.
  19187. * @returns - boolean indicating that the submesh is ready or not.
  19188. */
  19189. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19190. /**
  19191. * Update the defines for detail map usage
  19192. * @param defines the list of "defines" to update.
  19193. * @param scene defines the scene the material belongs to.
  19194. */
  19195. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19196. /**
  19197. * Binds the material data.
  19198. * @param uniformBuffer defines the Uniform buffer to fill in.
  19199. * @param scene defines the scene the material belongs to.
  19200. * @param isFrozen defines whether the material is frozen or not.
  19201. */
  19202. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19203. /**
  19204. * Checks to see if a texture is used in the material.
  19205. * @param texture - Base texture to use.
  19206. * @returns - Boolean specifying if a texture is used in the material.
  19207. */
  19208. hasTexture(texture: BaseTexture): boolean;
  19209. /**
  19210. * Returns an array of the actively used textures.
  19211. * @param activeTextures Array of BaseTextures
  19212. */
  19213. getActiveTextures(activeTextures: BaseTexture[]): void;
  19214. /**
  19215. * Returns the animatable textures.
  19216. * @param animatables Array of animatable textures.
  19217. */
  19218. getAnimatables(animatables: IAnimatable[]): void;
  19219. /**
  19220. * Disposes the resources of the material.
  19221. * @param forceDisposeTextures - Forces the disposal of all textures.
  19222. */
  19223. dispose(forceDisposeTextures?: boolean): void;
  19224. /**
  19225. * Get the current class name useful for serialization or dynamic coding.
  19226. * @returns "DetailMap"
  19227. */
  19228. getClassName(): string;
  19229. /**
  19230. * Add the required uniforms to the current list.
  19231. * @param uniforms defines the current uniform list.
  19232. */
  19233. static AddUniforms(uniforms: string[]): void;
  19234. /**
  19235. * Add the required samplers to the current list.
  19236. * @param samplers defines the current sampler list.
  19237. */
  19238. static AddSamplers(samplers: string[]): void;
  19239. /**
  19240. * Add the required uniforms to the current buffer.
  19241. * @param uniformBuffer defines the current uniform buffer.
  19242. */
  19243. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19244. /**
  19245. * Makes a duplicate of the current instance into another one.
  19246. * @param detailMap define the instance where to copy the info
  19247. */
  19248. copyTo(detailMap: DetailMapConfiguration): void;
  19249. /**
  19250. * Serializes this detail map instance
  19251. * @returns - An object with the serialized instance.
  19252. */
  19253. serialize(): any;
  19254. /**
  19255. * Parses a detail map setting from a serialized object.
  19256. * @param source - Serialized object.
  19257. * @param scene Defines the scene we are parsing for
  19258. * @param rootUrl Defines the rootUrl to load from
  19259. */
  19260. parse(source: any, scene: Scene, rootUrl: string): void;
  19261. }
  19262. }
  19263. declare module BABYLON {
  19264. /** @hidden */
  19265. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19266. MAINUV1: boolean;
  19267. MAINUV2: boolean;
  19268. DIFFUSE: boolean;
  19269. DIFFUSEDIRECTUV: number;
  19270. DETAIL: boolean;
  19271. DETAILDIRECTUV: number;
  19272. DETAIL_NORMALBLENDMETHOD: number;
  19273. AMBIENT: boolean;
  19274. AMBIENTDIRECTUV: number;
  19275. OPACITY: boolean;
  19276. OPACITYDIRECTUV: number;
  19277. OPACITYRGB: boolean;
  19278. REFLECTION: boolean;
  19279. EMISSIVE: boolean;
  19280. EMISSIVEDIRECTUV: number;
  19281. SPECULAR: boolean;
  19282. SPECULARDIRECTUV: number;
  19283. BUMP: boolean;
  19284. BUMPDIRECTUV: number;
  19285. PARALLAX: boolean;
  19286. PARALLAXOCCLUSION: boolean;
  19287. SPECULAROVERALPHA: boolean;
  19288. CLIPPLANE: boolean;
  19289. CLIPPLANE2: boolean;
  19290. CLIPPLANE3: boolean;
  19291. CLIPPLANE4: boolean;
  19292. CLIPPLANE5: boolean;
  19293. CLIPPLANE6: boolean;
  19294. ALPHATEST: boolean;
  19295. DEPTHPREPASS: boolean;
  19296. ALPHAFROMDIFFUSE: boolean;
  19297. POINTSIZE: boolean;
  19298. FOG: boolean;
  19299. SPECULARTERM: boolean;
  19300. DIFFUSEFRESNEL: boolean;
  19301. OPACITYFRESNEL: boolean;
  19302. REFLECTIONFRESNEL: boolean;
  19303. REFRACTIONFRESNEL: boolean;
  19304. EMISSIVEFRESNEL: boolean;
  19305. FRESNEL: boolean;
  19306. NORMAL: boolean;
  19307. UV1: boolean;
  19308. UV2: boolean;
  19309. VERTEXCOLOR: boolean;
  19310. VERTEXALPHA: boolean;
  19311. NUM_BONE_INFLUENCERS: number;
  19312. BonesPerMesh: number;
  19313. BONETEXTURE: boolean;
  19314. BONES_VELOCITY_ENABLED: boolean;
  19315. INSTANCES: boolean;
  19316. THIN_INSTANCES: boolean;
  19317. GLOSSINESS: boolean;
  19318. ROUGHNESS: boolean;
  19319. EMISSIVEASILLUMINATION: boolean;
  19320. LINKEMISSIVEWITHDIFFUSE: boolean;
  19321. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19322. LIGHTMAP: boolean;
  19323. LIGHTMAPDIRECTUV: number;
  19324. OBJECTSPACE_NORMALMAP: boolean;
  19325. USELIGHTMAPASSHADOWMAP: boolean;
  19326. REFLECTIONMAP_3D: boolean;
  19327. REFLECTIONMAP_SPHERICAL: boolean;
  19328. REFLECTIONMAP_PLANAR: boolean;
  19329. REFLECTIONMAP_CUBIC: boolean;
  19330. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19331. REFLECTIONMAP_PROJECTION: boolean;
  19332. REFLECTIONMAP_SKYBOX: boolean;
  19333. REFLECTIONMAP_EXPLICIT: boolean;
  19334. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19335. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19336. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19337. REFLECTIONMAP_OPPOSITEZ: boolean;
  19338. INVERTCUBICMAP: boolean;
  19339. LOGARITHMICDEPTH: boolean;
  19340. REFRACTION: boolean;
  19341. REFRACTIONMAP_3D: boolean;
  19342. REFLECTIONOVERALPHA: boolean;
  19343. TWOSIDEDLIGHTING: boolean;
  19344. SHADOWFLOAT: boolean;
  19345. MORPHTARGETS: boolean;
  19346. MORPHTARGETS_NORMAL: boolean;
  19347. MORPHTARGETS_TANGENT: boolean;
  19348. MORPHTARGETS_UV: boolean;
  19349. NUM_MORPH_INFLUENCERS: number;
  19350. NONUNIFORMSCALING: boolean;
  19351. PREMULTIPLYALPHA: boolean;
  19352. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19353. ALPHABLEND: boolean;
  19354. PREPASS: boolean;
  19355. PREPASS_IRRADIANCE: boolean;
  19356. PREPASS_IRRADIANCE_INDEX: number;
  19357. PREPASS_ALBEDO: boolean;
  19358. PREPASS_ALBEDO_INDEX: number;
  19359. PREPASS_DEPTHNORMAL: boolean;
  19360. PREPASS_DEPTHNORMAL_INDEX: number;
  19361. PREPASS_POSITION: boolean;
  19362. PREPASS_POSITION_INDEX: number;
  19363. PREPASS_VELOCITY: boolean;
  19364. PREPASS_VELOCITY_INDEX: number;
  19365. PREPASS_REFLECTIVITY: boolean;
  19366. PREPASS_REFLECTIVITY_INDEX: number;
  19367. SCENE_MRT_COUNT: number;
  19368. RGBDLIGHTMAP: boolean;
  19369. RGBDREFLECTION: boolean;
  19370. RGBDREFRACTION: boolean;
  19371. IMAGEPROCESSING: boolean;
  19372. VIGNETTE: boolean;
  19373. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19374. VIGNETTEBLENDMODEOPAQUE: boolean;
  19375. TONEMAPPING: boolean;
  19376. TONEMAPPING_ACES: boolean;
  19377. CONTRAST: boolean;
  19378. COLORCURVES: boolean;
  19379. COLORGRADING: boolean;
  19380. COLORGRADING3D: boolean;
  19381. SAMPLER3DGREENDEPTH: boolean;
  19382. SAMPLER3DBGRMAP: boolean;
  19383. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19384. MULTIVIEW: boolean;
  19385. /**
  19386. * If the reflection texture on this material is in linear color space
  19387. * @hidden
  19388. */
  19389. IS_REFLECTION_LINEAR: boolean;
  19390. /**
  19391. * If the refraction texture on this material is in linear color space
  19392. * @hidden
  19393. */
  19394. IS_REFRACTION_LINEAR: boolean;
  19395. EXPOSURE: boolean;
  19396. constructor();
  19397. setReflectionMode(modeToEnable: string): void;
  19398. }
  19399. /**
  19400. * This is the default material used in Babylon. It is the best trade off between quality
  19401. * and performances.
  19402. * @see https://doc.babylonjs.com/babylon101/materials
  19403. */
  19404. export class StandardMaterial extends PushMaterial {
  19405. private _diffuseTexture;
  19406. /**
  19407. * The basic texture of the material as viewed under a light.
  19408. */
  19409. diffuseTexture: Nullable<BaseTexture>;
  19410. private _ambientTexture;
  19411. /**
  19412. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19413. */
  19414. ambientTexture: Nullable<BaseTexture>;
  19415. private _opacityTexture;
  19416. /**
  19417. * Define the transparency of the material from a texture.
  19418. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19419. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19420. */
  19421. opacityTexture: Nullable<BaseTexture>;
  19422. private _reflectionTexture;
  19423. /**
  19424. * Define the texture used to display the reflection.
  19425. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19426. */
  19427. reflectionTexture: Nullable<BaseTexture>;
  19428. private _emissiveTexture;
  19429. /**
  19430. * Define texture of the material as if self lit.
  19431. * This will be mixed in the final result even in the absence of light.
  19432. */
  19433. emissiveTexture: Nullable<BaseTexture>;
  19434. private _specularTexture;
  19435. /**
  19436. * Define how the color and intensity of the highlight given by the light in the material.
  19437. */
  19438. specularTexture: Nullable<BaseTexture>;
  19439. private _bumpTexture;
  19440. /**
  19441. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19442. * 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.
  19443. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19444. */
  19445. bumpTexture: Nullable<BaseTexture>;
  19446. private _lightmapTexture;
  19447. /**
  19448. * Complex lighting can be computationally expensive to compute at runtime.
  19449. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19450. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19451. */
  19452. lightmapTexture: Nullable<BaseTexture>;
  19453. private _refractionTexture;
  19454. /**
  19455. * Define the texture used to display the refraction.
  19456. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19457. */
  19458. refractionTexture: Nullable<BaseTexture>;
  19459. /**
  19460. * The color of the material lit by the environmental background lighting.
  19461. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19462. */
  19463. ambientColor: Color3;
  19464. /**
  19465. * The basic color of the material as viewed under a light.
  19466. */
  19467. diffuseColor: Color3;
  19468. /**
  19469. * Define how the color and intensity of the highlight given by the light in the material.
  19470. */
  19471. specularColor: Color3;
  19472. /**
  19473. * Define the color of the material as if self lit.
  19474. * This will be mixed in the final result even in the absence of light.
  19475. */
  19476. emissiveColor: Color3;
  19477. /**
  19478. * Defines how sharp are the highlights in the material.
  19479. * The bigger the value the sharper giving a more glossy feeling to the result.
  19480. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19481. */
  19482. specularPower: number;
  19483. private _useAlphaFromDiffuseTexture;
  19484. /**
  19485. * Does the transparency come from the diffuse texture alpha channel.
  19486. */
  19487. useAlphaFromDiffuseTexture: boolean;
  19488. private _useEmissiveAsIllumination;
  19489. /**
  19490. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19491. */
  19492. useEmissiveAsIllumination: boolean;
  19493. private _linkEmissiveWithDiffuse;
  19494. /**
  19495. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19496. * the emissive level when the final color is close to one.
  19497. */
  19498. linkEmissiveWithDiffuse: boolean;
  19499. private _useSpecularOverAlpha;
  19500. /**
  19501. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19502. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19503. */
  19504. useSpecularOverAlpha: boolean;
  19505. private _useReflectionOverAlpha;
  19506. /**
  19507. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19508. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19509. */
  19510. useReflectionOverAlpha: boolean;
  19511. private _disableLighting;
  19512. /**
  19513. * Does lights from the scene impacts this material.
  19514. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19515. */
  19516. disableLighting: boolean;
  19517. private _useObjectSpaceNormalMap;
  19518. /**
  19519. * Allows using an object space normal map (instead of tangent space).
  19520. */
  19521. useObjectSpaceNormalMap: boolean;
  19522. private _useParallax;
  19523. /**
  19524. * Is parallax enabled or not.
  19525. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19526. */
  19527. useParallax: boolean;
  19528. private _useParallaxOcclusion;
  19529. /**
  19530. * Is parallax occlusion enabled or not.
  19531. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19532. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19533. */
  19534. useParallaxOcclusion: boolean;
  19535. /**
  19536. * 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.
  19537. */
  19538. parallaxScaleBias: number;
  19539. private _roughness;
  19540. /**
  19541. * Helps to define how blurry the reflections should appears in the material.
  19542. */
  19543. roughness: number;
  19544. /**
  19545. * In case of refraction, define the value of the index of refraction.
  19546. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19547. */
  19548. indexOfRefraction: number;
  19549. /**
  19550. * Invert the refraction texture alongside the y axis.
  19551. * It can be useful with procedural textures or probe for instance.
  19552. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19553. */
  19554. invertRefractionY: boolean;
  19555. /**
  19556. * Defines the alpha limits in alpha test mode.
  19557. */
  19558. alphaCutOff: number;
  19559. private _useLightmapAsShadowmap;
  19560. /**
  19561. * In case of light mapping, define whether the map contains light or shadow informations.
  19562. */
  19563. useLightmapAsShadowmap: boolean;
  19564. private _diffuseFresnelParameters;
  19565. /**
  19566. * Define the diffuse fresnel parameters of the material.
  19567. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19568. */
  19569. diffuseFresnelParameters: FresnelParameters;
  19570. private _opacityFresnelParameters;
  19571. /**
  19572. * Define the opacity fresnel parameters of the material.
  19573. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19574. */
  19575. opacityFresnelParameters: FresnelParameters;
  19576. private _reflectionFresnelParameters;
  19577. /**
  19578. * Define the reflection fresnel parameters of the material.
  19579. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19580. */
  19581. reflectionFresnelParameters: FresnelParameters;
  19582. private _refractionFresnelParameters;
  19583. /**
  19584. * Define the refraction fresnel parameters of the material.
  19585. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19586. */
  19587. refractionFresnelParameters: FresnelParameters;
  19588. private _emissiveFresnelParameters;
  19589. /**
  19590. * Define the emissive fresnel parameters of the material.
  19591. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19592. */
  19593. emissiveFresnelParameters: FresnelParameters;
  19594. private _useReflectionFresnelFromSpecular;
  19595. /**
  19596. * If true automatically deducts the fresnels values from the material specularity.
  19597. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19598. */
  19599. useReflectionFresnelFromSpecular: boolean;
  19600. private _useGlossinessFromSpecularMapAlpha;
  19601. /**
  19602. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19603. */
  19604. useGlossinessFromSpecularMapAlpha: boolean;
  19605. private _maxSimultaneousLights;
  19606. /**
  19607. * Defines the maximum number of lights that can be used in the material
  19608. */
  19609. maxSimultaneousLights: number;
  19610. private _invertNormalMapX;
  19611. /**
  19612. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19613. */
  19614. invertNormalMapX: boolean;
  19615. private _invertNormalMapY;
  19616. /**
  19617. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19618. */
  19619. invertNormalMapY: boolean;
  19620. private _twoSidedLighting;
  19621. /**
  19622. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19623. */
  19624. twoSidedLighting: boolean;
  19625. /**
  19626. * Default configuration related to image processing available in the standard Material.
  19627. */
  19628. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19629. /**
  19630. * Gets the image processing configuration used either in this material.
  19631. */
  19632. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19633. /**
  19634. * Sets the Default image processing configuration used either in the this material.
  19635. *
  19636. * If sets to null, the scene one is in use.
  19637. */
  19638. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19639. /**
  19640. * Keep track of the image processing observer to allow dispose and replace.
  19641. */
  19642. private _imageProcessingObserver;
  19643. /**
  19644. * Attaches a new image processing configuration to the Standard Material.
  19645. * @param configuration
  19646. */
  19647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19648. /**
  19649. * Defines additionnal PrePass parameters for the material.
  19650. */
  19651. readonly prePassConfiguration: PrePassConfiguration;
  19652. /**
  19653. * Gets wether the color curves effect is enabled.
  19654. */
  19655. get cameraColorCurvesEnabled(): boolean;
  19656. /**
  19657. * Sets wether the color curves effect is enabled.
  19658. */
  19659. set cameraColorCurvesEnabled(value: boolean);
  19660. /**
  19661. * Gets wether the color grading effect is enabled.
  19662. */
  19663. get cameraColorGradingEnabled(): boolean;
  19664. /**
  19665. * Gets wether the color grading effect is enabled.
  19666. */
  19667. set cameraColorGradingEnabled(value: boolean);
  19668. /**
  19669. * Gets wether tonemapping is enabled or not.
  19670. */
  19671. get cameraToneMappingEnabled(): boolean;
  19672. /**
  19673. * Sets wether tonemapping is enabled or not
  19674. */
  19675. set cameraToneMappingEnabled(value: boolean);
  19676. /**
  19677. * The camera exposure used on this material.
  19678. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19679. * This corresponds to a photographic exposure.
  19680. */
  19681. get cameraExposure(): number;
  19682. /**
  19683. * The camera exposure used on this material.
  19684. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19685. * This corresponds to a photographic exposure.
  19686. */
  19687. set cameraExposure(value: number);
  19688. /**
  19689. * Gets The camera contrast used on this material.
  19690. */
  19691. get cameraContrast(): number;
  19692. /**
  19693. * Sets The camera contrast used on this material.
  19694. */
  19695. set cameraContrast(value: number);
  19696. /**
  19697. * Gets the Color Grading 2D Lookup Texture.
  19698. */
  19699. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19700. /**
  19701. * Sets the Color Grading 2D Lookup Texture.
  19702. */
  19703. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19704. /**
  19705. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19706. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19707. * 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;
  19708. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19709. */
  19710. get cameraColorCurves(): Nullable<ColorCurves>;
  19711. /**
  19712. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19713. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19714. * 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;
  19715. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19716. */
  19717. set cameraColorCurves(value: Nullable<ColorCurves>);
  19718. /**
  19719. * Can this material render to several textures at once
  19720. */
  19721. get canRenderToMRT(): boolean;
  19722. /**
  19723. * Defines the detail map parameters for the material.
  19724. */
  19725. readonly detailMap: DetailMapConfiguration;
  19726. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19727. protected _worldViewProjectionMatrix: Matrix;
  19728. protected _globalAmbientColor: Color3;
  19729. protected _useLogarithmicDepth: boolean;
  19730. protected _rebuildInParallel: boolean;
  19731. /**
  19732. * Instantiates a new standard material.
  19733. * This is the default material used in Babylon. It is the best trade off between quality
  19734. * and performances.
  19735. * @see https://doc.babylonjs.com/babylon101/materials
  19736. * @param name Define the name of the material in the scene
  19737. * @param scene Define the scene the material belong to
  19738. */
  19739. constructor(name: string, scene: Scene);
  19740. /**
  19741. * Gets a boolean indicating that current material needs to register RTT
  19742. */
  19743. get hasRenderTargetTextures(): boolean;
  19744. /**
  19745. * Gets the current class name of the material e.g. "StandardMaterial"
  19746. * Mainly use in serialization.
  19747. * @returns the class name
  19748. */
  19749. getClassName(): string;
  19750. /**
  19751. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19752. * You can try switching to logarithmic depth.
  19753. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19754. */
  19755. get useLogarithmicDepth(): boolean;
  19756. set useLogarithmicDepth(value: boolean);
  19757. /**
  19758. * Specifies if the material will require alpha blending
  19759. * @returns a boolean specifying if alpha blending is needed
  19760. */
  19761. needAlphaBlending(): boolean;
  19762. /**
  19763. * Specifies if this material should be rendered in alpha test mode
  19764. * @returns a boolean specifying if an alpha test is needed.
  19765. */
  19766. needAlphaTesting(): boolean;
  19767. /**
  19768. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19769. */
  19770. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19771. /**
  19772. * Specifies whether or not there is a usable alpha channel for transparency.
  19773. */
  19774. protected _hasAlphaChannel(): boolean;
  19775. /**
  19776. * Get the texture used for alpha test purpose.
  19777. * @returns the diffuse texture in case of the standard material.
  19778. */
  19779. getAlphaTestTexture(): Nullable<BaseTexture>;
  19780. /**
  19781. * Get if the submesh is ready to be used and all its information available.
  19782. * Child classes can use it to update shaders
  19783. * @param mesh defines the mesh to check
  19784. * @param subMesh defines which submesh to check
  19785. * @param useInstances specifies that instances should be used
  19786. * @returns a boolean indicating that the submesh is ready or not
  19787. */
  19788. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19789. /**
  19790. * Builds the material UBO layouts.
  19791. * Used internally during the effect preparation.
  19792. */
  19793. buildUniformLayout(): void;
  19794. /**
  19795. * Unbinds the material from the mesh
  19796. */
  19797. unbind(): void;
  19798. /**
  19799. * Binds the submesh to this material by preparing the effect and shader to draw
  19800. * @param world defines the world transformation matrix
  19801. * @param mesh defines the mesh containing the submesh
  19802. * @param subMesh defines the submesh to bind the material to
  19803. */
  19804. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19805. /**
  19806. * Get the list of animatables in the material.
  19807. * @returns the list of animatables object used in the material
  19808. */
  19809. getAnimatables(): IAnimatable[];
  19810. /**
  19811. * Gets the active textures from the material
  19812. * @returns an array of textures
  19813. */
  19814. getActiveTextures(): BaseTexture[];
  19815. /**
  19816. * Specifies if the material uses a texture
  19817. * @param texture defines the texture to check against the material
  19818. * @returns a boolean specifying if the material uses the texture
  19819. */
  19820. hasTexture(texture: BaseTexture): boolean;
  19821. /**
  19822. * Disposes the material
  19823. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19824. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19825. */
  19826. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19827. /**
  19828. * Makes a duplicate of the material, and gives it a new name
  19829. * @param name defines the new name for the duplicated material
  19830. * @returns the cloned material
  19831. */
  19832. clone(name: string): StandardMaterial;
  19833. /**
  19834. * Serializes this material in a JSON representation
  19835. * @returns the serialized material object
  19836. */
  19837. serialize(): any;
  19838. /**
  19839. * Creates a standard material from parsed material data
  19840. * @param source defines the JSON representation of the material
  19841. * @param scene defines the hosting scene
  19842. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19843. * @returns a new standard material
  19844. */
  19845. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19846. /**
  19847. * Are diffuse textures enabled in the application.
  19848. */
  19849. static get DiffuseTextureEnabled(): boolean;
  19850. static set DiffuseTextureEnabled(value: boolean);
  19851. /**
  19852. * Are detail textures enabled in the application.
  19853. */
  19854. static get DetailTextureEnabled(): boolean;
  19855. static set DetailTextureEnabled(value: boolean);
  19856. /**
  19857. * Are ambient textures enabled in the application.
  19858. */
  19859. static get AmbientTextureEnabled(): boolean;
  19860. static set AmbientTextureEnabled(value: boolean);
  19861. /**
  19862. * Are opacity textures enabled in the application.
  19863. */
  19864. static get OpacityTextureEnabled(): boolean;
  19865. static set OpacityTextureEnabled(value: boolean);
  19866. /**
  19867. * Are reflection textures enabled in the application.
  19868. */
  19869. static get ReflectionTextureEnabled(): boolean;
  19870. static set ReflectionTextureEnabled(value: boolean);
  19871. /**
  19872. * Are emissive textures enabled in the application.
  19873. */
  19874. static get EmissiveTextureEnabled(): boolean;
  19875. static set EmissiveTextureEnabled(value: boolean);
  19876. /**
  19877. * Are specular textures enabled in the application.
  19878. */
  19879. static get SpecularTextureEnabled(): boolean;
  19880. static set SpecularTextureEnabled(value: boolean);
  19881. /**
  19882. * Are bump textures enabled in the application.
  19883. */
  19884. static get BumpTextureEnabled(): boolean;
  19885. static set BumpTextureEnabled(value: boolean);
  19886. /**
  19887. * Are lightmap textures enabled in the application.
  19888. */
  19889. static get LightmapTextureEnabled(): boolean;
  19890. static set LightmapTextureEnabled(value: boolean);
  19891. /**
  19892. * Are refraction textures enabled in the application.
  19893. */
  19894. static get RefractionTextureEnabled(): boolean;
  19895. static set RefractionTextureEnabled(value: boolean);
  19896. /**
  19897. * Are color grading textures enabled in the application.
  19898. */
  19899. static get ColorGradingTextureEnabled(): boolean;
  19900. static set ColorGradingTextureEnabled(value: boolean);
  19901. /**
  19902. * Are fresnels enabled in the application.
  19903. */
  19904. static get FresnelEnabled(): boolean;
  19905. static set FresnelEnabled(value: boolean);
  19906. }
  19907. }
  19908. declare module BABYLON {
  19909. /** @hidden */
  19910. export var rgbdDecodePixelShader: {
  19911. name: string;
  19912. shader: string;
  19913. };
  19914. }
  19915. declare module BABYLON {
  19916. /** @hidden */
  19917. export var passPixelShader: {
  19918. name: string;
  19919. shader: string;
  19920. };
  19921. }
  19922. declare module BABYLON {
  19923. /** @hidden */
  19924. export var passCubePixelShader: {
  19925. name: string;
  19926. shader: string;
  19927. };
  19928. }
  19929. declare module BABYLON {
  19930. /**
  19931. * PassPostProcess which produces an output the same as it's input
  19932. */
  19933. export class PassPostProcess extends PostProcess {
  19934. /**
  19935. * Gets a string identifying the name of the class
  19936. * @returns "PassPostProcess" string
  19937. */
  19938. getClassName(): string;
  19939. /**
  19940. * Creates the PassPostProcess
  19941. * @param name The name of the effect.
  19942. * @param options The required width/height ratio to downsize to before computing the render pass.
  19943. * @param camera The camera to apply the render pass to.
  19944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19945. * @param engine The engine which the post process will be applied. (default: current engine)
  19946. * @param reusable If the post process can be reused on the same frame. (default: false)
  19947. * @param textureType The type of texture to be used when performing the post processing.
  19948. * @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)
  19949. */
  19950. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19951. /** @hidden */
  19952. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  19953. }
  19954. /**
  19955. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  19956. */
  19957. export class PassCubePostProcess extends PostProcess {
  19958. private _face;
  19959. /**
  19960. * Gets or sets the cube face to display.
  19961. * * 0 is +X
  19962. * * 1 is -X
  19963. * * 2 is +Y
  19964. * * 3 is -Y
  19965. * * 4 is +Z
  19966. * * 5 is -Z
  19967. */
  19968. get face(): number;
  19969. set face(value: number);
  19970. /**
  19971. * Gets a string identifying the name of the class
  19972. * @returns "PassCubePostProcess" string
  19973. */
  19974. getClassName(): string;
  19975. /**
  19976. * Creates the PassCubePostProcess
  19977. * @param name The name of the effect.
  19978. * @param options The required width/height ratio to downsize to before computing the render pass.
  19979. * @param camera The camera to apply the render pass to.
  19980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19981. * @param engine The engine which the post process will be applied. (default: current engine)
  19982. * @param reusable If the post process can be reused on the same frame. (default: false)
  19983. * @param textureType The type of texture to be used when performing the post processing.
  19984. * @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)
  19985. */
  19986. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19987. /** @hidden */
  19988. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  19989. }
  19990. }
  19991. declare module BABYLON {
  19992. /**
  19993. * Class used to host texture specific utilities
  19994. */
  19995. export class TextureTools {
  19996. /**
  19997. * Uses the GPU to create a copy texture rescaled at a given size
  19998. * @param texture Texture to copy from
  19999. * @param width defines the desired width
  20000. * @param height defines the desired height
  20001. * @param useBilinearMode defines if bilinear mode has to be used
  20002. * @return the generated texture
  20003. */
  20004. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20005. /**
  20006. * Apply a post process to a texture
  20007. * @param postProcessName name of the fragment post process
  20008. * @param internalTexture the texture to encode
  20009. * @param scene the scene hosting the texture
  20010. * @param type type of the output texture. If not provided, use the one from internalTexture
  20011. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  20012. * @param format format of the output texture. If not provided, use the one from internalTexture
  20013. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20014. */
  20015. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20016. }
  20017. }
  20018. declare module BABYLON {
  20019. /**
  20020. * Class used to host RGBD texture specific utilities
  20021. */
  20022. export class RGBDTextureTools {
  20023. /**
  20024. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20025. * @param texture the texture to expand.
  20026. */
  20027. static ExpandRGBDTexture(texture: Texture): void;
  20028. /**
  20029. * Encode the texture to RGBD if possible.
  20030. * @param internalTexture the texture to encode
  20031. * @param scene the scene hosting the texture
  20032. * @param outputTextureType type of the texture in which the encoding is performed
  20033. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20034. */
  20035. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20036. }
  20037. }
  20038. declare module BABYLON {
  20039. /**
  20040. * Class used to host texture specific utilities
  20041. */
  20042. export class BRDFTextureTools {
  20043. /**
  20044. * Prevents texture cache collision
  20045. */
  20046. private static _instanceNumber;
  20047. /**
  20048. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20049. * @param scene defines the hosting scene
  20050. * @returns the environment BRDF texture
  20051. */
  20052. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20053. private static _environmentBRDFBase64Texture;
  20054. }
  20055. }
  20056. declare module BABYLON {
  20057. /**
  20058. * @hidden
  20059. */
  20060. export interface IMaterialClearCoatDefines {
  20061. CLEARCOAT: boolean;
  20062. CLEARCOAT_DEFAULTIOR: boolean;
  20063. CLEARCOAT_TEXTURE: boolean;
  20064. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20065. CLEARCOAT_TEXTUREDIRECTUV: number;
  20066. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20067. CLEARCOAT_BUMP: boolean;
  20068. CLEARCOAT_BUMPDIRECTUV: number;
  20069. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20070. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20071. CLEARCOAT_REMAP_F0: boolean;
  20072. CLEARCOAT_TINT: boolean;
  20073. CLEARCOAT_TINT_TEXTURE: boolean;
  20074. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20075. /** @hidden */
  20076. _areTexturesDirty: boolean;
  20077. }
  20078. /**
  20079. * Define the code related to the clear coat parameters of the pbr material.
  20080. */
  20081. export class PBRClearCoatConfiguration {
  20082. /**
  20083. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20084. * The default fits with a polyurethane material.
  20085. * @hidden
  20086. */
  20087. static readonly _DefaultIndexOfRefraction: number;
  20088. private _isEnabled;
  20089. /**
  20090. * Defines if the clear coat is enabled in the material.
  20091. */
  20092. isEnabled: boolean;
  20093. /**
  20094. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20095. */
  20096. intensity: number;
  20097. /**
  20098. * Defines the clear coat layer roughness.
  20099. */
  20100. roughness: number;
  20101. private _indexOfRefraction;
  20102. /**
  20103. * Defines the index of refraction of the clear coat.
  20104. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20105. * The default fits with a polyurethane material.
  20106. * Changing the default value is more performance intensive.
  20107. */
  20108. indexOfRefraction: number;
  20109. private _texture;
  20110. /**
  20111. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20112. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20113. * if textureRoughness is not empty, else no texture roughness is used
  20114. */
  20115. texture: Nullable<BaseTexture>;
  20116. private _useRoughnessFromMainTexture;
  20117. /**
  20118. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20119. * If false, the green channel from textureRoughness is used for roughness
  20120. */
  20121. useRoughnessFromMainTexture: boolean;
  20122. private _textureRoughness;
  20123. /**
  20124. * Stores the clear coat roughness in a texture (green channel)
  20125. * Not used if useRoughnessFromMainTexture is true
  20126. */
  20127. textureRoughness: Nullable<BaseTexture>;
  20128. private _remapF0OnInterfaceChange;
  20129. /**
  20130. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20131. */
  20132. remapF0OnInterfaceChange: boolean;
  20133. private _bumpTexture;
  20134. /**
  20135. * Define the clear coat specific bump texture.
  20136. */
  20137. bumpTexture: Nullable<BaseTexture>;
  20138. private _isTintEnabled;
  20139. /**
  20140. * Defines if the clear coat tint is enabled in the material.
  20141. */
  20142. isTintEnabled: boolean;
  20143. /**
  20144. * Defines the clear coat tint of the material.
  20145. * This is only use if tint is enabled
  20146. */
  20147. tintColor: Color3;
  20148. /**
  20149. * Defines the distance at which the tint color should be found in the
  20150. * clear coat media.
  20151. * This is only use if tint is enabled
  20152. */
  20153. tintColorAtDistance: number;
  20154. /**
  20155. * Defines the clear coat layer thickness.
  20156. * This is only use if tint is enabled
  20157. */
  20158. tintThickness: number;
  20159. private _tintTexture;
  20160. /**
  20161. * Stores the clear tint values in a texture.
  20162. * rgb is tint
  20163. * a is a thickness factor
  20164. */
  20165. tintTexture: Nullable<BaseTexture>;
  20166. /** @hidden */
  20167. private _internalMarkAllSubMeshesAsTexturesDirty;
  20168. /** @hidden */
  20169. _markAllSubMeshesAsTexturesDirty(): void;
  20170. /**
  20171. * Instantiate a new istance of clear coat configuration.
  20172. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20173. */
  20174. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20175. /**
  20176. * Gets wehter the submesh is ready to be used or not.
  20177. * @param defines the list of "defines" to update.
  20178. * @param scene defines the scene the material belongs to.
  20179. * @param engine defines the engine the material belongs to.
  20180. * @param disableBumpMap defines wether the material disables bump or not.
  20181. * @returns - boolean indicating that the submesh is ready or not.
  20182. */
  20183. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20184. /**
  20185. * Checks to see if a texture is used in the material.
  20186. * @param defines the list of "defines" to update.
  20187. * @param scene defines the scene to the material belongs to.
  20188. */
  20189. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20190. /**
  20191. * Binds the material data.
  20192. * @param uniformBuffer defines the Uniform buffer to fill in.
  20193. * @param scene defines the scene the material belongs to.
  20194. * @param engine defines the engine the material belongs to.
  20195. * @param disableBumpMap defines wether the material disables bump or not.
  20196. * @param isFrozen defines wether the material is frozen or not.
  20197. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20198. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20199. * @param subMesh the submesh to bind data for
  20200. */
  20201. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20202. /**
  20203. * Checks to see if a texture is used in the material.
  20204. * @param texture - Base texture to use.
  20205. * @returns - Boolean specifying if a texture is used in the material.
  20206. */
  20207. hasTexture(texture: BaseTexture): boolean;
  20208. /**
  20209. * Returns an array of the actively used textures.
  20210. * @param activeTextures Array of BaseTextures
  20211. */
  20212. getActiveTextures(activeTextures: BaseTexture[]): void;
  20213. /**
  20214. * Returns the animatable textures.
  20215. * @param animatables Array of animatable textures.
  20216. */
  20217. getAnimatables(animatables: IAnimatable[]): void;
  20218. /**
  20219. * Disposes the resources of the material.
  20220. * @param forceDisposeTextures - Forces the disposal of all textures.
  20221. */
  20222. dispose(forceDisposeTextures?: boolean): void;
  20223. /**
  20224. * Get the current class name of the texture useful for serialization or dynamic coding.
  20225. * @returns "PBRClearCoatConfiguration"
  20226. */
  20227. getClassName(): string;
  20228. /**
  20229. * Add fallbacks to the effect fallbacks list.
  20230. * @param defines defines the Base texture to use.
  20231. * @param fallbacks defines the current fallback list.
  20232. * @param currentRank defines the current fallback rank.
  20233. * @returns the new fallback rank.
  20234. */
  20235. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20236. /**
  20237. * Add the required uniforms to the current list.
  20238. * @param uniforms defines the current uniform list.
  20239. */
  20240. static AddUniforms(uniforms: string[]): void;
  20241. /**
  20242. * Add the required samplers to the current list.
  20243. * @param samplers defines the current sampler list.
  20244. */
  20245. static AddSamplers(samplers: string[]): void;
  20246. /**
  20247. * Add the required uniforms to the current buffer.
  20248. * @param uniformBuffer defines the current uniform buffer.
  20249. */
  20250. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20251. /**
  20252. * Makes a duplicate of the current configuration into another one.
  20253. * @param clearCoatConfiguration define the config where to copy the info
  20254. */
  20255. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20256. /**
  20257. * Serializes this clear coat configuration.
  20258. * @returns - An object with the serialized config.
  20259. */
  20260. serialize(): any;
  20261. /**
  20262. * Parses a anisotropy Configuration from a serialized object.
  20263. * @param source - Serialized object.
  20264. * @param scene Defines the scene we are parsing for
  20265. * @param rootUrl Defines the rootUrl to load from
  20266. */
  20267. parse(source: any, scene: Scene, rootUrl: string): void;
  20268. }
  20269. }
  20270. declare module BABYLON {
  20271. /**
  20272. * @hidden
  20273. */
  20274. export interface IMaterialAnisotropicDefines {
  20275. ANISOTROPIC: boolean;
  20276. ANISOTROPIC_TEXTURE: boolean;
  20277. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20278. MAINUV1: boolean;
  20279. _areTexturesDirty: boolean;
  20280. _needUVs: boolean;
  20281. }
  20282. /**
  20283. * Define the code related to the anisotropic parameters of the pbr material.
  20284. */
  20285. export class PBRAnisotropicConfiguration {
  20286. private _isEnabled;
  20287. /**
  20288. * Defines if the anisotropy is enabled in the material.
  20289. */
  20290. isEnabled: boolean;
  20291. /**
  20292. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20293. */
  20294. intensity: number;
  20295. /**
  20296. * Defines if the effect is along the tangents, bitangents or in between.
  20297. * By default, the effect is "strectching" the highlights along the tangents.
  20298. */
  20299. direction: Vector2;
  20300. private _texture;
  20301. /**
  20302. * Stores the anisotropy values in a texture.
  20303. * rg is direction (like normal from -1 to 1)
  20304. * b is a intensity
  20305. */
  20306. texture: Nullable<BaseTexture>;
  20307. /** @hidden */
  20308. private _internalMarkAllSubMeshesAsTexturesDirty;
  20309. /** @hidden */
  20310. _markAllSubMeshesAsTexturesDirty(): void;
  20311. /**
  20312. * Instantiate a new istance of anisotropy configuration.
  20313. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20314. */
  20315. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20316. /**
  20317. * Specifies that the submesh is ready to be used.
  20318. * @param defines the list of "defines" to update.
  20319. * @param scene defines the scene the material belongs to.
  20320. * @returns - boolean indicating that the submesh is ready or not.
  20321. */
  20322. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20323. /**
  20324. * Checks to see if a texture is used in the material.
  20325. * @param defines the list of "defines" to update.
  20326. * @param mesh the mesh we are preparing the defines for.
  20327. * @param scene defines the scene the material belongs to.
  20328. */
  20329. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20330. /**
  20331. * Binds the material data.
  20332. * @param uniformBuffer defines the Uniform buffer to fill in.
  20333. * @param scene defines the scene the material belongs to.
  20334. * @param isFrozen defines wether the material is frozen or not.
  20335. */
  20336. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20337. /**
  20338. * Checks to see if a texture is used in the material.
  20339. * @param texture - Base texture to use.
  20340. * @returns - Boolean specifying if a texture is used in the material.
  20341. */
  20342. hasTexture(texture: BaseTexture): boolean;
  20343. /**
  20344. * Returns an array of the actively used textures.
  20345. * @param activeTextures Array of BaseTextures
  20346. */
  20347. getActiveTextures(activeTextures: BaseTexture[]): void;
  20348. /**
  20349. * Returns the animatable textures.
  20350. * @param animatables Array of animatable textures.
  20351. */
  20352. getAnimatables(animatables: IAnimatable[]): void;
  20353. /**
  20354. * Disposes the resources of the material.
  20355. * @param forceDisposeTextures - Forces the disposal of all textures.
  20356. */
  20357. dispose(forceDisposeTextures?: boolean): void;
  20358. /**
  20359. * Get the current class name of the texture useful for serialization or dynamic coding.
  20360. * @returns "PBRAnisotropicConfiguration"
  20361. */
  20362. getClassName(): string;
  20363. /**
  20364. * Add fallbacks to the effect fallbacks list.
  20365. * @param defines defines the Base texture to use.
  20366. * @param fallbacks defines the current fallback list.
  20367. * @param currentRank defines the current fallback rank.
  20368. * @returns the new fallback rank.
  20369. */
  20370. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20371. /**
  20372. * Add the required uniforms to the current list.
  20373. * @param uniforms defines the current uniform list.
  20374. */
  20375. static AddUniforms(uniforms: string[]): void;
  20376. /**
  20377. * Add the required uniforms to the current buffer.
  20378. * @param uniformBuffer defines the current uniform buffer.
  20379. */
  20380. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20381. /**
  20382. * Add the required samplers to the current list.
  20383. * @param samplers defines the current sampler list.
  20384. */
  20385. static AddSamplers(samplers: string[]): void;
  20386. /**
  20387. * Makes a duplicate of the current configuration into another one.
  20388. * @param anisotropicConfiguration define the config where to copy the info
  20389. */
  20390. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20391. /**
  20392. * Serializes this anisotropy configuration.
  20393. * @returns - An object with the serialized config.
  20394. */
  20395. serialize(): any;
  20396. /**
  20397. * Parses a anisotropy Configuration from a serialized object.
  20398. * @param source - Serialized object.
  20399. * @param scene Defines the scene we are parsing for
  20400. * @param rootUrl Defines the rootUrl to load from
  20401. */
  20402. parse(source: any, scene: Scene, rootUrl: string): void;
  20403. }
  20404. }
  20405. declare module BABYLON {
  20406. /**
  20407. * @hidden
  20408. */
  20409. export interface IMaterialBRDFDefines {
  20410. BRDF_V_HEIGHT_CORRELATED: boolean;
  20411. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20412. SPHERICAL_HARMONICS: boolean;
  20413. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20414. /** @hidden */
  20415. _areMiscDirty: boolean;
  20416. }
  20417. /**
  20418. * Define the code related to the BRDF parameters of the pbr material.
  20419. */
  20420. export class PBRBRDFConfiguration {
  20421. /**
  20422. * Default value used for the energy conservation.
  20423. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20424. */
  20425. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20426. /**
  20427. * Default value used for the Smith Visibility Height Correlated mode.
  20428. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20429. */
  20430. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20431. /**
  20432. * Default value used for the IBL diffuse part.
  20433. * This can help switching back to the polynomials mode globally which is a tiny bit
  20434. * less GPU intensive at the drawback of a lower quality.
  20435. */
  20436. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20437. /**
  20438. * Default value used for activating energy conservation for the specular workflow.
  20439. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20440. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20441. */
  20442. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20443. private _useEnergyConservation;
  20444. /**
  20445. * Defines if the material uses energy conservation.
  20446. */
  20447. useEnergyConservation: boolean;
  20448. private _useSmithVisibilityHeightCorrelated;
  20449. /**
  20450. * LEGACY Mode set to false
  20451. * Defines if the material uses height smith correlated visibility term.
  20452. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20453. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20454. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20455. * Not relying on height correlated will also disable energy conservation.
  20456. */
  20457. useSmithVisibilityHeightCorrelated: boolean;
  20458. private _useSphericalHarmonics;
  20459. /**
  20460. * LEGACY Mode set to false
  20461. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20462. * diffuse part of the IBL.
  20463. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20464. * to the ground truth.
  20465. */
  20466. useSphericalHarmonics: boolean;
  20467. private _useSpecularGlossinessInputEnergyConservation;
  20468. /**
  20469. * Defines if the material uses energy conservation, when the specular workflow is active.
  20470. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20471. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20472. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20473. */
  20474. useSpecularGlossinessInputEnergyConservation: boolean;
  20475. /** @hidden */
  20476. private _internalMarkAllSubMeshesAsMiscDirty;
  20477. /** @hidden */
  20478. _markAllSubMeshesAsMiscDirty(): void;
  20479. /**
  20480. * Instantiate a new istance of clear coat configuration.
  20481. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20482. */
  20483. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20484. /**
  20485. * Checks to see if a texture is used in the material.
  20486. * @param defines the list of "defines" to update.
  20487. */
  20488. prepareDefines(defines: IMaterialBRDFDefines): void;
  20489. /**
  20490. * Get the current class name of the texture useful for serialization or dynamic coding.
  20491. * @returns "PBRClearCoatConfiguration"
  20492. */
  20493. getClassName(): string;
  20494. /**
  20495. * Makes a duplicate of the current configuration into another one.
  20496. * @param brdfConfiguration define the config where to copy the info
  20497. */
  20498. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20499. /**
  20500. * Serializes this BRDF configuration.
  20501. * @returns - An object with the serialized config.
  20502. */
  20503. serialize(): any;
  20504. /**
  20505. * Parses a anisotropy Configuration from a serialized object.
  20506. * @param source - Serialized object.
  20507. * @param scene Defines the scene we are parsing for
  20508. * @param rootUrl Defines the rootUrl to load from
  20509. */
  20510. parse(source: any, scene: Scene, rootUrl: string): void;
  20511. }
  20512. }
  20513. declare module BABYLON {
  20514. /**
  20515. * @hidden
  20516. */
  20517. export interface IMaterialSheenDefines {
  20518. SHEEN: boolean;
  20519. SHEEN_TEXTURE: boolean;
  20520. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20521. SHEEN_TEXTUREDIRECTUV: number;
  20522. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20523. SHEEN_LINKWITHALBEDO: boolean;
  20524. SHEEN_ROUGHNESS: boolean;
  20525. SHEEN_ALBEDOSCALING: boolean;
  20526. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20527. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20528. /** @hidden */
  20529. _areTexturesDirty: boolean;
  20530. }
  20531. /**
  20532. * Define the code related to the Sheen parameters of the pbr material.
  20533. */
  20534. export class PBRSheenConfiguration {
  20535. private _isEnabled;
  20536. /**
  20537. * Defines if the material uses sheen.
  20538. */
  20539. isEnabled: boolean;
  20540. private _linkSheenWithAlbedo;
  20541. /**
  20542. * Defines if the sheen is linked to the sheen color.
  20543. */
  20544. linkSheenWithAlbedo: boolean;
  20545. /**
  20546. * Defines the sheen intensity.
  20547. */
  20548. intensity: number;
  20549. /**
  20550. * Defines the sheen color.
  20551. */
  20552. color: Color3;
  20553. private _texture;
  20554. /**
  20555. * Stores the sheen tint values in a texture.
  20556. * rgb is tint
  20557. * 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)
  20558. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20559. */
  20560. texture: Nullable<BaseTexture>;
  20561. private _useRoughnessFromMainTexture;
  20562. /**
  20563. * Indicates that the alpha channel of the texture property will be used for roughness.
  20564. * Has no effect if the roughness (and texture!) property is not defined
  20565. */
  20566. useRoughnessFromMainTexture: boolean;
  20567. private _roughness;
  20568. /**
  20569. * Defines the sheen roughness.
  20570. * It is not taken into account if linkSheenWithAlbedo is true.
  20571. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20572. */
  20573. roughness: Nullable<number>;
  20574. private _textureRoughness;
  20575. /**
  20576. * Stores the sheen roughness in a texture.
  20577. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20578. */
  20579. textureRoughness: Nullable<BaseTexture>;
  20580. private _albedoScaling;
  20581. /**
  20582. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20583. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20584. * making it easier to setup and tweak the effect
  20585. */
  20586. albedoScaling: boolean;
  20587. /** @hidden */
  20588. private _internalMarkAllSubMeshesAsTexturesDirty;
  20589. /** @hidden */
  20590. _markAllSubMeshesAsTexturesDirty(): void;
  20591. /**
  20592. * Instantiate a new istance of clear coat configuration.
  20593. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20594. */
  20595. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20596. /**
  20597. * Specifies that the submesh is ready to be used.
  20598. * @param defines the list of "defines" to update.
  20599. * @param scene defines the scene the material belongs to.
  20600. * @returns - boolean indicating that the submesh is ready or not.
  20601. */
  20602. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20603. /**
  20604. * Checks to see if a texture is used in the material.
  20605. * @param defines the list of "defines" to update.
  20606. * @param scene defines the scene the material belongs to.
  20607. */
  20608. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20609. /**
  20610. * Binds the material data.
  20611. * @param uniformBuffer defines the Uniform buffer to fill in.
  20612. * @param scene defines the scene the material belongs to.
  20613. * @param isFrozen defines wether the material is frozen or not.
  20614. * @param subMesh the submesh to bind data for
  20615. */
  20616. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20617. /**
  20618. * Checks to see if a texture is used in the material.
  20619. * @param texture - Base texture to use.
  20620. * @returns - Boolean specifying if a texture is used in the material.
  20621. */
  20622. hasTexture(texture: BaseTexture): boolean;
  20623. /**
  20624. * Returns an array of the actively used textures.
  20625. * @param activeTextures Array of BaseTextures
  20626. */
  20627. getActiveTextures(activeTextures: BaseTexture[]): void;
  20628. /**
  20629. * Returns the animatable textures.
  20630. * @param animatables Array of animatable textures.
  20631. */
  20632. getAnimatables(animatables: IAnimatable[]): void;
  20633. /**
  20634. * Disposes the resources of the material.
  20635. * @param forceDisposeTextures - Forces the disposal of all textures.
  20636. */
  20637. dispose(forceDisposeTextures?: boolean): void;
  20638. /**
  20639. * Get the current class name of the texture useful for serialization or dynamic coding.
  20640. * @returns "PBRSheenConfiguration"
  20641. */
  20642. getClassName(): string;
  20643. /**
  20644. * Add fallbacks to the effect fallbacks list.
  20645. * @param defines defines the Base texture to use.
  20646. * @param fallbacks defines the current fallback list.
  20647. * @param currentRank defines the current fallback rank.
  20648. * @returns the new fallback rank.
  20649. */
  20650. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20651. /**
  20652. * Add the required uniforms to the current list.
  20653. * @param uniforms defines the current uniform list.
  20654. */
  20655. static AddUniforms(uniforms: string[]): void;
  20656. /**
  20657. * Add the required uniforms to the current buffer.
  20658. * @param uniformBuffer defines the current uniform buffer.
  20659. */
  20660. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20661. /**
  20662. * Add the required samplers to the current list.
  20663. * @param samplers defines the current sampler list.
  20664. */
  20665. static AddSamplers(samplers: string[]): void;
  20666. /**
  20667. * Makes a duplicate of the current configuration into another one.
  20668. * @param sheenConfiguration define the config where to copy the info
  20669. */
  20670. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20671. /**
  20672. * Serializes this BRDF configuration.
  20673. * @returns - An object with the serialized config.
  20674. */
  20675. serialize(): any;
  20676. /**
  20677. * Parses a anisotropy Configuration from a serialized object.
  20678. * @param source - Serialized object.
  20679. * @param scene Defines the scene we are parsing for
  20680. * @param rootUrl Defines the rootUrl to load from
  20681. */
  20682. parse(source: any, scene: Scene, rootUrl: string): void;
  20683. }
  20684. }
  20685. declare module BABYLON {
  20686. /**
  20687. * @hidden
  20688. */
  20689. export interface IMaterialSubSurfaceDefines {
  20690. SUBSURFACE: boolean;
  20691. SS_REFRACTION: boolean;
  20692. SS_TRANSLUCENCY: boolean;
  20693. SS_SCATTERING: boolean;
  20694. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20695. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20696. SS_REFRACTIONMAP_3D: boolean;
  20697. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20698. SS_LODINREFRACTIONALPHA: boolean;
  20699. SS_GAMMAREFRACTION: boolean;
  20700. SS_RGBDREFRACTION: boolean;
  20701. SS_LINEARSPECULARREFRACTION: boolean;
  20702. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20703. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20704. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20705. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20706. /** @hidden */
  20707. _areTexturesDirty: boolean;
  20708. }
  20709. /**
  20710. * Define the code related to the sub surface parameters of the pbr material.
  20711. */
  20712. export class PBRSubSurfaceConfiguration {
  20713. private _isRefractionEnabled;
  20714. /**
  20715. * Defines if the refraction is enabled in the material.
  20716. */
  20717. isRefractionEnabled: boolean;
  20718. private _isTranslucencyEnabled;
  20719. /**
  20720. * Defines if the translucency is enabled in the material.
  20721. */
  20722. isTranslucencyEnabled: boolean;
  20723. private _isScatteringEnabled;
  20724. /**
  20725. * Defines if the sub surface scattering is enabled in the material.
  20726. */
  20727. isScatteringEnabled: boolean;
  20728. private _scatteringDiffusionProfileIndex;
  20729. /**
  20730. * Diffusion profile for subsurface scattering.
  20731. * Useful for better scattering in the skins or foliages.
  20732. */
  20733. get scatteringDiffusionProfile(): Nullable<Color3>;
  20734. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20735. /**
  20736. * Defines the refraction intensity of the material.
  20737. * The refraction when enabled replaces the Diffuse part of the material.
  20738. * The intensity helps transitionning between diffuse and refraction.
  20739. */
  20740. refractionIntensity: number;
  20741. /**
  20742. * Defines the translucency intensity of the material.
  20743. * When translucency has been enabled, this defines how much of the "translucency"
  20744. * is addded to the diffuse part of the material.
  20745. */
  20746. translucencyIntensity: number;
  20747. /**
  20748. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20749. */
  20750. useAlbedoToTintRefraction: boolean;
  20751. private _thicknessTexture;
  20752. /**
  20753. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20754. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20755. * 0 would mean minimumThickness
  20756. * 1 would mean maximumThickness
  20757. * The other channels might be use as a mask to vary the different effects intensity.
  20758. */
  20759. thicknessTexture: Nullable<BaseTexture>;
  20760. private _refractionTexture;
  20761. /**
  20762. * Defines the texture to use for refraction.
  20763. */
  20764. refractionTexture: Nullable<BaseTexture>;
  20765. private _indexOfRefraction;
  20766. /**
  20767. * Index of refraction of the material base layer.
  20768. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20769. *
  20770. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20771. *
  20772. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20773. */
  20774. indexOfRefraction: number;
  20775. private _volumeIndexOfRefraction;
  20776. /**
  20777. * Index of refraction of the material's volume.
  20778. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20779. *
  20780. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20781. * the volume will use the same IOR as the surface.
  20782. */
  20783. get volumeIndexOfRefraction(): number;
  20784. set volumeIndexOfRefraction(value: number);
  20785. private _invertRefractionY;
  20786. /**
  20787. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20788. */
  20789. invertRefractionY: boolean;
  20790. private _linkRefractionWithTransparency;
  20791. /**
  20792. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20793. * Materials half opaque for instance using refraction could benefit from this control.
  20794. */
  20795. linkRefractionWithTransparency: boolean;
  20796. /**
  20797. * Defines the minimum thickness stored in the thickness map.
  20798. * If no thickness map is defined, this value will be used to simulate thickness.
  20799. */
  20800. minimumThickness: number;
  20801. /**
  20802. * Defines the maximum thickness stored in the thickness map.
  20803. */
  20804. maximumThickness: number;
  20805. /**
  20806. * Defines the volume tint of the material.
  20807. * This is used for both translucency and scattering.
  20808. */
  20809. tintColor: Color3;
  20810. /**
  20811. * Defines the distance at which the tint color should be found in the media.
  20812. * This is used for refraction only.
  20813. */
  20814. tintColorAtDistance: number;
  20815. /**
  20816. * Defines how far each channel transmit through the media.
  20817. * It is defined as a color to simplify it selection.
  20818. */
  20819. diffusionDistance: Color3;
  20820. private _useMaskFromThicknessTexture;
  20821. /**
  20822. * Stores the intensity of the different subsurface effects in the thickness texture.
  20823. * * the green channel is the translucency intensity.
  20824. * * the blue channel is the scattering intensity.
  20825. * * the alpha channel is the refraction intensity.
  20826. */
  20827. useMaskFromThicknessTexture: boolean;
  20828. private _scene;
  20829. private _useMaskFromThicknessTextureGltf;
  20830. /**
  20831. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20832. * matches the channel-packing that is used by glTF.
  20833. * * the red channel is the transmission/translucency intensity.
  20834. * * the green channel is the thickness.
  20835. */
  20836. useMaskFromThicknessTextureGltf: boolean;
  20837. /** @hidden */
  20838. private _internalMarkAllSubMeshesAsTexturesDirty;
  20839. private _internalMarkScenePrePassDirty;
  20840. /** @hidden */
  20841. _markAllSubMeshesAsTexturesDirty(): void;
  20842. /** @hidden */
  20843. _markScenePrePassDirty(): void;
  20844. /**
  20845. * Instantiate a new istance of sub surface configuration.
  20846. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20847. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20848. * @param scene The scene
  20849. */
  20850. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20851. /**
  20852. * Gets wehter the submesh is ready to be used or not.
  20853. * @param defines the list of "defines" to update.
  20854. * @param scene defines the scene the material belongs to.
  20855. * @returns - boolean indicating that the submesh is ready or not.
  20856. */
  20857. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20858. /**
  20859. * Checks to see if a texture is used in the material.
  20860. * @param defines the list of "defines" to update.
  20861. * @param scene defines the scene to the material belongs to.
  20862. */
  20863. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20864. /**
  20865. * Binds the material data.
  20866. * @param uniformBuffer defines the Uniform buffer to fill in.
  20867. * @param scene defines the scene the material belongs to.
  20868. * @param engine defines the engine the material belongs to.
  20869. * @param isFrozen defines whether the material is frozen or not.
  20870. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20871. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20872. */
  20873. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20874. /**
  20875. * Unbinds the material from the mesh.
  20876. * @param activeEffect defines the effect that should be unbound from.
  20877. * @returns true if unbound, otherwise false
  20878. */
  20879. unbind(activeEffect: Effect): boolean;
  20880. /**
  20881. * Returns the texture used for refraction or null if none is used.
  20882. * @param scene defines the scene the material belongs to.
  20883. * @returns - Refraction texture if present. If no refraction texture and refraction
  20884. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20885. */
  20886. private _getRefractionTexture;
  20887. /**
  20888. * Returns true if alpha blending should be disabled.
  20889. */
  20890. get disableAlphaBlending(): boolean;
  20891. /**
  20892. * Fills the list of render target textures.
  20893. * @param renderTargets the list of render targets to update
  20894. */
  20895. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20896. /**
  20897. * Checks to see if a texture is used in the material.
  20898. * @param texture - Base texture to use.
  20899. * @returns - Boolean specifying if a texture is used in the material.
  20900. */
  20901. hasTexture(texture: BaseTexture): boolean;
  20902. /**
  20903. * Gets a boolean indicating that current material needs to register RTT
  20904. * @returns true if this uses a render target otherwise false.
  20905. */
  20906. hasRenderTargetTextures(): boolean;
  20907. /**
  20908. * Returns an array of the actively used textures.
  20909. * @param activeTextures Array of BaseTextures
  20910. */
  20911. getActiveTextures(activeTextures: BaseTexture[]): void;
  20912. /**
  20913. * Returns the animatable textures.
  20914. * @param animatables Array of animatable textures.
  20915. */
  20916. getAnimatables(animatables: IAnimatable[]): void;
  20917. /**
  20918. * Disposes the resources of the material.
  20919. * @param forceDisposeTextures - Forces the disposal of all textures.
  20920. */
  20921. dispose(forceDisposeTextures?: boolean): void;
  20922. /**
  20923. * Get the current class name of the texture useful for serialization or dynamic coding.
  20924. * @returns "PBRSubSurfaceConfiguration"
  20925. */
  20926. getClassName(): string;
  20927. /**
  20928. * Add fallbacks to the effect fallbacks list.
  20929. * @param defines defines the Base texture to use.
  20930. * @param fallbacks defines the current fallback list.
  20931. * @param currentRank defines the current fallback rank.
  20932. * @returns the new fallback rank.
  20933. */
  20934. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20935. /**
  20936. * Add the required uniforms to the current list.
  20937. * @param uniforms defines the current uniform list.
  20938. */
  20939. static AddUniforms(uniforms: string[]): void;
  20940. /**
  20941. * Add the required samplers to the current list.
  20942. * @param samplers defines the current sampler list.
  20943. */
  20944. static AddSamplers(samplers: string[]): void;
  20945. /**
  20946. * Add the required uniforms to the current buffer.
  20947. * @param uniformBuffer defines the current uniform buffer.
  20948. */
  20949. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20950. /**
  20951. * Makes a duplicate of the current configuration into another one.
  20952. * @param configuration define the config where to copy the info
  20953. */
  20954. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20955. /**
  20956. * Serializes this Sub Surface configuration.
  20957. * @returns - An object with the serialized config.
  20958. */
  20959. serialize(): any;
  20960. /**
  20961. * Parses a anisotropy Configuration from a serialized object.
  20962. * @param source - Serialized object.
  20963. * @param scene Defines the scene we are parsing for
  20964. * @param rootUrl Defines the rootUrl to load from
  20965. */
  20966. parse(source: any, scene: Scene, rootUrl: string): void;
  20967. }
  20968. }
  20969. declare module BABYLON {
  20970. /**
  20971. * Class representing spherical harmonics coefficients to the 3rd degree
  20972. */
  20973. export class SphericalHarmonics {
  20974. /**
  20975. * Defines whether or not the harmonics have been prescaled for rendering.
  20976. */
  20977. preScaled: boolean;
  20978. /**
  20979. * The l0,0 coefficients of the spherical harmonics
  20980. */
  20981. l00: Vector3;
  20982. /**
  20983. * The l1,-1 coefficients of the spherical harmonics
  20984. */
  20985. l1_1: Vector3;
  20986. /**
  20987. * The l1,0 coefficients of the spherical harmonics
  20988. */
  20989. l10: Vector3;
  20990. /**
  20991. * The l1,1 coefficients of the spherical harmonics
  20992. */
  20993. l11: Vector3;
  20994. /**
  20995. * The l2,-2 coefficients of the spherical harmonics
  20996. */
  20997. l2_2: Vector3;
  20998. /**
  20999. * The l2,-1 coefficients of the spherical harmonics
  21000. */
  21001. l2_1: Vector3;
  21002. /**
  21003. * The l2,0 coefficients of the spherical harmonics
  21004. */
  21005. l20: Vector3;
  21006. /**
  21007. * The l2,1 coefficients of the spherical harmonics
  21008. */
  21009. l21: Vector3;
  21010. /**
  21011. * The l2,2 coefficients of the spherical harmonics
  21012. */
  21013. l22: Vector3;
  21014. /**
  21015. * Adds a light to the spherical harmonics
  21016. * @param direction the direction of the light
  21017. * @param color the color of the light
  21018. * @param deltaSolidAngle the delta solid angle of the light
  21019. */
  21020. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21021. /**
  21022. * Scales the spherical harmonics by the given amount
  21023. * @param scale the amount to scale
  21024. */
  21025. scaleInPlace(scale: number): void;
  21026. /**
  21027. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21028. *
  21029. * ```
  21030. * E_lm = A_l * L_lm
  21031. * ```
  21032. *
  21033. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21034. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21035. * the scaling factors are given in equation 9.
  21036. */
  21037. convertIncidentRadianceToIrradiance(): void;
  21038. /**
  21039. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21040. *
  21041. * ```
  21042. * L = (1/pi) * E * rho
  21043. * ```
  21044. *
  21045. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21046. */
  21047. convertIrradianceToLambertianRadiance(): void;
  21048. /**
  21049. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21050. * required operations at run time.
  21051. *
  21052. * This is simply done by scaling back the SH with Ylm constants parameter.
  21053. * The trigonometric part being applied by the shader at run time.
  21054. */
  21055. preScaleForRendering(): void;
  21056. /**
  21057. * Constructs a spherical harmonics from an array.
  21058. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21059. * @returns the spherical harmonics
  21060. */
  21061. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21062. /**
  21063. * Gets the spherical harmonics from polynomial
  21064. * @param polynomial the spherical polynomial
  21065. * @returns the spherical harmonics
  21066. */
  21067. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21068. }
  21069. /**
  21070. * Class representing spherical polynomial coefficients to the 3rd degree
  21071. */
  21072. export class SphericalPolynomial {
  21073. private _harmonics;
  21074. /**
  21075. * The spherical harmonics used to create the polynomials.
  21076. */
  21077. get preScaledHarmonics(): SphericalHarmonics;
  21078. /**
  21079. * The x coefficients of the spherical polynomial
  21080. */
  21081. x: Vector3;
  21082. /**
  21083. * The y coefficients of the spherical polynomial
  21084. */
  21085. y: Vector3;
  21086. /**
  21087. * The z coefficients of the spherical polynomial
  21088. */
  21089. z: Vector3;
  21090. /**
  21091. * The xx coefficients of the spherical polynomial
  21092. */
  21093. xx: Vector3;
  21094. /**
  21095. * The yy coefficients of the spherical polynomial
  21096. */
  21097. yy: Vector3;
  21098. /**
  21099. * The zz coefficients of the spherical polynomial
  21100. */
  21101. zz: Vector3;
  21102. /**
  21103. * The xy coefficients of the spherical polynomial
  21104. */
  21105. xy: Vector3;
  21106. /**
  21107. * The yz coefficients of the spherical polynomial
  21108. */
  21109. yz: Vector3;
  21110. /**
  21111. * The zx coefficients of the spherical polynomial
  21112. */
  21113. zx: Vector3;
  21114. /**
  21115. * Adds an ambient color to the spherical polynomial
  21116. * @param color the color to add
  21117. */
  21118. addAmbient(color: Color3): void;
  21119. /**
  21120. * Scales the spherical polynomial by the given amount
  21121. * @param scale the amount to scale
  21122. */
  21123. scaleInPlace(scale: number): void;
  21124. /**
  21125. * Gets the spherical polynomial from harmonics
  21126. * @param harmonics the spherical harmonics
  21127. * @returns the spherical polynomial
  21128. */
  21129. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21130. /**
  21131. * Constructs a spherical polynomial from an array.
  21132. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21133. * @returns the spherical polynomial
  21134. */
  21135. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21136. }
  21137. }
  21138. declare module BABYLON {
  21139. /**
  21140. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21141. */
  21142. export interface CubeMapInfo {
  21143. /**
  21144. * The pixel array for the front face.
  21145. * This is stored in format, left to right, up to down format.
  21146. */
  21147. front: Nullable<ArrayBufferView>;
  21148. /**
  21149. * The pixel array for the back face.
  21150. * This is stored in format, left to right, up to down format.
  21151. */
  21152. back: Nullable<ArrayBufferView>;
  21153. /**
  21154. * The pixel array for the left face.
  21155. * This is stored in format, left to right, up to down format.
  21156. */
  21157. left: Nullable<ArrayBufferView>;
  21158. /**
  21159. * The pixel array for the right face.
  21160. * This is stored in format, left to right, up to down format.
  21161. */
  21162. right: Nullable<ArrayBufferView>;
  21163. /**
  21164. * The pixel array for the up face.
  21165. * This is stored in format, left to right, up to down format.
  21166. */
  21167. up: Nullable<ArrayBufferView>;
  21168. /**
  21169. * The pixel array for the down face.
  21170. * This is stored in format, left to right, up to down format.
  21171. */
  21172. down: Nullable<ArrayBufferView>;
  21173. /**
  21174. * The size of the cubemap stored.
  21175. *
  21176. * Each faces will be size * size pixels.
  21177. */
  21178. size: number;
  21179. /**
  21180. * The format of the texture.
  21181. *
  21182. * RGBA, RGB.
  21183. */
  21184. format: number;
  21185. /**
  21186. * The type of the texture data.
  21187. *
  21188. * UNSIGNED_INT, FLOAT.
  21189. */
  21190. type: number;
  21191. /**
  21192. * Specifies whether the texture is in gamma space.
  21193. */
  21194. gammaSpace: boolean;
  21195. }
  21196. /**
  21197. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21198. */
  21199. export class PanoramaToCubeMapTools {
  21200. private static FACE_LEFT;
  21201. private static FACE_RIGHT;
  21202. private static FACE_FRONT;
  21203. private static FACE_BACK;
  21204. private static FACE_DOWN;
  21205. private static FACE_UP;
  21206. /**
  21207. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21208. *
  21209. * @param float32Array The source data.
  21210. * @param inputWidth The width of the input panorama.
  21211. * @param inputHeight The height of the input panorama.
  21212. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21213. * @return The cubemap data
  21214. */
  21215. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21216. private static CreateCubemapTexture;
  21217. private static CalcProjectionSpherical;
  21218. }
  21219. }
  21220. declare module BABYLON {
  21221. /**
  21222. * Helper class dealing with the extraction of spherical polynomial dataArray
  21223. * from a cube map.
  21224. */
  21225. export class CubeMapToSphericalPolynomialTools {
  21226. private static FileFaces;
  21227. /**
  21228. * Converts a texture to the according Spherical Polynomial data.
  21229. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21230. *
  21231. * @param texture The texture to extract the information from.
  21232. * @return The Spherical Polynomial data.
  21233. */
  21234. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21235. /**
  21236. * Converts a cubemap to the according Spherical Polynomial data.
  21237. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21238. *
  21239. * @param cubeInfo The Cube map to extract the information from.
  21240. * @return The Spherical Polynomial data.
  21241. */
  21242. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21243. }
  21244. }
  21245. declare module BABYLON {
  21246. interface BaseTexture {
  21247. /**
  21248. * Get the polynomial representation of the texture data.
  21249. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21250. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21251. */
  21252. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21253. }
  21254. }
  21255. declare module BABYLON {
  21256. /** @hidden */
  21257. export var pbrFragmentDeclaration: {
  21258. name: string;
  21259. shader: string;
  21260. };
  21261. }
  21262. declare module BABYLON {
  21263. /** @hidden */
  21264. export var pbrUboDeclaration: {
  21265. name: string;
  21266. shader: string;
  21267. };
  21268. }
  21269. declare module BABYLON {
  21270. /** @hidden */
  21271. export var pbrFragmentExtraDeclaration: {
  21272. name: string;
  21273. shader: string;
  21274. };
  21275. }
  21276. declare module BABYLON {
  21277. /** @hidden */
  21278. export var pbrFragmentSamplersDeclaration: {
  21279. name: string;
  21280. shader: string;
  21281. };
  21282. }
  21283. declare module BABYLON {
  21284. /** @hidden */
  21285. export var subSurfaceScatteringFunctions: {
  21286. name: string;
  21287. shader: string;
  21288. };
  21289. }
  21290. declare module BABYLON {
  21291. /** @hidden */
  21292. export var importanceSampling: {
  21293. name: string;
  21294. shader: string;
  21295. };
  21296. }
  21297. declare module BABYLON {
  21298. /** @hidden */
  21299. export var pbrHelperFunctions: {
  21300. name: string;
  21301. shader: string;
  21302. };
  21303. }
  21304. declare module BABYLON {
  21305. /** @hidden */
  21306. export var harmonicsFunctions: {
  21307. name: string;
  21308. shader: string;
  21309. };
  21310. }
  21311. declare module BABYLON {
  21312. /** @hidden */
  21313. export var pbrDirectLightingSetupFunctions: {
  21314. name: string;
  21315. shader: string;
  21316. };
  21317. }
  21318. declare module BABYLON {
  21319. /** @hidden */
  21320. export var pbrDirectLightingFalloffFunctions: {
  21321. name: string;
  21322. shader: string;
  21323. };
  21324. }
  21325. declare module BABYLON {
  21326. /** @hidden */
  21327. export var pbrBRDFFunctions: {
  21328. name: string;
  21329. shader: string;
  21330. };
  21331. }
  21332. declare module BABYLON {
  21333. /** @hidden */
  21334. export var hdrFilteringFunctions: {
  21335. name: string;
  21336. shader: string;
  21337. };
  21338. }
  21339. declare module BABYLON {
  21340. /** @hidden */
  21341. export var pbrDirectLightingFunctions: {
  21342. name: string;
  21343. shader: string;
  21344. };
  21345. }
  21346. declare module BABYLON {
  21347. /** @hidden */
  21348. export var pbrIBLFunctions: {
  21349. name: string;
  21350. shader: string;
  21351. };
  21352. }
  21353. declare module BABYLON {
  21354. /** @hidden */
  21355. export var pbrBlockAlbedoOpacity: {
  21356. name: string;
  21357. shader: string;
  21358. };
  21359. }
  21360. declare module BABYLON {
  21361. /** @hidden */
  21362. export var pbrBlockReflectivity: {
  21363. name: string;
  21364. shader: string;
  21365. };
  21366. }
  21367. declare module BABYLON {
  21368. /** @hidden */
  21369. export var pbrBlockAmbientOcclusion: {
  21370. name: string;
  21371. shader: string;
  21372. };
  21373. }
  21374. declare module BABYLON {
  21375. /** @hidden */
  21376. export var pbrBlockAlphaFresnel: {
  21377. name: string;
  21378. shader: string;
  21379. };
  21380. }
  21381. declare module BABYLON {
  21382. /** @hidden */
  21383. export var pbrBlockAnisotropic: {
  21384. name: string;
  21385. shader: string;
  21386. };
  21387. }
  21388. declare module BABYLON {
  21389. /** @hidden */
  21390. export var pbrBlockReflection: {
  21391. name: string;
  21392. shader: string;
  21393. };
  21394. }
  21395. declare module BABYLON {
  21396. /** @hidden */
  21397. export var pbrBlockSheen: {
  21398. name: string;
  21399. shader: string;
  21400. };
  21401. }
  21402. declare module BABYLON {
  21403. /** @hidden */
  21404. export var pbrBlockClearcoat: {
  21405. name: string;
  21406. shader: string;
  21407. };
  21408. }
  21409. declare module BABYLON {
  21410. /** @hidden */
  21411. export var pbrBlockSubSurface: {
  21412. name: string;
  21413. shader: string;
  21414. };
  21415. }
  21416. declare module BABYLON {
  21417. /** @hidden */
  21418. export var pbrBlockNormalGeometric: {
  21419. name: string;
  21420. shader: string;
  21421. };
  21422. }
  21423. declare module BABYLON {
  21424. /** @hidden */
  21425. export var pbrBlockNormalFinal: {
  21426. name: string;
  21427. shader: string;
  21428. };
  21429. }
  21430. declare module BABYLON {
  21431. /** @hidden */
  21432. export var pbrBlockLightmapInit: {
  21433. name: string;
  21434. shader: string;
  21435. };
  21436. }
  21437. declare module BABYLON {
  21438. /** @hidden */
  21439. export var pbrBlockGeometryInfo: {
  21440. name: string;
  21441. shader: string;
  21442. };
  21443. }
  21444. declare module BABYLON {
  21445. /** @hidden */
  21446. export var pbrBlockReflectance0: {
  21447. name: string;
  21448. shader: string;
  21449. };
  21450. }
  21451. declare module BABYLON {
  21452. /** @hidden */
  21453. export var pbrBlockReflectance: {
  21454. name: string;
  21455. shader: string;
  21456. };
  21457. }
  21458. declare module BABYLON {
  21459. /** @hidden */
  21460. export var pbrBlockDirectLighting: {
  21461. name: string;
  21462. shader: string;
  21463. };
  21464. }
  21465. declare module BABYLON {
  21466. /** @hidden */
  21467. export var pbrBlockFinalLitComponents: {
  21468. name: string;
  21469. shader: string;
  21470. };
  21471. }
  21472. declare module BABYLON {
  21473. /** @hidden */
  21474. export var pbrBlockFinalUnlitComponents: {
  21475. name: string;
  21476. shader: string;
  21477. };
  21478. }
  21479. declare module BABYLON {
  21480. /** @hidden */
  21481. export var pbrBlockFinalColorComposition: {
  21482. name: string;
  21483. shader: string;
  21484. };
  21485. }
  21486. declare module BABYLON {
  21487. /** @hidden */
  21488. export var pbrBlockImageProcessing: {
  21489. name: string;
  21490. shader: string;
  21491. };
  21492. }
  21493. declare module BABYLON {
  21494. /** @hidden */
  21495. export var pbrDebug: {
  21496. name: string;
  21497. shader: string;
  21498. };
  21499. }
  21500. declare module BABYLON {
  21501. /** @hidden */
  21502. export var pbrPixelShader: {
  21503. name: string;
  21504. shader: string;
  21505. };
  21506. }
  21507. declare module BABYLON {
  21508. /** @hidden */
  21509. export var pbrVertexDeclaration: {
  21510. name: string;
  21511. shader: string;
  21512. };
  21513. }
  21514. declare module BABYLON {
  21515. /** @hidden */
  21516. export var pbrVertexShader: {
  21517. name: string;
  21518. shader: string;
  21519. };
  21520. }
  21521. declare module BABYLON {
  21522. /**
  21523. * Manages the defines for the PBR Material.
  21524. * @hidden
  21525. */
  21526. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21527. PBR: boolean;
  21528. NUM_SAMPLES: string;
  21529. REALTIME_FILTERING: boolean;
  21530. MAINUV1: boolean;
  21531. MAINUV2: boolean;
  21532. UV1: boolean;
  21533. UV2: boolean;
  21534. ALBEDO: boolean;
  21535. GAMMAALBEDO: boolean;
  21536. ALBEDODIRECTUV: number;
  21537. VERTEXCOLOR: boolean;
  21538. DETAIL: boolean;
  21539. DETAILDIRECTUV: number;
  21540. DETAIL_NORMALBLENDMETHOD: number;
  21541. AMBIENT: boolean;
  21542. AMBIENTDIRECTUV: number;
  21543. AMBIENTINGRAYSCALE: boolean;
  21544. OPACITY: boolean;
  21545. VERTEXALPHA: boolean;
  21546. OPACITYDIRECTUV: number;
  21547. OPACITYRGB: boolean;
  21548. ALPHATEST: boolean;
  21549. DEPTHPREPASS: boolean;
  21550. ALPHABLEND: boolean;
  21551. ALPHAFROMALBEDO: boolean;
  21552. ALPHATESTVALUE: string;
  21553. SPECULAROVERALPHA: boolean;
  21554. RADIANCEOVERALPHA: boolean;
  21555. ALPHAFRESNEL: boolean;
  21556. LINEARALPHAFRESNEL: boolean;
  21557. PREMULTIPLYALPHA: boolean;
  21558. EMISSIVE: boolean;
  21559. EMISSIVEDIRECTUV: number;
  21560. REFLECTIVITY: boolean;
  21561. REFLECTIVITYDIRECTUV: number;
  21562. SPECULARTERM: boolean;
  21563. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21564. MICROSURFACEAUTOMATIC: boolean;
  21565. LODBASEDMICROSFURACE: boolean;
  21566. MICROSURFACEMAP: boolean;
  21567. MICROSURFACEMAPDIRECTUV: number;
  21568. METALLICWORKFLOW: boolean;
  21569. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21570. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21571. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21572. AOSTOREINMETALMAPRED: boolean;
  21573. METALLIC_REFLECTANCE: boolean;
  21574. METALLIC_REFLECTANCEDIRECTUV: number;
  21575. ENVIRONMENTBRDF: boolean;
  21576. ENVIRONMENTBRDF_RGBD: boolean;
  21577. NORMAL: boolean;
  21578. TANGENT: boolean;
  21579. BUMP: boolean;
  21580. BUMPDIRECTUV: number;
  21581. OBJECTSPACE_NORMALMAP: boolean;
  21582. PARALLAX: boolean;
  21583. PARALLAXOCCLUSION: boolean;
  21584. NORMALXYSCALE: boolean;
  21585. LIGHTMAP: boolean;
  21586. LIGHTMAPDIRECTUV: number;
  21587. USELIGHTMAPASSHADOWMAP: boolean;
  21588. GAMMALIGHTMAP: boolean;
  21589. RGBDLIGHTMAP: boolean;
  21590. REFLECTION: boolean;
  21591. REFLECTIONMAP_3D: boolean;
  21592. REFLECTIONMAP_SPHERICAL: boolean;
  21593. REFLECTIONMAP_PLANAR: boolean;
  21594. REFLECTIONMAP_CUBIC: boolean;
  21595. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21596. REFLECTIONMAP_PROJECTION: boolean;
  21597. REFLECTIONMAP_SKYBOX: boolean;
  21598. REFLECTIONMAP_EXPLICIT: boolean;
  21599. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21600. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21601. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21602. INVERTCUBICMAP: boolean;
  21603. USESPHERICALFROMREFLECTIONMAP: boolean;
  21604. USEIRRADIANCEMAP: boolean;
  21605. SPHERICAL_HARMONICS: boolean;
  21606. USESPHERICALINVERTEX: boolean;
  21607. REFLECTIONMAP_OPPOSITEZ: boolean;
  21608. LODINREFLECTIONALPHA: boolean;
  21609. GAMMAREFLECTION: boolean;
  21610. RGBDREFLECTION: boolean;
  21611. LINEARSPECULARREFLECTION: boolean;
  21612. RADIANCEOCCLUSION: boolean;
  21613. HORIZONOCCLUSION: boolean;
  21614. INSTANCES: boolean;
  21615. THIN_INSTANCES: boolean;
  21616. PREPASS: boolean;
  21617. PREPASS_IRRADIANCE: boolean;
  21618. PREPASS_IRRADIANCE_INDEX: number;
  21619. PREPASS_ALBEDO: boolean;
  21620. PREPASS_ALBEDO_INDEX: number;
  21621. PREPASS_DEPTHNORMAL: boolean;
  21622. PREPASS_DEPTHNORMAL_INDEX: number;
  21623. PREPASS_POSITION: boolean;
  21624. PREPASS_POSITION_INDEX: number;
  21625. PREPASS_VELOCITY: boolean;
  21626. PREPASS_VELOCITY_INDEX: number;
  21627. PREPASS_REFLECTIVITY: boolean;
  21628. PREPASS_REFLECTIVITY_INDEX: number;
  21629. SCENE_MRT_COUNT: number;
  21630. NUM_BONE_INFLUENCERS: number;
  21631. BonesPerMesh: number;
  21632. BONETEXTURE: boolean;
  21633. BONES_VELOCITY_ENABLED: boolean;
  21634. NONUNIFORMSCALING: boolean;
  21635. MORPHTARGETS: boolean;
  21636. MORPHTARGETS_NORMAL: boolean;
  21637. MORPHTARGETS_TANGENT: boolean;
  21638. MORPHTARGETS_UV: boolean;
  21639. NUM_MORPH_INFLUENCERS: number;
  21640. IMAGEPROCESSING: boolean;
  21641. VIGNETTE: boolean;
  21642. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21643. VIGNETTEBLENDMODEOPAQUE: boolean;
  21644. TONEMAPPING: boolean;
  21645. TONEMAPPING_ACES: boolean;
  21646. CONTRAST: boolean;
  21647. COLORCURVES: boolean;
  21648. COLORGRADING: boolean;
  21649. COLORGRADING3D: boolean;
  21650. SAMPLER3DGREENDEPTH: boolean;
  21651. SAMPLER3DBGRMAP: boolean;
  21652. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21653. EXPOSURE: boolean;
  21654. MULTIVIEW: boolean;
  21655. USEPHYSICALLIGHTFALLOFF: boolean;
  21656. USEGLTFLIGHTFALLOFF: boolean;
  21657. TWOSIDEDLIGHTING: boolean;
  21658. SHADOWFLOAT: boolean;
  21659. CLIPPLANE: boolean;
  21660. CLIPPLANE2: boolean;
  21661. CLIPPLANE3: boolean;
  21662. CLIPPLANE4: boolean;
  21663. CLIPPLANE5: boolean;
  21664. CLIPPLANE6: boolean;
  21665. POINTSIZE: boolean;
  21666. FOG: boolean;
  21667. LOGARITHMICDEPTH: boolean;
  21668. FORCENORMALFORWARD: boolean;
  21669. SPECULARAA: boolean;
  21670. CLEARCOAT: boolean;
  21671. CLEARCOAT_DEFAULTIOR: boolean;
  21672. CLEARCOAT_TEXTURE: boolean;
  21673. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21674. CLEARCOAT_TEXTUREDIRECTUV: number;
  21675. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21676. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21677. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21678. CLEARCOAT_BUMP: boolean;
  21679. CLEARCOAT_BUMPDIRECTUV: number;
  21680. CLEARCOAT_REMAP_F0: boolean;
  21681. CLEARCOAT_TINT: boolean;
  21682. CLEARCOAT_TINT_TEXTURE: boolean;
  21683. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21684. ANISOTROPIC: boolean;
  21685. ANISOTROPIC_TEXTURE: boolean;
  21686. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21687. BRDF_V_HEIGHT_CORRELATED: boolean;
  21688. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21689. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21690. SHEEN: boolean;
  21691. SHEEN_TEXTURE: boolean;
  21692. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21693. SHEEN_TEXTUREDIRECTUV: number;
  21694. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21695. SHEEN_LINKWITHALBEDO: boolean;
  21696. SHEEN_ROUGHNESS: boolean;
  21697. SHEEN_ALBEDOSCALING: boolean;
  21698. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21699. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21700. SUBSURFACE: boolean;
  21701. SS_REFRACTION: boolean;
  21702. SS_TRANSLUCENCY: boolean;
  21703. SS_SCATTERING: boolean;
  21704. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21705. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21706. SS_REFRACTIONMAP_3D: boolean;
  21707. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21708. SS_LODINREFRACTIONALPHA: boolean;
  21709. SS_GAMMAREFRACTION: boolean;
  21710. SS_RGBDREFRACTION: boolean;
  21711. SS_LINEARSPECULARREFRACTION: boolean;
  21712. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21713. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21714. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21715. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21716. UNLIT: boolean;
  21717. DEBUGMODE: number;
  21718. /**
  21719. * Initializes the PBR Material defines.
  21720. */
  21721. constructor();
  21722. /**
  21723. * Resets the PBR Material defines.
  21724. */
  21725. reset(): void;
  21726. }
  21727. /**
  21728. * The Physically based material base class of BJS.
  21729. *
  21730. * This offers the main features of a standard PBR material.
  21731. * For more information, please refer to the documentation :
  21732. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21733. */
  21734. export abstract class PBRBaseMaterial extends PushMaterial {
  21735. /**
  21736. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21737. */
  21738. static readonly PBRMATERIAL_OPAQUE: number;
  21739. /**
  21740. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21741. */
  21742. static readonly PBRMATERIAL_ALPHATEST: number;
  21743. /**
  21744. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21745. */
  21746. static readonly PBRMATERIAL_ALPHABLEND: number;
  21747. /**
  21748. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21749. * They are also discarded below the alpha cutoff threshold to improve performances.
  21750. */
  21751. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21752. /**
  21753. * Defines the default value of how much AO map is occluding the analytical lights
  21754. * (point spot...).
  21755. */
  21756. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21757. /**
  21758. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21759. */
  21760. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21761. /**
  21762. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21763. * to enhance interoperability with other engines.
  21764. */
  21765. static readonly LIGHTFALLOFF_GLTF: number;
  21766. /**
  21767. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21768. * to enhance interoperability with other materials.
  21769. */
  21770. static readonly LIGHTFALLOFF_STANDARD: number;
  21771. /**
  21772. * Intensity of the direct lights e.g. the four lights available in your scene.
  21773. * This impacts both the direct diffuse and specular highlights.
  21774. */
  21775. protected _directIntensity: number;
  21776. /**
  21777. * Intensity of the emissive part of the material.
  21778. * This helps controlling the emissive effect without modifying the emissive color.
  21779. */
  21780. protected _emissiveIntensity: number;
  21781. /**
  21782. * Intensity of the environment e.g. how much the environment will light the object
  21783. * either through harmonics for rough material or through the refelction for shiny ones.
  21784. */
  21785. protected _environmentIntensity: number;
  21786. /**
  21787. * This is a special control allowing the reduction of the specular highlights coming from the
  21788. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21789. */
  21790. protected _specularIntensity: number;
  21791. /**
  21792. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21793. */
  21794. private _lightingInfos;
  21795. /**
  21796. * Debug Control allowing disabling the bump map on this material.
  21797. */
  21798. protected _disableBumpMap: boolean;
  21799. /**
  21800. * AKA Diffuse Texture in standard nomenclature.
  21801. */
  21802. protected _albedoTexture: Nullable<BaseTexture>;
  21803. /**
  21804. * AKA Occlusion Texture in other nomenclature.
  21805. */
  21806. protected _ambientTexture: Nullable<BaseTexture>;
  21807. /**
  21808. * AKA Occlusion Texture Intensity in other nomenclature.
  21809. */
  21810. protected _ambientTextureStrength: number;
  21811. /**
  21812. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21813. * 1 means it completely occludes it
  21814. * 0 mean it has no impact
  21815. */
  21816. protected _ambientTextureImpactOnAnalyticalLights: number;
  21817. /**
  21818. * Stores the alpha values in a texture.
  21819. */
  21820. protected _opacityTexture: Nullable<BaseTexture>;
  21821. /**
  21822. * Stores the reflection values in a texture.
  21823. */
  21824. protected _reflectionTexture: Nullable<BaseTexture>;
  21825. /**
  21826. * Stores the emissive values in a texture.
  21827. */
  21828. protected _emissiveTexture: Nullable<BaseTexture>;
  21829. /**
  21830. * AKA Specular texture in other nomenclature.
  21831. */
  21832. protected _reflectivityTexture: Nullable<BaseTexture>;
  21833. /**
  21834. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21835. */
  21836. protected _metallicTexture: Nullable<BaseTexture>;
  21837. /**
  21838. * Specifies the metallic scalar of the metallic/roughness workflow.
  21839. * Can also be used to scale the metalness values of the metallic texture.
  21840. */
  21841. protected _metallic: Nullable<number>;
  21842. /**
  21843. * Specifies the roughness scalar of the metallic/roughness workflow.
  21844. * Can also be used to scale the roughness values of the metallic texture.
  21845. */
  21846. protected _roughness: Nullable<number>;
  21847. /**
  21848. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21849. * By default the indexOfrefraction is used to compute F0;
  21850. *
  21851. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21852. *
  21853. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21854. * F90 = metallicReflectanceColor;
  21855. */
  21856. protected _metallicF0Factor: number;
  21857. /**
  21858. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21859. * By default the F90 is always 1;
  21860. *
  21861. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21862. *
  21863. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21864. * F90 = metallicReflectanceColor;
  21865. */
  21866. protected _metallicReflectanceColor: Color3;
  21867. /**
  21868. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21869. * This is multiply against the scalar values defined in the material.
  21870. */
  21871. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21872. /**
  21873. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21874. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21875. */
  21876. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21877. /**
  21878. * Stores surface normal data used to displace a mesh in a texture.
  21879. */
  21880. protected _bumpTexture: Nullable<BaseTexture>;
  21881. /**
  21882. * Stores the pre-calculated light information of a mesh in a texture.
  21883. */
  21884. protected _lightmapTexture: Nullable<BaseTexture>;
  21885. /**
  21886. * The color of a material in ambient lighting.
  21887. */
  21888. protected _ambientColor: Color3;
  21889. /**
  21890. * AKA Diffuse Color in other nomenclature.
  21891. */
  21892. protected _albedoColor: Color3;
  21893. /**
  21894. * AKA Specular Color in other nomenclature.
  21895. */
  21896. protected _reflectivityColor: Color3;
  21897. /**
  21898. * The color applied when light is reflected from a material.
  21899. */
  21900. protected _reflectionColor: Color3;
  21901. /**
  21902. * The color applied when light is emitted from a material.
  21903. */
  21904. protected _emissiveColor: Color3;
  21905. /**
  21906. * AKA Glossiness in other nomenclature.
  21907. */
  21908. protected _microSurface: number;
  21909. /**
  21910. * Specifies that the material will use the light map as a show map.
  21911. */
  21912. protected _useLightmapAsShadowmap: boolean;
  21913. /**
  21914. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21915. * makes the reflect vector face the model (under horizon).
  21916. */
  21917. protected _useHorizonOcclusion: boolean;
  21918. /**
  21919. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21920. * too much the area relying on ambient texture to define their ambient occlusion.
  21921. */
  21922. protected _useRadianceOcclusion: boolean;
  21923. /**
  21924. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21925. */
  21926. protected _useAlphaFromAlbedoTexture: boolean;
  21927. /**
  21928. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21929. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21930. */
  21931. protected _useSpecularOverAlpha: boolean;
  21932. /**
  21933. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21934. */
  21935. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21936. /**
  21937. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21938. */
  21939. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21940. /**
  21941. * Specifies if the metallic texture contains the roughness information in its green channel.
  21942. */
  21943. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21944. /**
  21945. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21946. */
  21947. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21948. /**
  21949. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21950. */
  21951. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21952. /**
  21953. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21954. */
  21955. protected _useAmbientInGrayScale: boolean;
  21956. /**
  21957. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21958. * The material will try to infer what glossiness each pixel should be.
  21959. */
  21960. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21961. /**
  21962. * Defines the falloff type used in this material.
  21963. * It by default is Physical.
  21964. */
  21965. protected _lightFalloff: number;
  21966. /**
  21967. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21968. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21969. */
  21970. protected _useRadianceOverAlpha: boolean;
  21971. /**
  21972. * Allows using an object space normal map (instead of tangent space).
  21973. */
  21974. protected _useObjectSpaceNormalMap: boolean;
  21975. /**
  21976. * Allows using the bump map in parallax mode.
  21977. */
  21978. protected _useParallax: boolean;
  21979. /**
  21980. * Allows using the bump map in parallax occlusion mode.
  21981. */
  21982. protected _useParallaxOcclusion: boolean;
  21983. /**
  21984. * Controls the scale bias of the parallax mode.
  21985. */
  21986. protected _parallaxScaleBias: number;
  21987. /**
  21988. * If sets to true, disables all the lights affecting the material.
  21989. */
  21990. protected _disableLighting: boolean;
  21991. /**
  21992. * Number of Simultaneous lights allowed on the material.
  21993. */
  21994. protected _maxSimultaneousLights: number;
  21995. /**
  21996. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21997. */
  21998. protected _invertNormalMapX: boolean;
  21999. /**
  22000. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22001. */
  22002. protected _invertNormalMapY: boolean;
  22003. /**
  22004. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22005. */
  22006. protected _twoSidedLighting: boolean;
  22007. /**
  22008. * Defines the alpha limits in alpha test mode.
  22009. */
  22010. protected _alphaCutOff: number;
  22011. /**
  22012. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22013. */
  22014. protected _forceAlphaTest: boolean;
  22015. /**
  22016. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22017. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22018. */
  22019. protected _useAlphaFresnel: boolean;
  22020. /**
  22021. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22022. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22023. */
  22024. protected _useLinearAlphaFresnel: boolean;
  22025. /**
  22026. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22027. * from cos thetav and roughness:
  22028. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22029. */
  22030. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22031. /**
  22032. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22033. */
  22034. protected _forceIrradianceInFragment: boolean;
  22035. private _realTimeFiltering;
  22036. /**
  22037. * Enables realtime filtering on the texture.
  22038. */
  22039. get realTimeFiltering(): boolean;
  22040. set realTimeFiltering(b: boolean);
  22041. private _realTimeFilteringQuality;
  22042. /**
  22043. * Quality switch for realtime filtering
  22044. */
  22045. get realTimeFilteringQuality(): number;
  22046. set realTimeFilteringQuality(n: number);
  22047. /**
  22048. * Can this material render to several textures at once
  22049. */
  22050. get canRenderToMRT(): boolean;
  22051. /**
  22052. * Force normal to face away from face.
  22053. */
  22054. protected _forceNormalForward: boolean;
  22055. /**
  22056. * Enables specular anti aliasing in the PBR shader.
  22057. * It will both interacts on the Geometry for analytical and IBL lighting.
  22058. * It also prefilter the roughness map based on the bump values.
  22059. */
  22060. protected _enableSpecularAntiAliasing: boolean;
  22061. /**
  22062. * Default configuration related to image processing available in the PBR Material.
  22063. */
  22064. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22065. /**
  22066. * Keep track of the image processing observer to allow dispose and replace.
  22067. */
  22068. private _imageProcessingObserver;
  22069. /**
  22070. * Attaches a new image processing configuration to the PBR Material.
  22071. * @param configuration
  22072. */
  22073. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22074. /**
  22075. * Stores the available render targets.
  22076. */
  22077. private _renderTargets;
  22078. /**
  22079. * Sets the global ambient color for the material used in lighting calculations.
  22080. */
  22081. private _globalAmbientColor;
  22082. /**
  22083. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22084. */
  22085. private _useLogarithmicDepth;
  22086. /**
  22087. * If set to true, no lighting calculations will be applied.
  22088. */
  22089. private _unlit;
  22090. private _debugMode;
  22091. /**
  22092. * @hidden
  22093. * This is reserved for the inspector.
  22094. * Defines the material debug mode.
  22095. * It helps seeing only some components of the material while troubleshooting.
  22096. */
  22097. debugMode: number;
  22098. /**
  22099. * @hidden
  22100. * This is reserved for the inspector.
  22101. * Specify from where on screen the debug mode should start.
  22102. * The value goes from -1 (full screen) to 1 (not visible)
  22103. * It helps with side by side comparison against the final render
  22104. * This defaults to -1
  22105. */
  22106. private debugLimit;
  22107. /**
  22108. * @hidden
  22109. * This is reserved for the inspector.
  22110. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22111. * You can use the factor to better multiply the final value.
  22112. */
  22113. private debugFactor;
  22114. /**
  22115. * Defines the clear coat layer parameters for the material.
  22116. */
  22117. readonly clearCoat: PBRClearCoatConfiguration;
  22118. /**
  22119. * Defines the anisotropic parameters for the material.
  22120. */
  22121. readonly anisotropy: PBRAnisotropicConfiguration;
  22122. /**
  22123. * Defines the BRDF parameters for the material.
  22124. */
  22125. readonly brdf: PBRBRDFConfiguration;
  22126. /**
  22127. * Defines the Sheen parameters for the material.
  22128. */
  22129. readonly sheen: PBRSheenConfiguration;
  22130. /**
  22131. * Defines the SubSurface parameters for the material.
  22132. */
  22133. readonly subSurface: PBRSubSurfaceConfiguration;
  22134. /**
  22135. * Defines additionnal PrePass parameters for the material.
  22136. */
  22137. readonly prePassConfiguration: PrePassConfiguration;
  22138. /**
  22139. * Defines the detail map parameters for the material.
  22140. */
  22141. readonly detailMap: DetailMapConfiguration;
  22142. protected _rebuildInParallel: boolean;
  22143. /**
  22144. * Instantiates a new PBRMaterial instance.
  22145. *
  22146. * @param name The material name
  22147. * @param scene The scene the material will be use in.
  22148. */
  22149. constructor(name: string, scene: Scene);
  22150. /**
  22151. * Gets a boolean indicating that current material needs to register RTT
  22152. */
  22153. get hasRenderTargetTextures(): boolean;
  22154. /**
  22155. * Gets the name of the material class.
  22156. */
  22157. getClassName(): string;
  22158. /**
  22159. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22160. */
  22161. get useLogarithmicDepth(): boolean;
  22162. /**
  22163. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22164. */
  22165. set useLogarithmicDepth(value: boolean);
  22166. /**
  22167. * Returns true if alpha blending should be disabled.
  22168. */
  22169. protected get _disableAlphaBlending(): boolean;
  22170. /**
  22171. * Specifies whether or not this material should be rendered in alpha blend mode.
  22172. */
  22173. needAlphaBlending(): boolean;
  22174. /**
  22175. * Specifies whether or not this material should be rendered in alpha test mode.
  22176. */
  22177. needAlphaTesting(): boolean;
  22178. /**
  22179. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22180. */
  22181. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22182. /**
  22183. * Specifies whether or not there is a usable alpha channel for transparency.
  22184. */
  22185. protected _hasAlphaChannel(): boolean;
  22186. /**
  22187. * Gets the texture used for the alpha test.
  22188. */
  22189. getAlphaTestTexture(): Nullable<BaseTexture>;
  22190. /**
  22191. * Specifies that the submesh is ready to be used.
  22192. * @param mesh - BJS mesh.
  22193. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22194. * @param useInstances - Specifies that instances should be used.
  22195. * @returns - boolean indicating that the submesh is ready or not.
  22196. */
  22197. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22198. /**
  22199. * Specifies if the material uses metallic roughness workflow.
  22200. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22201. */
  22202. isMetallicWorkflow(): boolean;
  22203. private _prepareEffect;
  22204. private _prepareDefines;
  22205. /**
  22206. * Force shader compilation
  22207. */
  22208. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22209. /**
  22210. * Initializes the uniform buffer layout for the shader.
  22211. */
  22212. buildUniformLayout(): void;
  22213. /**
  22214. * Unbinds the material from the mesh
  22215. */
  22216. unbind(): void;
  22217. /**
  22218. * Binds the submesh data.
  22219. * @param world - The world matrix.
  22220. * @param mesh - The BJS mesh.
  22221. * @param subMesh - A submesh of the BJS mesh.
  22222. */
  22223. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22224. /**
  22225. * Returns the animatable textures.
  22226. * @returns - Array of animatable textures.
  22227. */
  22228. getAnimatables(): IAnimatable[];
  22229. /**
  22230. * Returns the texture used for reflections.
  22231. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22232. */
  22233. private _getReflectionTexture;
  22234. /**
  22235. * Returns an array of the actively used textures.
  22236. * @returns - Array of BaseTextures
  22237. */
  22238. getActiveTextures(): BaseTexture[];
  22239. /**
  22240. * Checks to see if a texture is used in the material.
  22241. * @param texture - Base texture to use.
  22242. * @returns - Boolean specifying if a texture is used in the material.
  22243. */
  22244. hasTexture(texture: BaseTexture): boolean;
  22245. /**
  22246. * Sets the required values to the prepass renderer.
  22247. * @param prePassRenderer defines the prepass renderer to setup
  22248. */
  22249. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22250. /**
  22251. * Disposes the resources of the material.
  22252. * @param forceDisposeEffect - Forces the disposal of effects.
  22253. * @param forceDisposeTextures - Forces the disposal of all textures.
  22254. */
  22255. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22256. }
  22257. }
  22258. declare module BABYLON {
  22259. /**
  22260. * The Physically based material of BJS.
  22261. *
  22262. * This offers the main features of a standard PBR material.
  22263. * For more information, please refer to the documentation :
  22264. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22265. */
  22266. export class PBRMaterial extends PBRBaseMaterial {
  22267. /**
  22268. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22269. */
  22270. static readonly PBRMATERIAL_OPAQUE: number;
  22271. /**
  22272. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22273. */
  22274. static readonly PBRMATERIAL_ALPHATEST: number;
  22275. /**
  22276. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22277. */
  22278. static readonly PBRMATERIAL_ALPHABLEND: number;
  22279. /**
  22280. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22281. * They are also discarded below the alpha cutoff threshold to improve performances.
  22282. */
  22283. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22284. /**
  22285. * Defines the default value of how much AO map is occluding the analytical lights
  22286. * (point spot...).
  22287. */
  22288. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22289. /**
  22290. * Intensity of the direct lights e.g. the four lights available in your scene.
  22291. * This impacts both the direct diffuse and specular highlights.
  22292. */
  22293. directIntensity: number;
  22294. /**
  22295. * Intensity of the emissive part of the material.
  22296. * This helps controlling the emissive effect without modifying the emissive color.
  22297. */
  22298. emissiveIntensity: number;
  22299. /**
  22300. * Intensity of the environment e.g. how much the environment will light the object
  22301. * either through harmonics for rough material or through the refelction for shiny ones.
  22302. */
  22303. environmentIntensity: number;
  22304. /**
  22305. * This is a special control allowing the reduction of the specular highlights coming from the
  22306. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22307. */
  22308. specularIntensity: number;
  22309. /**
  22310. * Debug Control allowing disabling the bump map on this material.
  22311. */
  22312. disableBumpMap: boolean;
  22313. /**
  22314. * AKA Diffuse Texture in standard nomenclature.
  22315. */
  22316. albedoTexture: BaseTexture;
  22317. /**
  22318. * AKA Occlusion Texture in other nomenclature.
  22319. */
  22320. ambientTexture: BaseTexture;
  22321. /**
  22322. * AKA Occlusion Texture Intensity in other nomenclature.
  22323. */
  22324. ambientTextureStrength: number;
  22325. /**
  22326. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22327. * 1 means it completely occludes it
  22328. * 0 mean it has no impact
  22329. */
  22330. ambientTextureImpactOnAnalyticalLights: number;
  22331. /**
  22332. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22333. */
  22334. opacityTexture: BaseTexture;
  22335. /**
  22336. * Stores the reflection values in a texture.
  22337. */
  22338. reflectionTexture: Nullable<BaseTexture>;
  22339. /**
  22340. * Stores the emissive values in a texture.
  22341. */
  22342. emissiveTexture: BaseTexture;
  22343. /**
  22344. * AKA Specular texture in other nomenclature.
  22345. */
  22346. reflectivityTexture: BaseTexture;
  22347. /**
  22348. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22349. */
  22350. metallicTexture: BaseTexture;
  22351. /**
  22352. * Specifies the metallic scalar of the metallic/roughness workflow.
  22353. * Can also be used to scale the metalness values of the metallic texture.
  22354. */
  22355. metallic: Nullable<number>;
  22356. /**
  22357. * Specifies the roughness scalar of the metallic/roughness workflow.
  22358. * Can also be used to scale the roughness values of the metallic texture.
  22359. */
  22360. roughness: Nullable<number>;
  22361. /**
  22362. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22363. * By default the indexOfrefraction is used to compute F0;
  22364. *
  22365. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22366. *
  22367. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22368. * F90 = metallicReflectanceColor;
  22369. */
  22370. metallicF0Factor: number;
  22371. /**
  22372. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22373. * By default the F90 is always 1;
  22374. *
  22375. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22376. *
  22377. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22378. * F90 = metallicReflectanceColor;
  22379. */
  22380. metallicReflectanceColor: Color3;
  22381. /**
  22382. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22383. * This is multiply against the scalar values defined in the material.
  22384. */
  22385. metallicReflectanceTexture: Nullable<BaseTexture>;
  22386. /**
  22387. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22388. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22389. */
  22390. microSurfaceTexture: BaseTexture;
  22391. /**
  22392. * Stores surface normal data used to displace a mesh in a texture.
  22393. */
  22394. bumpTexture: BaseTexture;
  22395. /**
  22396. * Stores the pre-calculated light information of a mesh in a texture.
  22397. */
  22398. lightmapTexture: BaseTexture;
  22399. /**
  22400. * Stores the refracted light information in a texture.
  22401. */
  22402. get refractionTexture(): Nullable<BaseTexture>;
  22403. set refractionTexture(value: Nullable<BaseTexture>);
  22404. /**
  22405. * The color of a material in ambient lighting.
  22406. */
  22407. ambientColor: Color3;
  22408. /**
  22409. * AKA Diffuse Color in other nomenclature.
  22410. */
  22411. albedoColor: Color3;
  22412. /**
  22413. * AKA Specular Color in other nomenclature.
  22414. */
  22415. reflectivityColor: Color3;
  22416. /**
  22417. * The color reflected from the material.
  22418. */
  22419. reflectionColor: Color3;
  22420. /**
  22421. * The color emitted from the material.
  22422. */
  22423. emissiveColor: Color3;
  22424. /**
  22425. * AKA Glossiness in other nomenclature.
  22426. */
  22427. microSurface: number;
  22428. /**
  22429. * Index of refraction of the material base layer.
  22430. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22431. *
  22432. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22433. *
  22434. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22435. */
  22436. get indexOfRefraction(): number;
  22437. set indexOfRefraction(value: number);
  22438. /**
  22439. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22440. */
  22441. get invertRefractionY(): boolean;
  22442. set invertRefractionY(value: boolean);
  22443. /**
  22444. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22445. * Materials half opaque for instance using refraction could benefit from this control.
  22446. */
  22447. get linkRefractionWithTransparency(): boolean;
  22448. set linkRefractionWithTransparency(value: boolean);
  22449. /**
  22450. * If true, the light map contains occlusion information instead of lighting info.
  22451. */
  22452. useLightmapAsShadowmap: boolean;
  22453. /**
  22454. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22455. */
  22456. useAlphaFromAlbedoTexture: boolean;
  22457. /**
  22458. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22459. */
  22460. forceAlphaTest: boolean;
  22461. /**
  22462. * Defines the alpha limits in alpha test mode.
  22463. */
  22464. alphaCutOff: number;
  22465. /**
  22466. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22467. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22468. */
  22469. useSpecularOverAlpha: boolean;
  22470. /**
  22471. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22472. */
  22473. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22474. /**
  22475. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22476. */
  22477. useRoughnessFromMetallicTextureAlpha: boolean;
  22478. /**
  22479. * Specifies if the metallic texture contains the roughness information in its green channel.
  22480. */
  22481. useRoughnessFromMetallicTextureGreen: boolean;
  22482. /**
  22483. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22484. */
  22485. useMetallnessFromMetallicTextureBlue: boolean;
  22486. /**
  22487. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22488. */
  22489. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22490. /**
  22491. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22492. */
  22493. useAmbientInGrayScale: boolean;
  22494. /**
  22495. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22496. * The material will try to infer what glossiness each pixel should be.
  22497. */
  22498. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22499. /**
  22500. * BJS is using an harcoded light falloff based on a manually sets up range.
  22501. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22502. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22503. */
  22504. get usePhysicalLightFalloff(): boolean;
  22505. /**
  22506. * BJS is using an harcoded light falloff based on a manually sets up range.
  22507. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22508. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22509. */
  22510. set usePhysicalLightFalloff(value: boolean);
  22511. /**
  22512. * In order to support the falloff compatibility with gltf, a special mode has been added
  22513. * to reproduce the gltf light falloff.
  22514. */
  22515. get useGLTFLightFalloff(): boolean;
  22516. /**
  22517. * In order to support the falloff compatibility with gltf, a special mode has been added
  22518. * to reproduce the gltf light falloff.
  22519. */
  22520. set useGLTFLightFalloff(value: boolean);
  22521. /**
  22522. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22523. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22524. */
  22525. useRadianceOverAlpha: boolean;
  22526. /**
  22527. * Allows using an object space normal map (instead of tangent space).
  22528. */
  22529. useObjectSpaceNormalMap: boolean;
  22530. /**
  22531. * Allows using the bump map in parallax mode.
  22532. */
  22533. useParallax: boolean;
  22534. /**
  22535. * Allows using the bump map in parallax occlusion mode.
  22536. */
  22537. useParallaxOcclusion: boolean;
  22538. /**
  22539. * Controls the scale bias of the parallax mode.
  22540. */
  22541. parallaxScaleBias: number;
  22542. /**
  22543. * If sets to true, disables all the lights affecting the material.
  22544. */
  22545. disableLighting: boolean;
  22546. /**
  22547. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22548. */
  22549. forceIrradianceInFragment: boolean;
  22550. /**
  22551. * Number of Simultaneous lights allowed on the material.
  22552. */
  22553. maxSimultaneousLights: number;
  22554. /**
  22555. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22556. */
  22557. invertNormalMapX: boolean;
  22558. /**
  22559. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22560. */
  22561. invertNormalMapY: boolean;
  22562. /**
  22563. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22564. */
  22565. twoSidedLighting: boolean;
  22566. /**
  22567. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22568. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22569. */
  22570. useAlphaFresnel: boolean;
  22571. /**
  22572. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22573. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22574. */
  22575. useLinearAlphaFresnel: boolean;
  22576. /**
  22577. * Let user defines the brdf lookup texture used for IBL.
  22578. * A default 8bit version is embedded but you could point at :
  22579. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22580. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22581. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22582. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22583. */
  22584. environmentBRDFTexture: Nullable<BaseTexture>;
  22585. /**
  22586. * Force normal to face away from face.
  22587. */
  22588. forceNormalForward: boolean;
  22589. /**
  22590. * Enables specular anti aliasing in the PBR shader.
  22591. * It will both interacts on the Geometry for analytical and IBL lighting.
  22592. * It also prefilter the roughness map based on the bump values.
  22593. */
  22594. enableSpecularAntiAliasing: boolean;
  22595. /**
  22596. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22597. * makes the reflect vector face the model (under horizon).
  22598. */
  22599. useHorizonOcclusion: boolean;
  22600. /**
  22601. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22602. * too much the area relying on ambient texture to define their ambient occlusion.
  22603. */
  22604. useRadianceOcclusion: boolean;
  22605. /**
  22606. * If set to true, no lighting calculations will be applied.
  22607. */
  22608. unlit: boolean;
  22609. /**
  22610. * Gets the image processing configuration used either in this material.
  22611. */
  22612. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22613. /**
  22614. * Sets the Default image processing configuration used either in the this material.
  22615. *
  22616. * If sets to null, the scene one is in use.
  22617. */
  22618. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22619. /**
  22620. * Gets wether the color curves effect is enabled.
  22621. */
  22622. get cameraColorCurvesEnabled(): boolean;
  22623. /**
  22624. * Sets wether the color curves effect is enabled.
  22625. */
  22626. set cameraColorCurvesEnabled(value: boolean);
  22627. /**
  22628. * Gets wether the color grading effect is enabled.
  22629. */
  22630. get cameraColorGradingEnabled(): boolean;
  22631. /**
  22632. * Gets wether the color grading effect is enabled.
  22633. */
  22634. set cameraColorGradingEnabled(value: boolean);
  22635. /**
  22636. * Gets wether tonemapping is enabled or not.
  22637. */
  22638. get cameraToneMappingEnabled(): boolean;
  22639. /**
  22640. * Sets wether tonemapping is enabled or not
  22641. */
  22642. set cameraToneMappingEnabled(value: boolean);
  22643. /**
  22644. * The camera exposure used on this material.
  22645. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22646. * This corresponds to a photographic exposure.
  22647. */
  22648. get cameraExposure(): number;
  22649. /**
  22650. * The camera exposure used on this material.
  22651. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22652. * This corresponds to a photographic exposure.
  22653. */
  22654. set cameraExposure(value: number);
  22655. /**
  22656. * Gets The camera contrast used on this material.
  22657. */
  22658. get cameraContrast(): number;
  22659. /**
  22660. * Sets The camera contrast used on this material.
  22661. */
  22662. set cameraContrast(value: number);
  22663. /**
  22664. * Gets the Color Grading 2D Lookup Texture.
  22665. */
  22666. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22667. /**
  22668. * Sets the Color Grading 2D Lookup Texture.
  22669. */
  22670. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22671. /**
  22672. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22673. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22674. * 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;
  22675. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22676. */
  22677. get cameraColorCurves(): Nullable<ColorCurves>;
  22678. /**
  22679. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22680. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22681. * 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;
  22682. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22683. */
  22684. set cameraColorCurves(value: Nullable<ColorCurves>);
  22685. /**
  22686. * Instantiates a new PBRMaterial instance.
  22687. *
  22688. * @param name The material name
  22689. * @param scene The scene the material will be use in.
  22690. */
  22691. constructor(name: string, scene: Scene);
  22692. /**
  22693. * Returns the name of this material class.
  22694. */
  22695. getClassName(): string;
  22696. /**
  22697. * Makes a duplicate of the current material.
  22698. * @param name - name to use for the new material.
  22699. */
  22700. clone(name: string): PBRMaterial;
  22701. /**
  22702. * Serializes this PBR Material.
  22703. * @returns - An object with the serialized material.
  22704. */
  22705. serialize(): any;
  22706. /**
  22707. * Parses a PBR Material from a serialized object.
  22708. * @param source - Serialized object.
  22709. * @param scene - BJS scene instance.
  22710. * @param rootUrl - url for the scene object
  22711. * @returns - PBRMaterial
  22712. */
  22713. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22714. }
  22715. }
  22716. declare module BABYLON {
  22717. /** @hidden */
  22718. export var mrtFragmentDeclaration: {
  22719. name: string;
  22720. shader: string;
  22721. };
  22722. }
  22723. declare module BABYLON {
  22724. /** @hidden */
  22725. export var geometryPixelShader: {
  22726. name: string;
  22727. shader: string;
  22728. };
  22729. }
  22730. declare module BABYLON {
  22731. /** @hidden */
  22732. export var instancesDeclaration: {
  22733. name: string;
  22734. shader: string;
  22735. };
  22736. }
  22737. declare module BABYLON {
  22738. /** @hidden */
  22739. export var geometryVertexShader: {
  22740. name: string;
  22741. shader: string;
  22742. };
  22743. }
  22744. declare module BABYLON {
  22745. /** @hidden */
  22746. interface ISavedTransformationMatrix {
  22747. world: Matrix;
  22748. viewProjection: Matrix;
  22749. }
  22750. /**
  22751. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22752. */
  22753. export class GeometryBufferRenderer {
  22754. /**
  22755. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22756. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22757. */
  22758. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22759. /**
  22760. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22761. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22762. */
  22763. static readonly POSITION_TEXTURE_TYPE: number;
  22764. /**
  22765. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22766. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22767. */
  22768. static readonly VELOCITY_TEXTURE_TYPE: number;
  22769. /**
  22770. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22771. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22772. */
  22773. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22774. /**
  22775. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22776. * in order to compute objects velocities when enableVelocity is set to "true"
  22777. * @hidden
  22778. */
  22779. _previousTransformationMatrices: {
  22780. [index: number]: ISavedTransformationMatrix;
  22781. };
  22782. /**
  22783. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22784. * in order to compute objects velocities when enableVelocity is set to "true"
  22785. * @hidden
  22786. */
  22787. _previousBonesTransformationMatrices: {
  22788. [index: number]: Float32Array;
  22789. };
  22790. /**
  22791. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22792. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22793. */
  22794. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22795. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22796. renderTransparentMeshes: boolean;
  22797. private _scene;
  22798. private _resizeObserver;
  22799. private _multiRenderTarget;
  22800. private _ratio;
  22801. private _enablePosition;
  22802. private _enableVelocity;
  22803. private _enableReflectivity;
  22804. private _positionIndex;
  22805. private _velocityIndex;
  22806. private _reflectivityIndex;
  22807. private _depthNormalIndex;
  22808. private _linkedWithPrePass;
  22809. private _prePassRenderer;
  22810. private _attachments;
  22811. protected _effect: Effect;
  22812. protected _cachedDefines: string;
  22813. /**
  22814. * @hidden
  22815. * Sets up internal structures to share outputs with PrePassRenderer
  22816. * This method should only be called by the PrePassRenderer itself
  22817. */
  22818. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22819. /**
  22820. * @hidden
  22821. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22822. * This method should only be called by the PrePassRenderer itself
  22823. */
  22824. _unlinkPrePassRenderer(): void;
  22825. /**
  22826. * @hidden
  22827. * Resets the geometry buffer layout
  22828. */
  22829. _resetLayout(): void;
  22830. /**
  22831. * @hidden
  22832. * Replaces a texture in the geometry buffer renderer
  22833. * Useful when linking textures of the prepass renderer
  22834. */
  22835. _forceTextureType(geometryBufferType: number, index: number): void;
  22836. /**
  22837. * @hidden
  22838. * Sets texture attachments
  22839. * Useful when linking textures of the prepass renderer
  22840. */
  22841. _setAttachments(attachments: number[]): void;
  22842. /**
  22843. * @hidden
  22844. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22845. * Useful when linking textures of the prepass renderer
  22846. */
  22847. _linkInternalTexture(internalTexture: InternalTexture): void;
  22848. /**
  22849. * Gets the render list (meshes to be rendered) used in the G buffer.
  22850. */
  22851. get renderList(): Nullable<AbstractMesh[]>;
  22852. /**
  22853. * Set the render list (meshes to be rendered) used in the G buffer.
  22854. */
  22855. set renderList(meshes: Nullable<AbstractMesh[]>);
  22856. /**
  22857. * Gets wether or not G buffer are supported by the running hardware.
  22858. * This requires draw buffer supports
  22859. */
  22860. get isSupported(): boolean;
  22861. /**
  22862. * Returns the index of the given texture type in the G-Buffer textures array
  22863. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22864. * @returns the index of the given texture type in the G-Buffer textures array
  22865. */
  22866. getTextureIndex(textureType: number): number;
  22867. /**
  22868. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22869. */
  22870. get enablePosition(): boolean;
  22871. /**
  22872. * Sets whether or not objects positions are enabled for the G buffer.
  22873. */
  22874. set enablePosition(enable: boolean);
  22875. /**
  22876. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22877. */
  22878. get enableVelocity(): boolean;
  22879. /**
  22880. * Sets wether or not objects velocities are enabled for the G buffer.
  22881. */
  22882. set enableVelocity(enable: boolean);
  22883. /**
  22884. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22885. */
  22886. get enableReflectivity(): boolean;
  22887. /**
  22888. * Sets wether or not objects roughness are enabled for the G buffer.
  22889. */
  22890. set enableReflectivity(enable: boolean);
  22891. /**
  22892. * Gets the scene associated with the buffer.
  22893. */
  22894. get scene(): Scene;
  22895. /**
  22896. * Gets the ratio used by the buffer during its creation.
  22897. * How big is the buffer related to the main canvas.
  22898. */
  22899. get ratio(): number;
  22900. /** @hidden */
  22901. static _SceneComponentInitialization: (scene: Scene) => void;
  22902. /**
  22903. * Creates a new G Buffer for the scene
  22904. * @param scene The scene the buffer belongs to
  22905. * @param ratio How big is the buffer related to the main canvas.
  22906. */
  22907. constructor(scene: Scene, ratio?: number);
  22908. /**
  22909. * Checks wether everything is ready to render a submesh to the G buffer.
  22910. * @param subMesh the submesh to check readiness for
  22911. * @param useInstances is the mesh drawn using instance or not
  22912. * @returns true if ready otherwise false
  22913. */
  22914. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22915. /**
  22916. * Gets the current underlying G Buffer.
  22917. * @returns the buffer
  22918. */
  22919. getGBuffer(): MultiRenderTarget;
  22920. /**
  22921. * Gets the number of samples used to render the buffer (anti aliasing).
  22922. */
  22923. get samples(): number;
  22924. /**
  22925. * Sets the number of samples used to render the buffer (anti aliasing).
  22926. */
  22927. set samples(value: number);
  22928. /**
  22929. * Disposes the renderer and frees up associated resources.
  22930. */
  22931. dispose(): void;
  22932. private _assignRenderTargetIndices;
  22933. protected _createRenderTargets(): void;
  22934. private _copyBonesTransformationMatrices;
  22935. }
  22936. }
  22937. declare module BABYLON {
  22938. /**
  22939. * Renders a pre pass of the scene
  22940. * This means every mesh in the scene will be rendered to a render target texture
  22941. * And then this texture will be composited to the rendering canvas with post processes
  22942. * It is necessary for effects like subsurface scattering or deferred shading
  22943. */
  22944. export class PrePassRenderer {
  22945. /** @hidden */
  22946. static _SceneComponentInitialization: (scene: Scene) => void;
  22947. private _textureFormats;
  22948. /**
  22949. * To save performance, we can excluded skinned meshes from the prepass
  22950. */
  22951. excludedSkinnedMesh: AbstractMesh[];
  22952. /**
  22953. * Force material to be excluded from the prepass
  22954. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22955. * and you don't want a material to show in the effect.
  22956. */
  22957. excludedMaterials: Material[];
  22958. private _textureIndices;
  22959. private _scene;
  22960. private _engine;
  22961. private _isDirty;
  22962. /**
  22963. * Number of textures in the multi render target texture where the scene is directly rendered
  22964. */
  22965. mrtCount: number;
  22966. /**
  22967. * The render target where the scene is directly rendered
  22968. */
  22969. prePassRT: MultiRenderTarget;
  22970. private _multiRenderAttachments;
  22971. private _defaultAttachments;
  22972. private _postProcesses;
  22973. private readonly _clearColor;
  22974. /**
  22975. * Image processing post process for composition
  22976. */
  22977. imageProcessingPostProcess: ImageProcessingPostProcess;
  22978. /**
  22979. * Configuration for prepass effects
  22980. */
  22981. private _effectConfigurations;
  22982. private _mrtFormats;
  22983. private _mrtLayout;
  22984. private _enabled;
  22985. /**
  22986. * Indicates if the prepass is enabled
  22987. */
  22988. get enabled(): boolean;
  22989. /**
  22990. * How many samples are used for MSAA of the scene render target
  22991. */
  22992. get samples(): number;
  22993. set samples(n: number);
  22994. private _geometryBuffer;
  22995. private _useGeometryBufferFallback;
  22996. /**
  22997. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22998. */
  22999. get useGeometryBufferFallback(): boolean;
  23000. set useGeometryBufferFallback(value: boolean);
  23001. /**
  23002. * Set to true to disable gamma transform in PrePass.
  23003. * Can be useful in case you already proceed to gamma transform on a material level
  23004. * and your post processes don't need to be in linear color space.
  23005. */
  23006. disableGammaTransform: boolean;
  23007. /**
  23008. * Instanciates a prepass renderer
  23009. * @param scene The scene
  23010. */
  23011. constructor(scene: Scene);
  23012. private _initializeAttachments;
  23013. private _createCompositionEffect;
  23014. /**
  23015. * Indicates if rendering a prepass is supported
  23016. */
  23017. get isSupported(): boolean;
  23018. /**
  23019. * Sets the proper output textures to draw in the engine.
  23020. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23021. * @param subMesh Submesh on which the effect is applied
  23022. */
  23023. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23024. /**
  23025. * Restores attachments for single texture draw.
  23026. */
  23027. restoreAttachments(): void;
  23028. /**
  23029. * @hidden
  23030. */
  23031. _beforeCameraDraw(): void;
  23032. /**
  23033. * @hidden
  23034. */
  23035. _afterCameraDraw(): void;
  23036. private _checkRTSize;
  23037. private _bindFrameBuffer;
  23038. /**
  23039. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23040. */
  23041. clear(): void;
  23042. private _setState;
  23043. private _updateGeometryBufferLayout;
  23044. /**
  23045. * Adds an effect configuration to the prepass.
  23046. * If an effect has already been added, it won't add it twice and will return the configuration
  23047. * already present.
  23048. * @param cfg the effect configuration
  23049. * @return the effect configuration now used by the prepass
  23050. */
  23051. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23052. /**
  23053. * Returns the index of a texture in the multi render target texture array.
  23054. * @param type Texture type
  23055. * @return The index
  23056. */
  23057. getIndex(type: number): number;
  23058. private _enable;
  23059. private _disable;
  23060. private _resetLayout;
  23061. private _resetPostProcessChain;
  23062. private _bindPostProcessChain;
  23063. /**
  23064. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23065. */
  23066. markAsDirty(): void;
  23067. /**
  23068. * Enables a texture on the MultiRenderTarget for prepass
  23069. */
  23070. private _enableTextures;
  23071. private _update;
  23072. private _markAllMaterialsAsPrePassDirty;
  23073. /**
  23074. * Disposes the prepass renderer.
  23075. */
  23076. dispose(): void;
  23077. }
  23078. }
  23079. declare module BABYLON {
  23080. /**
  23081. * Size options for a post process
  23082. */
  23083. export type PostProcessOptions = {
  23084. width: number;
  23085. height: number;
  23086. };
  23087. /**
  23088. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23089. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23090. */
  23091. export class PostProcess {
  23092. /**
  23093. * Gets or sets the unique id of the post process
  23094. */
  23095. uniqueId: number;
  23096. /** Name of the PostProcess. */
  23097. name: string;
  23098. /**
  23099. * Width of the texture to apply the post process on
  23100. */
  23101. width: number;
  23102. /**
  23103. * Height of the texture to apply the post process on
  23104. */
  23105. height: number;
  23106. /**
  23107. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23108. */
  23109. nodeMaterialSource: Nullable<NodeMaterial>;
  23110. /**
  23111. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23112. * @hidden
  23113. */
  23114. _outputTexture: Nullable<InternalTexture>;
  23115. /**
  23116. * Sampling mode used by the shader
  23117. * See https://doc.babylonjs.com/classes/3.1/texture
  23118. */
  23119. renderTargetSamplingMode: number;
  23120. /**
  23121. * Clear color to use when screen clearing
  23122. */
  23123. clearColor: Color4;
  23124. /**
  23125. * If the buffer needs to be cleared before applying the post process. (default: true)
  23126. * Should be set to false if shader will overwrite all previous pixels.
  23127. */
  23128. autoClear: boolean;
  23129. /**
  23130. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23131. */
  23132. alphaMode: number;
  23133. /**
  23134. * Sets the setAlphaBlendConstants of the babylon engine
  23135. */
  23136. alphaConstants: Color4;
  23137. /**
  23138. * Animations to be used for the post processing
  23139. */
  23140. animations: Animation[];
  23141. /**
  23142. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23143. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23144. */
  23145. enablePixelPerfectMode: boolean;
  23146. /**
  23147. * Force the postprocess to be applied without taking in account viewport
  23148. */
  23149. forceFullscreenViewport: boolean;
  23150. /**
  23151. * List of inspectable custom properties (used by the Inspector)
  23152. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23153. */
  23154. inspectableCustomProperties: IInspectable[];
  23155. /**
  23156. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23157. *
  23158. * | Value | Type | Description |
  23159. * | ----- | ----------------------------------- | ----------- |
  23160. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23161. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23162. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23163. *
  23164. */
  23165. scaleMode: number;
  23166. /**
  23167. * Force textures to be a power of two (default: false)
  23168. */
  23169. alwaysForcePOT: boolean;
  23170. private _samples;
  23171. /**
  23172. * Number of sample textures (default: 1)
  23173. */
  23174. get samples(): number;
  23175. set samples(n: number);
  23176. /**
  23177. * Modify the scale of the post process to be the same as the viewport (default: false)
  23178. */
  23179. adaptScaleToCurrentViewport: boolean;
  23180. private _camera;
  23181. protected _scene: Scene;
  23182. private _engine;
  23183. private _options;
  23184. private _reusable;
  23185. private _textureType;
  23186. private _textureFormat;
  23187. /**
  23188. * Smart array of input and output textures for the post process.
  23189. * @hidden
  23190. */
  23191. _textures: SmartArray<InternalTexture>;
  23192. /**
  23193. * The index in _textures that corresponds to the output texture.
  23194. * @hidden
  23195. */
  23196. _currentRenderTextureInd: number;
  23197. private _effect;
  23198. private _samplers;
  23199. private _fragmentUrl;
  23200. private _vertexUrl;
  23201. private _parameters;
  23202. private _scaleRatio;
  23203. protected _indexParameters: any;
  23204. private _shareOutputWithPostProcess;
  23205. private _texelSize;
  23206. private _forcedOutputTexture;
  23207. /**
  23208. * Prepass configuration in case this post process needs a texture from prepass
  23209. * @hidden
  23210. */
  23211. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23212. /**
  23213. * Returns the fragment url or shader name used in the post process.
  23214. * @returns the fragment url or name in the shader store.
  23215. */
  23216. getEffectName(): string;
  23217. /**
  23218. * An event triggered when the postprocess is activated.
  23219. */
  23220. onActivateObservable: Observable<Camera>;
  23221. private _onActivateObserver;
  23222. /**
  23223. * A function that is added to the onActivateObservable
  23224. */
  23225. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23226. /**
  23227. * An event triggered when the postprocess changes its size.
  23228. */
  23229. onSizeChangedObservable: Observable<PostProcess>;
  23230. private _onSizeChangedObserver;
  23231. /**
  23232. * A function that is added to the onSizeChangedObservable
  23233. */
  23234. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23235. /**
  23236. * An event triggered when the postprocess applies its effect.
  23237. */
  23238. onApplyObservable: Observable<Effect>;
  23239. private _onApplyObserver;
  23240. /**
  23241. * A function that is added to the onApplyObservable
  23242. */
  23243. set onApply(callback: (effect: Effect) => void);
  23244. /**
  23245. * An event triggered before rendering the postprocess
  23246. */
  23247. onBeforeRenderObservable: Observable<Effect>;
  23248. private _onBeforeRenderObserver;
  23249. /**
  23250. * A function that is added to the onBeforeRenderObservable
  23251. */
  23252. set onBeforeRender(callback: (effect: Effect) => void);
  23253. /**
  23254. * An event triggered after rendering the postprocess
  23255. */
  23256. onAfterRenderObservable: Observable<Effect>;
  23257. private _onAfterRenderObserver;
  23258. /**
  23259. * A function that is added to the onAfterRenderObservable
  23260. */
  23261. set onAfterRender(callback: (efect: Effect) => void);
  23262. /**
  23263. * 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
  23264. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23265. */
  23266. get inputTexture(): InternalTexture;
  23267. set inputTexture(value: InternalTexture);
  23268. /**
  23269. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23270. * the only way to unset it is to use this function to restore its internal state
  23271. */
  23272. restoreDefaultInputTexture(): void;
  23273. /**
  23274. * Gets the camera which post process is applied to.
  23275. * @returns The camera the post process is applied to.
  23276. */
  23277. getCamera(): Camera;
  23278. /**
  23279. * Gets the texel size of the postprocess.
  23280. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23281. */
  23282. get texelSize(): Vector2;
  23283. /**
  23284. * Creates a new instance PostProcess
  23285. * @param name The name of the PostProcess.
  23286. * @param fragmentUrl The url of the fragment shader to be used.
  23287. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23288. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23289. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23290. * @param camera The camera to apply the render pass to.
  23291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23292. * @param engine The engine which the post process will be applied. (default: current engine)
  23293. * @param reusable If the post process can be reused on the same frame. (default: false)
  23294. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23295. * @param textureType Type of textures used when performing the post process. (default: 0)
  23296. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23297. * @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
  23298. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23299. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23300. */
  23301. 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);
  23302. /**
  23303. * Gets a string identifying the name of the class
  23304. * @returns "PostProcess" string
  23305. */
  23306. getClassName(): string;
  23307. /**
  23308. * Gets the engine which this post process belongs to.
  23309. * @returns The engine the post process was enabled with.
  23310. */
  23311. getEngine(): Engine;
  23312. /**
  23313. * The effect that is created when initializing the post process.
  23314. * @returns The created effect corresponding the the postprocess.
  23315. */
  23316. getEffect(): Effect;
  23317. /**
  23318. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23319. * @param postProcess The post process to share the output with.
  23320. * @returns This post process.
  23321. */
  23322. shareOutputWith(postProcess: PostProcess): PostProcess;
  23323. /**
  23324. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23325. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23326. */
  23327. useOwnOutput(): void;
  23328. /**
  23329. * Updates the effect with the current post process compile time values and recompiles the shader.
  23330. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23331. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23332. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23333. * @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
  23334. * @param onCompiled Called when the shader has been compiled.
  23335. * @param onError Called if there is an error when compiling a shader.
  23336. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23337. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23338. */
  23339. 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;
  23340. /**
  23341. * The post process is reusable if it can be used multiple times within one frame.
  23342. * @returns If the post process is reusable
  23343. */
  23344. isReusable(): boolean;
  23345. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23346. markTextureDirty(): void;
  23347. /**
  23348. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23349. * 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.
  23350. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23351. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23352. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23353. * @returns The target texture that was bound to be written to.
  23354. */
  23355. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23356. /**
  23357. * If the post process is supported.
  23358. */
  23359. get isSupported(): boolean;
  23360. /**
  23361. * The aspect ratio of the output texture.
  23362. */
  23363. get aspectRatio(): number;
  23364. /**
  23365. * Get a value indicating if the post-process is ready to be used
  23366. * @returns true if the post-process is ready (shader is compiled)
  23367. */
  23368. isReady(): boolean;
  23369. /**
  23370. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23371. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23372. */
  23373. apply(): Nullable<Effect>;
  23374. private _disposeTextures;
  23375. /**
  23376. * Sets the required values to the prepass renderer.
  23377. * @param prePassRenderer defines the prepass renderer to setup.
  23378. * @returns true if the pre pass is needed.
  23379. */
  23380. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23381. /**
  23382. * Disposes the post process.
  23383. * @param camera The camera to dispose the post process on.
  23384. */
  23385. dispose(camera?: Camera): void;
  23386. /**
  23387. * Serializes the particle system to a JSON object
  23388. * @returns the JSON object
  23389. */
  23390. serialize(): any;
  23391. /**
  23392. * Creates a material from parsed material data
  23393. * @param parsedPostProcess defines parsed post process data
  23394. * @param scene defines the hosting scene
  23395. * @param rootUrl defines the root URL to use to load textures
  23396. * @returns a new post process
  23397. */
  23398. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23399. }
  23400. }
  23401. declare module BABYLON {
  23402. /** @hidden */
  23403. export var kernelBlurVaryingDeclaration: {
  23404. name: string;
  23405. shader: string;
  23406. };
  23407. }
  23408. declare module BABYLON {
  23409. /** @hidden */
  23410. export var packingFunctions: {
  23411. name: string;
  23412. shader: string;
  23413. };
  23414. }
  23415. declare module BABYLON {
  23416. /** @hidden */
  23417. export var kernelBlurFragment: {
  23418. name: string;
  23419. shader: string;
  23420. };
  23421. }
  23422. declare module BABYLON {
  23423. /** @hidden */
  23424. export var kernelBlurFragment2: {
  23425. name: string;
  23426. shader: string;
  23427. };
  23428. }
  23429. declare module BABYLON {
  23430. /** @hidden */
  23431. export var kernelBlurPixelShader: {
  23432. name: string;
  23433. shader: string;
  23434. };
  23435. }
  23436. declare module BABYLON {
  23437. /** @hidden */
  23438. export var kernelBlurVertex: {
  23439. name: string;
  23440. shader: string;
  23441. };
  23442. }
  23443. declare module BABYLON {
  23444. /** @hidden */
  23445. export var kernelBlurVertexShader: {
  23446. name: string;
  23447. shader: string;
  23448. };
  23449. }
  23450. declare module BABYLON {
  23451. /**
  23452. * The Blur Post Process which blurs an image based on a kernel and direction.
  23453. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23454. */
  23455. export class BlurPostProcess extends PostProcess {
  23456. private blockCompilation;
  23457. protected _kernel: number;
  23458. protected _idealKernel: number;
  23459. protected _packedFloat: boolean;
  23460. private _staticDefines;
  23461. /** The direction in which to blur the image. */
  23462. direction: Vector2;
  23463. /**
  23464. * Sets the length in pixels of the blur sample region
  23465. */
  23466. set kernel(v: number);
  23467. /**
  23468. * Gets the length in pixels of the blur sample region
  23469. */
  23470. get kernel(): number;
  23471. /**
  23472. * Sets wether or not the blur needs to unpack/repack floats
  23473. */
  23474. set packedFloat(v: boolean);
  23475. /**
  23476. * Gets wether or not the blur is unpacking/repacking floats
  23477. */
  23478. get packedFloat(): boolean;
  23479. /**
  23480. * Gets a string identifying the name of the class
  23481. * @returns "BlurPostProcess" string
  23482. */
  23483. getClassName(): string;
  23484. /**
  23485. * Creates a new instance BlurPostProcess
  23486. * @param name The name of the effect.
  23487. * @param direction The direction in which to blur the image.
  23488. * @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.
  23489. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23490. * @param camera The camera to apply the render pass to.
  23491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23492. * @param engine The engine which the post process will be applied. (default: current engine)
  23493. * @param reusable If the post process can be reused on the same frame. (default: false)
  23494. * @param textureType Type of textures used when performing the post process. (default: 0)
  23495. * @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)
  23496. */
  23497. 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);
  23498. /**
  23499. * Updates the effect with the current post process compile time values and recompiles the shader.
  23500. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23501. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23502. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23503. * @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
  23504. * @param onCompiled Called when the shader has been compiled.
  23505. * @param onError Called if there is an error when compiling a shader.
  23506. */
  23507. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23508. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23509. /**
  23510. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23511. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23512. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23513. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23514. * The gaps between physical kernels are compensated for in the weighting of the samples
  23515. * @param idealKernel Ideal blur kernel.
  23516. * @return Nearest best kernel.
  23517. */
  23518. protected _nearestBestKernel(idealKernel: number): number;
  23519. /**
  23520. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23521. * @param x The point on the Gaussian distribution to sample.
  23522. * @return the value of the Gaussian function at x.
  23523. */
  23524. protected _gaussianWeight(x: number): number;
  23525. /**
  23526. * Generates a string that can be used as a floating point number in GLSL.
  23527. * @param x Value to print.
  23528. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23529. * @return GLSL float string.
  23530. */
  23531. protected _glslFloat(x: number, decimalFigures?: number): string;
  23532. /** @hidden */
  23533. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23534. }
  23535. }
  23536. declare module BABYLON {
  23537. /**
  23538. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23539. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23540. * You can then easily use it as a reflectionTexture on a flat surface.
  23541. * In case the surface is not a plane, please consider relying on reflection probes.
  23542. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23543. */
  23544. export class MirrorTexture extends RenderTargetTexture {
  23545. private scene;
  23546. /**
  23547. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23548. * 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.
  23549. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23550. */
  23551. mirrorPlane: Plane;
  23552. /**
  23553. * Define the blur ratio used to blur the reflection if needed.
  23554. */
  23555. set blurRatio(value: number);
  23556. get blurRatio(): number;
  23557. /**
  23558. * Define the adaptive blur kernel used to blur the reflection if needed.
  23559. * This will autocompute the closest best match for the `blurKernel`
  23560. */
  23561. set adaptiveBlurKernel(value: number);
  23562. /**
  23563. * Define the blur kernel used to blur the reflection if needed.
  23564. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23565. */
  23566. set blurKernel(value: number);
  23567. /**
  23568. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23569. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23570. */
  23571. set blurKernelX(value: number);
  23572. get blurKernelX(): number;
  23573. /**
  23574. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23575. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23576. */
  23577. set blurKernelY(value: number);
  23578. get blurKernelY(): number;
  23579. private _autoComputeBlurKernel;
  23580. protected _onRatioRescale(): void;
  23581. private _updateGammaSpace;
  23582. private _imageProcessingConfigChangeObserver;
  23583. private _transformMatrix;
  23584. private _mirrorMatrix;
  23585. private _savedViewMatrix;
  23586. private _blurX;
  23587. private _blurY;
  23588. private _adaptiveBlurKernel;
  23589. private _blurKernelX;
  23590. private _blurKernelY;
  23591. private _blurRatio;
  23592. /**
  23593. * Instantiates a Mirror Texture.
  23594. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23595. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23596. * You can then easily use it as a reflectionTexture on a flat surface.
  23597. * In case the surface is not a plane, please consider relying on reflection probes.
  23598. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23599. * @param name
  23600. * @param size
  23601. * @param scene
  23602. * @param generateMipMaps
  23603. * @param type
  23604. * @param samplingMode
  23605. * @param generateDepthBuffer
  23606. */
  23607. constructor(name: string, size: number | {
  23608. width: number;
  23609. height: number;
  23610. } | {
  23611. ratio: number;
  23612. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23613. private _preparePostProcesses;
  23614. /**
  23615. * Clone the mirror texture.
  23616. * @returns the cloned texture
  23617. */
  23618. clone(): MirrorTexture;
  23619. /**
  23620. * Serialize the texture to a JSON representation you could use in Parse later on
  23621. * @returns the serialized JSON representation
  23622. */
  23623. serialize(): any;
  23624. /**
  23625. * Dispose the texture and release its associated resources.
  23626. */
  23627. dispose(): void;
  23628. }
  23629. }
  23630. declare module BABYLON {
  23631. /**
  23632. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23633. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23634. */
  23635. export class Texture extends BaseTexture {
  23636. /**
  23637. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23638. */
  23639. static SerializeBuffers: boolean;
  23640. /**
  23641. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23642. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23643. */
  23644. static ForceSerializeBuffers: boolean;
  23645. /** @hidden */
  23646. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23647. /** @hidden */
  23648. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23649. /** @hidden */
  23650. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23651. /** nearest is mag = nearest and min = nearest and mip = linear */
  23652. static readonly NEAREST_SAMPLINGMODE: number;
  23653. /** nearest is mag = nearest and min = nearest and mip = linear */
  23654. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23655. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23656. static readonly BILINEAR_SAMPLINGMODE: number;
  23657. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23658. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23659. /** Trilinear is mag = linear and min = linear and mip = linear */
  23660. static readonly TRILINEAR_SAMPLINGMODE: number;
  23661. /** Trilinear is mag = linear and min = linear and mip = linear */
  23662. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23663. /** mag = nearest and min = nearest and mip = nearest */
  23664. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23665. /** mag = nearest and min = linear and mip = nearest */
  23666. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23667. /** mag = nearest and min = linear and mip = linear */
  23668. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23669. /** mag = nearest and min = linear and mip = none */
  23670. static readonly NEAREST_LINEAR: number;
  23671. /** mag = nearest and min = nearest and mip = none */
  23672. static readonly NEAREST_NEAREST: number;
  23673. /** mag = linear and min = nearest and mip = nearest */
  23674. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23675. /** mag = linear and min = nearest and mip = linear */
  23676. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23677. /** mag = linear and min = linear and mip = none */
  23678. static readonly LINEAR_LINEAR: number;
  23679. /** mag = linear and min = nearest and mip = none */
  23680. static readonly LINEAR_NEAREST: number;
  23681. /** Explicit coordinates mode */
  23682. static readonly EXPLICIT_MODE: number;
  23683. /** Spherical coordinates mode */
  23684. static readonly SPHERICAL_MODE: number;
  23685. /** Planar coordinates mode */
  23686. static readonly PLANAR_MODE: number;
  23687. /** Cubic coordinates mode */
  23688. static readonly CUBIC_MODE: number;
  23689. /** Projection coordinates mode */
  23690. static readonly PROJECTION_MODE: number;
  23691. /** Inverse Cubic coordinates mode */
  23692. static readonly SKYBOX_MODE: number;
  23693. /** Inverse Cubic coordinates mode */
  23694. static readonly INVCUBIC_MODE: number;
  23695. /** Equirectangular coordinates mode */
  23696. static readonly EQUIRECTANGULAR_MODE: number;
  23697. /** Equirectangular Fixed coordinates mode */
  23698. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23699. /** Equirectangular Fixed Mirrored coordinates mode */
  23700. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23701. /** Texture is not repeating outside of 0..1 UVs */
  23702. static readonly CLAMP_ADDRESSMODE: number;
  23703. /** Texture is repeating outside of 0..1 UVs */
  23704. static readonly WRAP_ADDRESSMODE: number;
  23705. /** Texture is repeating and mirrored */
  23706. static readonly MIRROR_ADDRESSMODE: number;
  23707. /**
  23708. * 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
  23709. */
  23710. static UseSerializedUrlIfAny: boolean;
  23711. /**
  23712. * Define the url of the texture.
  23713. */
  23714. url: Nullable<string>;
  23715. /**
  23716. * Define an offset on the texture to offset the u coordinates of the UVs
  23717. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23718. */
  23719. uOffset: number;
  23720. /**
  23721. * Define an offset on the texture to offset the v coordinates of the UVs
  23722. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23723. */
  23724. vOffset: number;
  23725. /**
  23726. * Define an offset on the texture to scale the u coordinates of the UVs
  23727. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23728. */
  23729. uScale: number;
  23730. /**
  23731. * Define an offset on the texture to scale the v coordinates of the UVs
  23732. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23733. */
  23734. vScale: number;
  23735. /**
  23736. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23737. * @see https://doc.babylonjs.com/how_to/more_materials
  23738. */
  23739. uAng: number;
  23740. /**
  23741. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23742. * @see https://doc.babylonjs.com/how_to/more_materials
  23743. */
  23744. vAng: number;
  23745. /**
  23746. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23747. * @see https://doc.babylonjs.com/how_to/more_materials
  23748. */
  23749. wAng: number;
  23750. /**
  23751. * Defines the center of rotation (U)
  23752. */
  23753. uRotationCenter: number;
  23754. /**
  23755. * Defines the center of rotation (V)
  23756. */
  23757. vRotationCenter: number;
  23758. /**
  23759. * Defines the center of rotation (W)
  23760. */
  23761. wRotationCenter: number;
  23762. /**
  23763. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23764. */
  23765. homogeneousRotationInUVTransform: boolean;
  23766. /**
  23767. * Are mip maps generated for this texture or not.
  23768. */
  23769. get noMipmap(): boolean;
  23770. /**
  23771. * List of inspectable custom properties (used by the Inspector)
  23772. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23773. */
  23774. inspectableCustomProperties: Nullable<IInspectable[]>;
  23775. private _noMipmap;
  23776. /** @hidden */
  23777. _invertY: boolean;
  23778. private _rowGenerationMatrix;
  23779. private _cachedTextureMatrix;
  23780. private _projectionModeMatrix;
  23781. private _t0;
  23782. private _t1;
  23783. private _t2;
  23784. private _cachedUOffset;
  23785. private _cachedVOffset;
  23786. private _cachedUScale;
  23787. private _cachedVScale;
  23788. private _cachedUAng;
  23789. private _cachedVAng;
  23790. private _cachedWAng;
  23791. private _cachedProjectionMatrixId;
  23792. private _cachedURotationCenter;
  23793. private _cachedVRotationCenter;
  23794. private _cachedWRotationCenter;
  23795. private _cachedHomogeneousRotationInUVTransform;
  23796. private _cachedCoordinatesMode;
  23797. /** @hidden */
  23798. protected _initialSamplingMode: number;
  23799. /** @hidden */
  23800. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23801. private _deleteBuffer;
  23802. protected _format: Nullable<number>;
  23803. private _delayedOnLoad;
  23804. private _delayedOnError;
  23805. private _mimeType?;
  23806. private _loaderOptions?;
  23807. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23808. get mimeType(): string | undefined;
  23809. /**
  23810. * Observable triggered once the texture has been loaded.
  23811. */
  23812. onLoadObservable: Observable<Texture>;
  23813. protected _isBlocking: boolean;
  23814. /**
  23815. * Is the texture preventing material to render while loading.
  23816. * If false, a default texture will be used instead of the loading one during the preparation step.
  23817. */
  23818. set isBlocking(value: boolean);
  23819. get isBlocking(): boolean;
  23820. /**
  23821. * Get the current sampling mode associated with the texture.
  23822. */
  23823. get samplingMode(): number;
  23824. /**
  23825. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23826. */
  23827. get invertY(): boolean;
  23828. /**
  23829. * Instantiates a new texture.
  23830. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23831. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23832. * @param url defines the url of the picture to load as a texture
  23833. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23834. * @param noMipmap defines if the texture will require mip maps or not
  23835. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23836. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23837. * @param onLoad defines a callback triggered when the texture has been loaded
  23838. * @param onError defines a callback triggered when an error occurred during the loading session
  23839. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23840. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23841. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23842. * @param mimeType defines an optional mime type information
  23843. * @param loaderOptions options to be passed to the loader
  23844. */
  23845. 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);
  23846. /**
  23847. * Update the url (and optional buffer) of this texture if url was null during construction.
  23848. * @param url the url of the texture
  23849. * @param buffer the buffer of the texture (defaults to null)
  23850. * @param onLoad callback called when the texture is loaded (defaults to null)
  23851. */
  23852. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23853. /**
  23854. * Finish the loading sequence of a texture flagged as delayed load.
  23855. * @hidden
  23856. */
  23857. delayLoad(): void;
  23858. private _prepareRowForTextureGeneration;
  23859. /**
  23860. * Checks if the texture has the same transform matrix than another texture
  23861. * @param texture texture to check against
  23862. * @returns true if the transforms are the same, else false
  23863. */
  23864. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23865. /**
  23866. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23867. * @returns the transform matrix of the texture.
  23868. */
  23869. getTextureMatrix(uBase?: number): Matrix;
  23870. /**
  23871. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23872. * @returns The reflection texture transform
  23873. */
  23874. getReflectionTextureMatrix(): Matrix;
  23875. /**
  23876. * Clones the texture.
  23877. * @returns the cloned texture
  23878. */
  23879. clone(): Texture;
  23880. /**
  23881. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23882. * @returns The JSON representation of the texture
  23883. */
  23884. serialize(): any;
  23885. /**
  23886. * Get the current class name of the texture useful for serialization or dynamic coding.
  23887. * @returns "Texture"
  23888. */
  23889. getClassName(): string;
  23890. /**
  23891. * Dispose the texture and release its associated resources.
  23892. */
  23893. dispose(): void;
  23894. /**
  23895. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23896. * @param parsedTexture Define the JSON representation of the texture
  23897. * @param scene Define the scene the parsed texture should be instantiated in
  23898. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23899. * @returns The parsed texture if successful
  23900. */
  23901. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23902. /**
  23903. * Creates a texture from its base 64 representation.
  23904. * @param data Define the base64 payload without the data: prefix
  23905. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23906. * @param scene Define the scene the texture should belong to
  23907. * @param noMipmap Forces the texture to not create mip map information if true
  23908. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23909. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23910. * @param onLoad define a callback triggered when the texture has been loaded
  23911. * @param onError define a callback triggered when an error occurred during the loading session
  23912. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23913. * @returns the created texture
  23914. */
  23915. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23916. /**
  23917. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23918. * @param data Define the base64 payload without the data: prefix
  23919. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23920. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23921. * @param scene Define the scene the texture should belong to
  23922. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23923. * @param noMipmap Forces the texture to not create mip map information if true
  23924. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23925. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23926. * @param onLoad define a callback triggered when the texture has been loaded
  23927. * @param onError define a callback triggered when an error occurred during the loading session
  23928. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23929. * @returns the created texture
  23930. */
  23931. 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;
  23932. }
  23933. }
  23934. declare module BABYLON {
  23935. /**
  23936. * ThinSprite Class used to represent a thin sprite
  23937. * This is the base class for sprites but can also directly be used with ThinEngine
  23938. * @see https://doc.babylonjs.com/babylon101/sprites
  23939. */
  23940. export class ThinSprite {
  23941. /** Gets or sets the cell index in the sprite sheet */
  23942. cellIndex: number;
  23943. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23944. cellRef: string;
  23945. /** Gets or sets the current world position */
  23946. position: IVector3Like;
  23947. /** Gets or sets the main color */
  23948. color: IColor4Like;
  23949. /** Gets or sets the width */
  23950. width: number;
  23951. /** Gets or sets the height */
  23952. height: number;
  23953. /** Gets or sets rotation angle */
  23954. angle: number;
  23955. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23956. invertU: boolean;
  23957. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23958. invertV: boolean;
  23959. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23960. isVisible: boolean;
  23961. /**
  23962. * Returns a boolean indicating if the animation is started
  23963. */
  23964. get animationStarted(): boolean;
  23965. /** Gets the initial key for the animation (setting it will restart the animation) */
  23966. get fromIndex(): number;
  23967. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23968. get toIndex(): number;
  23969. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23970. get loopAnimation(): boolean;
  23971. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23972. get delay(): number;
  23973. /** @hidden */
  23974. _xOffset: number;
  23975. /** @hidden */
  23976. _yOffset: number;
  23977. /** @hidden */
  23978. _xSize: number;
  23979. /** @hidden */
  23980. _ySize: number;
  23981. private _animationStarted;
  23982. protected _loopAnimation: boolean;
  23983. protected _fromIndex: number;
  23984. protected _toIndex: number;
  23985. protected _delay: number;
  23986. private _direction;
  23987. private _time;
  23988. private _onBaseAnimationEnd;
  23989. /**
  23990. * Creates a new Thin Sprite
  23991. */
  23992. constructor();
  23993. /**
  23994. * Starts an animation
  23995. * @param from defines the initial key
  23996. * @param to defines the end key
  23997. * @param loop defines if the animation must loop
  23998. * @param delay defines the start delay (in ms)
  23999. * @param onAnimationEnd defines a callback for when the animation ends
  24000. */
  24001. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24002. /** Stops current animation (if any) */
  24003. stopAnimation(): void;
  24004. /** @hidden */
  24005. _animate(deltaTime: number): void;
  24006. }
  24007. }
  24008. declare module BABYLON {
  24009. /** @hidden */
  24010. export var imageProcessingCompatibility: {
  24011. name: string;
  24012. shader: string;
  24013. };
  24014. }
  24015. declare module BABYLON {
  24016. /** @hidden */
  24017. export var spritesPixelShader: {
  24018. name: string;
  24019. shader: string;
  24020. };
  24021. }
  24022. declare module BABYLON {
  24023. /** @hidden */
  24024. export var spritesVertexShader: {
  24025. name: string;
  24026. shader: string;
  24027. };
  24028. }
  24029. declare module BABYLON {
  24030. /**
  24031. * Class used to render sprites.
  24032. *
  24033. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24034. */
  24035. export class SpriteRenderer {
  24036. /**
  24037. * Defines the texture of the spritesheet
  24038. */
  24039. texture: Nullable<ThinTexture>;
  24040. /**
  24041. * Defines the default width of a cell in the spritesheet
  24042. */
  24043. cellWidth: number;
  24044. /**
  24045. * Defines the default height of a cell in the spritesheet
  24046. */
  24047. cellHeight: number;
  24048. /**
  24049. * Blend mode use to render the particle, it can be any of
  24050. * the static Constants.ALPHA_x properties provided in this class.
  24051. * Default value is Constants.ALPHA_COMBINE
  24052. */
  24053. blendMode: number;
  24054. /**
  24055. * Gets or sets a boolean indicating if alpha mode is automatically
  24056. * reset.
  24057. */
  24058. autoResetAlpha: boolean;
  24059. /**
  24060. * Disables writing to the depth buffer when rendering the sprites.
  24061. * It can be handy to disable depth writing when using textures without alpha channel
  24062. * and setting some specific blend modes.
  24063. */
  24064. disableDepthWrite: boolean;
  24065. /**
  24066. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24067. */
  24068. fogEnabled: boolean;
  24069. /**
  24070. * Gets the capacity of the manager
  24071. */
  24072. get capacity(): number;
  24073. private readonly _engine;
  24074. private readonly _useVAO;
  24075. private readonly _useInstancing;
  24076. private readonly _scene;
  24077. private readonly _capacity;
  24078. private readonly _epsilon;
  24079. private _vertexBufferSize;
  24080. private _vertexData;
  24081. private _buffer;
  24082. private _vertexBuffers;
  24083. private _spriteBuffer;
  24084. private _indexBuffer;
  24085. private _effectBase;
  24086. private _effectFog;
  24087. private _vertexArrayObject;
  24088. /**
  24089. * Creates a new sprite Renderer
  24090. * @param engine defines the engine the renderer works with
  24091. * @param capacity defines the maximum allowed number of sprites
  24092. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24093. * @param scene defines the hosting scene
  24094. */
  24095. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24096. /**
  24097. * Render all child sprites
  24098. * @param sprites defines the list of sprites to render
  24099. * @param deltaTime defines the time since last frame
  24100. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24101. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24102. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24103. */
  24104. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24105. private _appendSpriteVertex;
  24106. /**
  24107. * Release associated resources
  24108. */
  24109. dispose(): void;
  24110. }
  24111. }
  24112. declare module BABYLON {
  24113. /**
  24114. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24115. */
  24116. export interface ISpriteManager extends IDisposable {
  24117. /**
  24118. * Gets manager's name
  24119. */
  24120. name: string;
  24121. /**
  24122. * Restricts the camera to viewing objects with the same layerMask.
  24123. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24124. */
  24125. layerMask: number;
  24126. /**
  24127. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24128. */
  24129. isPickable: boolean;
  24130. /**
  24131. * Gets the hosting scene
  24132. */
  24133. scene: Scene;
  24134. /**
  24135. * Specifies the rendering group id for this mesh (0 by default)
  24136. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24137. */
  24138. renderingGroupId: number;
  24139. /**
  24140. * Defines the list of sprites managed by the manager.
  24141. */
  24142. sprites: Array<Sprite>;
  24143. /**
  24144. * Gets or sets the spritesheet texture
  24145. */
  24146. texture: Texture;
  24147. /** Defines the default width of a cell in the spritesheet */
  24148. cellWidth: number;
  24149. /** Defines the default height of a cell in the spritesheet */
  24150. cellHeight: number;
  24151. /**
  24152. * Tests the intersection of a sprite with a specific ray.
  24153. * @param ray The ray we are sending to test the collision
  24154. * @param camera The camera space we are sending rays in
  24155. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24156. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24157. * @returns picking info or null.
  24158. */
  24159. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24160. /**
  24161. * Intersects the sprites with a ray
  24162. * @param ray defines the ray to intersect with
  24163. * @param camera defines the current active camera
  24164. * @param predicate defines a predicate used to select candidate sprites
  24165. * @returns null if no hit or a PickingInfo array
  24166. */
  24167. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24168. /**
  24169. * Renders the list of sprites on screen.
  24170. */
  24171. render(): void;
  24172. }
  24173. /**
  24174. * Class used to manage multiple sprites on the same spritesheet
  24175. * @see https://doc.babylonjs.com/babylon101/sprites
  24176. */
  24177. export class SpriteManager implements ISpriteManager {
  24178. /** defines the manager's name */
  24179. name: string;
  24180. /** Define the Url to load snippets */
  24181. static SnippetUrl: string;
  24182. /** Snippet ID if the manager was created from the snippet server */
  24183. snippetId: string;
  24184. /** Gets the list of sprites */
  24185. sprites: Sprite[];
  24186. /** Gets or sets the rendering group id (0 by default) */
  24187. renderingGroupId: number;
  24188. /** Gets or sets camera layer mask */
  24189. layerMask: number;
  24190. /** Gets or sets a boolean indicating if the sprites are pickable */
  24191. isPickable: boolean;
  24192. /**
  24193. * An event triggered when the manager is disposed.
  24194. */
  24195. onDisposeObservable: Observable<SpriteManager>;
  24196. /**
  24197. * Callback called when the manager is disposed
  24198. */
  24199. set onDispose(callback: () => void);
  24200. /**
  24201. * Gets or sets the unique id of the sprite
  24202. */
  24203. uniqueId: number;
  24204. /**
  24205. * Gets the array of sprites
  24206. */
  24207. get children(): Sprite[];
  24208. /**
  24209. * Gets the hosting scene
  24210. */
  24211. get scene(): Scene;
  24212. /**
  24213. * Gets the capacity of the manager
  24214. */
  24215. get capacity(): number;
  24216. /**
  24217. * Gets or sets the spritesheet texture
  24218. */
  24219. get texture(): Texture;
  24220. set texture(value: Texture);
  24221. /** Defines the default width of a cell in the spritesheet */
  24222. get cellWidth(): number;
  24223. set cellWidth(value: number);
  24224. /** Defines the default height of a cell in the spritesheet */
  24225. get cellHeight(): number;
  24226. set cellHeight(value: number);
  24227. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24228. get fogEnabled(): boolean;
  24229. set fogEnabled(value: boolean);
  24230. /**
  24231. * Blend mode use to render the particle, it can be any of
  24232. * the static Constants.ALPHA_x properties provided in this class.
  24233. * Default value is Constants.ALPHA_COMBINE
  24234. */
  24235. get blendMode(): number;
  24236. set blendMode(blendMode: number);
  24237. /** Disables writing to the depth buffer when rendering the sprites.
  24238. * It can be handy to disable depth writing when using textures without alpha channel
  24239. * and setting some specific blend modes.
  24240. */
  24241. disableDepthWrite: boolean;
  24242. private _spriteRenderer;
  24243. /** Associative array from JSON sprite data file */
  24244. private _cellData;
  24245. /** Array of sprite names from JSON sprite data file */
  24246. private _spriteMap;
  24247. /** True when packed cell data from JSON file is ready*/
  24248. private _packedAndReady;
  24249. private _textureContent;
  24250. private _onDisposeObserver;
  24251. private _fromPacked;
  24252. private _scene;
  24253. /**
  24254. * Creates a new sprite manager
  24255. * @param name defines the manager's name
  24256. * @param imgUrl defines the sprite sheet url
  24257. * @param capacity defines the maximum allowed number of sprites
  24258. * @param cellSize defines the size of a sprite cell
  24259. * @param scene defines the hosting scene
  24260. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24261. * @param samplingMode defines the smapling mode to use with spritesheet
  24262. * @param fromPacked set to false; do not alter
  24263. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24264. */
  24265. constructor(
  24266. /** defines the manager's name */
  24267. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24268. /**
  24269. * Returns the string "SpriteManager"
  24270. * @returns "SpriteManager"
  24271. */
  24272. getClassName(): string;
  24273. private _makePacked;
  24274. private _checkTextureAlpha;
  24275. /**
  24276. * Intersects the sprites with a ray
  24277. * @param ray defines the ray to intersect with
  24278. * @param camera defines the current active camera
  24279. * @param predicate defines a predicate used to select candidate sprites
  24280. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24281. * @returns null if no hit or a PickingInfo
  24282. */
  24283. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24284. /**
  24285. * Intersects the sprites with a ray
  24286. * @param ray defines the ray to intersect with
  24287. * @param camera defines the current active camera
  24288. * @param predicate defines a predicate used to select candidate sprites
  24289. * @returns null if no hit or a PickingInfo array
  24290. */
  24291. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24292. /**
  24293. * Render all child sprites
  24294. */
  24295. render(): void;
  24296. private _customUpdate;
  24297. /**
  24298. * Release associated resources
  24299. */
  24300. dispose(): void;
  24301. /**
  24302. * Serializes the sprite manager to a JSON object
  24303. * @param serializeTexture defines if the texture must be serialized as well
  24304. * @returns the JSON object
  24305. */
  24306. serialize(serializeTexture?: boolean): any;
  24307. /**
  24308. * Parses a JSON object to create a new sprite manager.
  24309. * @param parsedManager The JSON object to parse
  24310. * @param scene The scene to create the sprite managerin
  24311. * @param rootUrl The root url to use to load external dependencies like texture
  24312. * @returns the new sprite manager
  24313. */
  24314. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24315. /**
  24316. * Creates a sprite manager from a snippet saved in a remote file
  24317. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24318. * @param url defines the url to load from
  24319. * @param scene defines the hosting scene
  24320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24321. * @returns a promise that will resolve to the new sprite manager
  24322. */
  24323. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24324. /**
  24325. * Creates a sprite manager from a snippet saved by the sprite editor
  24326. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24327. * @param scene defines the hosting scene
  24328. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24329. * @returns a promise that will resolve to the new sprite manager
  24330. */
  24331. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24332. }
  24333. }
  24334. declare module BABYLON {
  24335. /**
  24336. * Class used to represent a sprite
  24337. * @see https://doc.babylonjs.com/babylon101/sprites
  24338. */
  24339. export class Sprite extends ThinSprite implements IAnimatable {
  24340. /** defines the name */
  24341. name: string;
  24342. /** Gets or sets the current world position */
  24343. position: Vector3;
  24344. /** Gets or sets the main color */
  24345. color: Color4;
  24346. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24347. disposeWhenFinishedAnimating: boolean;
  24348. /** Gets the list of attached animations */
  24349. animations: Nullable<Array<Animation>>;
  24350. /** Gets or sets a boolean indicating if the sprite can be picked */
  24351. isPickable: boolean;
  24352. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24353. useAlphaForPicking: boolean;
  24354. /**
  24355. * Gets or sets the associated action manager
  24356. */
  24357. actionManager: Nullable<ActionManager>;
  24358. /**
  24359. * An event triggered when the control has been disposed
  24360. */
  24361. onDisposeObservable: Observable<Sprite>;
  24362. private _manager;
  24363. private _onAnimationEnd;
  24364. /**
  24365. * Gets or sets the sprite size
  24366. */
  24367. get size(): number;
  24368. set size(value: number);
  24369. /**
  24370. * Gets or sets the unique id of the sprite
  24371. */
  24372. uniqueId: number;
  24373. /**
  24374. * Gets the manager of this sprite
  24375. */
  24376. get manager(): ISpriteManager;
  24377. /**
  24378. * Creates a new Sprite
  24379. * @param name defines the name
  24380. * @param manager defines the manager
  24381. */
  24382. constructor(
  24383. /** defines the name */
  24384. name: string, manager: ISpriteManager);
  24385. /**
  24386. * Returns the string "Sprite"
  24387. * @returns "Sprite"
  24388. */
  24389. getClassName(): string;
  24390. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24391. get fromIndex(): number;
  24392. set fromIndex(value: number);
  24393. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24394. get toIndex(): number;
  24395. set toIndex(value: number);
  24396. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24397. get loopAnimation(): boolean;
  24398. set loopAnimation(value: boolean);
  24399. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24400. get delay(): number;
  24401. set delay(value: number);
  24402. /**
  24403. * Starts an animation
  24404. * @param from defines the initial key
  24405. * @param to defines the end key
  24406. * @param loop defines if the animation must loop
  24407. * @param delay defines the start delay (in ms)
  24408. * @param onAnimationEnd defines a callback to call when animation ends
  24409. */
  24410. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24411. private _endAnimation;
  24412. /** Release associated resources */
  24413. dispose(): void;
  24414. /**
  24415. * Serializes the sprite to a JSON object
  24416. * @returns the JSON object
  24417. */
  24418. serialize(): any;
  24419. /**
  24420. * Parses a JSON object to create a new sprite
  24421. * @param parsedSprite The JSON object to parse
  24422. * @param manager defines the hosting manager
  24423. * @returns the new sprite
  24424. */
  24425. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24426. }
  24427. }
  24428. declare module BABYLON {
  24429. /**
  24430. * Information about the result of picking within a scene
  24431. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24432. */
  24433. export class PickingInfo {
  24434. /** @hidden */
  24435. _pickingUnavailable: boolean;
  24436. /**
  24437. * If the pick collided with an object
  24438. */
  24439. hit: boolean;
  24440. /**
  24441. * Distance away where the pick collided
  24442. */
  24443. distance: number;
  24444. /**
  24445. * The location of pick collision
  24446. */
  24447. pickedPoint: Nullable<Vector3>;
  24448. /**
  24449. * The mesh corresponding the the pick collision
  24450. */
  24451. pickedMesh: Nullable<AbstractMesh>;
  24452. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24453. bu: number;
  24454. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24455. bv: number;
  24456. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24457. faceId: number;
  24458. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24459. subMeshFaceId: number;
  24460. /** Id of the the submesh that was picked */
  24461. subMeshId: number;
  24462. /** If a sprite was picked, this will be the sprite the pick collided with */
  24463. pickedSprite: Nullable<Sprite>;
  24464. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24465. thinInstanceIndex: number;
  24466. /**
  24467. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24468. */
  24469. originMesh: Nullable<AbstractMesh>;
  24470. /**
  24471. * The ray that was used to perform the picking.
  24472. */
  24473. ray: Nullable<Ray>;
  24474. /**
  24475. * Gets the normal correspodning to the face the pick collided with
  24476. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24477. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24478. * @returns The normal correspodning to the face the pick collided with
  24479. */
  24480. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24481. /**
  24482. * Gets the texture coordinates of where the pick occured
  24483. * @returns the vector containing the coordnates of the texture
  24484. */
  24485. getTextureCoordinates(): Nullable<Vector2>;
  24486. }
  24487. }
  24488. declare module BABYLON {
  24489. /**
  24490. * Gather the list of pointer event types as constants.
  24491. */
  24492. export class PointerEventTypes {
  24493. /**
  24494. * 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.
  24495. */
  24496. static readonly POINTERDOWN: number;
  24497. /**
  24498. * The pointerup event is fired when a pointer is no longer active.
  24499. */
  24500. static readonly POINTERUP: number;
  24501. /**
  24502. * The pointermove event is fired when a pointer changes coordinates.
  24503. */
  24504. static readonly POINTERMOVE: number;
  24505. /**
  24506. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24507. */
  24508. static readonly POINTERWHEEL: number;
  24509. /**
  24510. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24511. */
  24512. static readonly POINTERPICK: number;
  24513. /**
  24514. * The pointertap event is fired when a the object has been touched and released without drag.
  24515. */
  24516. static readonly POINTERTAP: number;
  24517. /**
  24518. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24519. */
  24520. static readonly POINTERDOUBLETAP: number;
  24521. }
  24522. /**
  24523. * Base class of pointer info types.
  24524. */
  24525. export class PointerInfoBase {
  24526. /**
  24527. * Defines the type of event (PointerEventTypes)
  24528. */
  24529. type: number;
  24530. /**
  24531. * Defines the related dom event
  24532. */
  24533. event: PointerEvent | MouseWheelEvent;
  24534. /**
  24535. * Instantiates the base class of pointers info.
  24536. * @param type Defines the type of event (PointerEventTypes)
  24537. * @param event Defines the related dom event
  24538. */
  24539. constructor(
  24540. /**
  24541. * Defines the type of event (PointerEventTypes)
  24542. */
  24543. type: number,
  24544. /**
  24545. * Defines the related dom event
  24546. */
  24547. event: PointerEvent | MouseWheelEvent);
  24548. }
  24549. /**
  24550. * This class is used to store pointer related info for the onPrePointerObservable event.
  24551. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24552. */
  24553. export class PointerInfoPre extends PointerInfoBase {
  24554. /**
  24555. * Ray from a pointer if availible (eg. 6dof controller)
  24556. */
  24557. ray: Nullable<Ray>;
  24558. /**
  24559. * Defines the local position of the pointer on the canvas.
  24560. */
  24561. localPosition: Vector2;
  24562. /**
  24563. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24564. */
  24565. skipOnPointerObservable: boolean;
  24566. /**
  24567. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24568. * @param type Defines the type of event (PointerEventTypes)
  24569. * @param event Defines the related dom event
  24570. * @param localX Defines the local x coordinates of the pointer when the event occured
  24571. * @param localY Defines the local y coordinates of the pointer when the event occured
  24572. */
  24573. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24574. }
  24575. /**
  24576. * This type contains all the data related to a pointer event in Babylon.js.
  24577. * 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.
  24578. */
  24579. export class PointerInfo extends PointerInfoBase {
  24580. /**
  24581. * Defines the picking info associated to the info (if any)\
  24582. */
  24583. pickInfo: Nullable<PickingInfo>;
  24584. /**
  24585. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24586. * @param type Defines the type of event (PointerEventTypes)
  24587. * @param event Defines the related dom event
  24588. * @param pickInfo Defines the picking info associated to the info (if any)\
  24589. */
  24590. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24591. /**
  24592. * Defines the picking info associated to the info (if any)\
  24593. */
  24594. pickInfo: Nullable<PickingInfo>);
  24595. }
  24596. /**
  24597. * Data relating to a touch event on the screen.
  24598. */
  24599. export interface PointerTouch {
  24600. /**
  24601. * X coordinate of touch.
  24602. */
  24603. x: number;
  24604. /**
  24605. * Y coordinate of touch.
  24606. */
  24607. y: number;
  24608. /**
  24609. * Id of touch. Unique for each finger.
  24610. */
  24611. pointerId: number;
  24612. /**
  24613. * Event type passed from DOM.
  24614. */
  24615. type: any;
  24616. }
  24617. }
  24618. declare module BABYLON {
  24619. /**
  24620. * Manage the mouse inputs to control the movement of a free camera.
  24621. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24622. */
  24623. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24624. /**
  24625. * Define if touch is enabled in the mouse input
  24626. */
  24627. touchEnabled: boolean;
  24628. /**
  24629. * Defines the camera the input is attached to.
  24630. */
  24631. camera: FreeCamera;
  24632. /**
  24633. * Defines the buttons associated with the input to handle camera move.
  24634. */
  24635. buttons: number[];
  24636. /**
  24637. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24638. */
  24639. angularSensibility: number;
  24640. private _pointerInput;
  24641. private _onMouseMove;
  24642. private _observer;
  24643. private previousPosition;
  24644. /**
  24645. * Observable for when a pointer move event occurs containing the move offset
  24646. */
  24647. onPointerMovedObservable: Observable<{
  24648. offsetX: number;
  24649. offsetY: number;
  24650. }>;
  24651. /**
  24652. * @hidden
  24653. * If the camera should be rotated automatically based on pointer movement
  24654. */
  24655. _allowCameraRotation: boolean;
  24656. /**
  24657. * Manage the mouse inputs to control the movement of a free camera.
  24658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24659. * @param touchEnabled Defines if touch is enabled or not
  24660. */
  24661. constructor(
  24662. /**
  24663. * Define if touch is enabled in the mouse input
  24664. */
  24665. touchEnabled?: boolean);
  24666. /**
  24667. * Attach the input controls to a specific dom element to get the input from.
  24668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24669. */
  24670. attachControl(noPreventDefault?: boolean): void;
  24671. /**
  24672. * Called on JS contextmenu event.
  24673. * Override this method to provide functionality.
  24674. */
  24675. protected onContextMenu(evt: PointerEvent): void;
  24676. /**
  24677. * Detach the current controls from the specified dom element.
  24678. */
  24679. detachControl(): void;
  24680. /**
  24681. * Gets the class name of the current intput.
  24682. * @returns the class name
  24683. */
  24684. getClassName(): string;
  24685. /**
  24686. * Get the friendly name associated with the input class.
  24687. * @returns the input friendly name
  24688. */
  24689. getSimpleName(): string;
  24690. }
  24691. }
  24692. declare module BABYLON {
  24693. /**
  24694. * Base class for mouse wheel input..
  24695. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24696. * for example usage.
  24697. */
  24698. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24699. /**
  24700. * Defines the camera the input is attached to.
  24701. */
  24702. abstract camera: Camera;
  24703. /**
  24704. * How fast is the camera moves in relation to X axis mouseWheel events.
  24705. * Use negative value to reverse direction.
  24706. */
  24707. wheelPrecisionX: number;
  24708. /**
  24709. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24710. * Use negative value to reverse direction.
  24711. */
  24712. wheelPrecisionY: number;
  24713. /**
  24714. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24715. * Use negative value to reverse direction.
  24716. */
  24717. wheelPrecisionZ: number;
  24718. /**
  24719. * Observable for when a mouse wheel move event occurs.
  24720. */
  24721. onChangedObservable: Observable<{
  24722. wheelDeltaX: number;
  24723. wheelDeltaY: number;
  24724. wheelDeltaZ: number;
  24725. }>;
  24726. private _wheel;
  24727. private _observer;
  24728. /**
  24729. * Attach the input controls to a specific dom element to get the input from.
  24730. * @param noPreventDefault Defines whether event caught by the controls
  24731. * should call preventdefault().
  24732. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24733. */
  24734. attachControl(noPreventDefault?: boolean): void;
  24735. /**
  24736. * Detach the current controls from the specified dom element.
  24737. */
  24738. detachControl(): void;
  24739. /**
  24740. * Called for each rendered frame.
  24741. */
  24742. checkInputs(): void;
  24743. /**
  24744. * Gets the class name of the current intput.
  24745. * @returns the class name
  24746. */
  24747. getClassName(): string;
  24748. /**
  24749. * Get the friendly name associated with the input class.
  24750. * @returns the input friendly name
  24751. */
  24752. getSimpleName(): string;
  24753. /**
  24754. * Incremental value of multiple mouse wheel movements of the X axis.
  24755. * Should be zero-ed when read.
  24756. */
  24757. protected _wheelDeltaX: number;
  24758. /**
  24759. * Incremental value of multiple mouse wheel movements of the Y axis.
  24760. * Should be zero-ed when read.
  24761. */
  24762. protected _wheelDeltaY: number;
  24763. /**
  24764. * Incremental value of multiple mouse wheel movements of the Z axis.
  24765. * Should be zero-ed when read.
  24766. */
  24767. protected _wheelDeltaZ: number;
  24768. /**
  24769. * Firefox uses a different scheme to report scroll distances to other
  24770. * browsers. Rather than use complicated methods to calculate the exact
  24771. * multiple we need to apply, let's just cheat and use a constant.
  24772. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24773. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24774. */
  24775. private readonly _ffMultiplier;
  24776. /**
  24777. * Different event attributes for wheel data fall into a few set ranges.
  24778. * Some relevant but dated date here:
  24779. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24780. */
  24781. private readonly _normalize;
  24782. }
  24783. }
  24784. declare module BABYLON {
  24785. /**
  24786. * Manage the mouse wheel inputs to control a free camera.
  24787. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24788. */
  24789. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24790. /**
  24791. * Defines the camera the input is attached to.
  24792. */
  24793. camera: FreeCamera;
  24794. /**
  24795. * Gets the class name of the current input.
  24796. * @returns the class name
  24797. */
  24798. getClassName(): string;
  24799. /**
  24800. * Set which movement axis (relative to camera's orientation) the mouse
  24801. * wheel's X axis controls.
  24802. * @param axis The axis to be moved. Set null to clear.
  24803. */
  24804. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24805. /**
  24806. * Get the configured movement axis (relative to camera's orientation) the
  24807. * mouse wheel's X axis controls.
  24808. * @returns The configured axis or null if none.
  24809. */
  24810. get wheelXMoveRelative(): Nullable<Coordinate>;
  24811. /**
  24812. * Set which movement axis (relative to camera's orientation) the mouse
  24813. * wheel's Y axis controls.
  24814. * @param axis The axis to be moved. Set null to clear.
  24815. */
  24816. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24817. /**
  24818. * Get the configured movement axis (relative to camera's orientation) the
  24819. * mouse wheel's Y axis controls.
  24820. * @returns The configured axis or null if none.
  24821. */
  24822. get wheelYMoveRelative(): Nullable<Coordinate>;
  24823. /**
  24824. * Set which movement axis (relative to camera's orientation) the mouse
  24825. * wheel's Z axis controls.
  24826. * @param axis The axis to be moved. Set null to clear.
  24827. */
  24828. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24829. /**
  24830. * Get the configured movement axis (relative to camera's orientation) the
  24831. * mouse wheel's Z axis controls.
  24832. * @returns The configured axis or null if none.
  24833. */
  24834. get wheelZMoveRelative(): Nullable<Coordinate>;
  24835. /**
  24836. * Set which rotation axis (relative to camera's orientation) the mouse
  24837. * wheel's X axis controls.
  24838. * @param axis The axis to be moved. Set null to clear.
  24839. */
  24840. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24841. /**
  24842. * Get the configured rotation axis (relative to camera's orientation) the
  24843. * mouse wheel's X axis controls.
  24844. * @returns The configured axis or null if none.
  24845. */
  24846. get wheelXRotateRelative(): Nullable<Coordinate>;
  24847. /**
  24848. * Set which rotation axis (relative to camera's orientation) the mouse
  24849. * wheel's Y axis controls.
  24850. * @param axis The axis to be moved. Set null to clear.
  24851. */
  24852. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24853. /**
  24854. * Get the configured rotation axis (relative to camera's orientation) the
  24855. * mouse wheel's Y axis controls.
  24856. * @returns The configured axis or null if none.
  24857. */
  24858. get wheelYRotateRelative(): Nullable<Coordinate>;
  24859. /**
  24860. * Set which rotation axis (relative to camera's orientation) the mouse
  24861. * wheel's Z axis controls.
  24862. * @param axis The axis to be moved. Set null to clear.
  24863. */
  24864. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24865. /**
  24866. * Get the configured rotation axis (relative to camera's orientation) the
  24867. * mouse wheel's Z axis controls.
  24868. * @returns The configured axis or null if none.
  24869. */
  24870. get wheelZRotateRelative(): Nullable<Coordinate>;
  24871. /**
  24872. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24873. * controls.
  24874. * @param axis The axis to be moved. Set null to clear.
  24875. */
  24876. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24877. /**
  24878. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24879. * X axis controls.
  24880. * @returns The configured axis or null if none.
  24881. */
  24882. get wheelXMoveScene(): Nullable<Coordinate>;
  24883. /**
  24884. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24885. * controls.
  24886. * @param axis The axis to be moved. Set null to clear.
  24887. */
  24888. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24889. /**
  24890. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24891. * Y axis controls.
  24892. * @returns The configured axis or null if none.
  24893. */
  24894. get wheelYMoveScene(): Nullable<Coordinate>;
  24895. /**
  24896. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24897. * controls.
  24898. * @param axis The axis to be moved. Set null to clear.
  24899. */
  24900. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24901. /**
  24902. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24903. * Z axis controls.
  24904. * @returns The configured axis or null if none.
  24905. */
  24906. get wheelZMoveScene(): Nullable<Coordinate>;
  24907. /**
  24908. * Called for each rendered frame.
  24909. */
  24910. checkInputs(): void;
  24911. private _moveRelative;
  24912. private _rotateRelative;
  24913. private _moveScene;
  24914. /**
  24915. * These are set to the desired default behaviour.
  24916. */
  24917. private _wheelXAction;
  24918. private _wheelXActionCoordinate;
  24919. private _wheelYAction;
  24920. private _wheelYActionCoordinate;
  24921. private _wheelZAction;
  24922. private _wheelZActionCoordinate;
  24923. /**
  24924. * Update the camera according to any configured properties for the 3
  24925. * mouse-wheel axis.
  24926. */
  24927. private _updateCamera;
  24928. /**
  24929. * Update one property of the camera.
  24930. */
  24931. private _updateCameraProperty;
  24932. }
  24933. }
  24934. declare module BABYLON {
  24935. /**
  24936. * Manage the touch inputs to control the movement of a free camera.
  24937. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24938. */
  24939. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24940. /**
  24941. * Define if mouse events can be treated as touch events
  24942. */
  24943. allowMouse: boolean;
  24944. /**
  24945. * Defines the camera the input is attached to.
  24946. */
  24947. camera: FreeCamera;
  24948. /**
  24949. * Defines the touch sensibility for rotation.
  24950. * The higher the faster.
  24951. */
  24952. touchAngularSensibility: number;
  24953. /**
  24954. * Defines the touch sensibility for move.
  24955. * The higher the faster.
  24956. */
  24957. touchMoveSensibility: number;
  24958. private _offsetX;
  24959. private _offsetY;
  24960. private _pointerPressed;
  24961. private _pointerInput?;
  24962. private _observer;
  24963. private _onLostFocus;
  24964. /**
  24965. * Manage the touch inputs to control the movement of a free camera.
  24966. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24967. * @param allowMouse Defines if mouse events can be treated as touch events
  24968. */
  24969. constructor(
  24970. /**
  24971. * Define if mouse events can be treated as touch events
  24972. */
  24973. allowMouse?: boolean);
  24974. /**
  24975. * Attach the input controls to a specific dom element to get the input from.
  24976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24977. */
  24978. attachControl(noPreventDefault?: boolean): void;
  24979. /**
  24980. * Detach the current controls from the specified dom element.
  24981. */
  24982. detachControl(): void;
  24983. /**
  24984. * Update the current camera state depending on the inputs that have been used this frame.
  24985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24986. */
  24987. checkInputs(): void;
  24988. /**
  24989. * Gets the class name of the current intput.
  24990. * @returns the class name
  24991. */
  24992. getClassName(): string;
  24993. /**
  24994. * Get the friendly name associated with the input class.
  24995. * @returns the input friendly name
  24996. */
  24997. getSimpleName(): string;
  24998. }
  24999. }
  25000. declare module BABYLON {
  25001. /**
  25002. * Default Inputs manager for the FreeCamera.
  25003. * It groups all the default supported inputs for ease of use.
  25004. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25005. */
  25006. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25007. /**
  25008. * @hidden
  25009. */
  25010. _mouseInput: Nullable<FreeCameraMouseInput>;
  25011. /**
  25012. * @hidden
  25013. */
  25014. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25015. /**
  25016. * Instantiates a new FreeCameraInputsManager.
  25017. * @param camera Defines the camera the inputs belong to
  25018. */
  25019. constructor(camera: FreeCamera);
  25020. /**
  25021. * Add keyboard input support to the input manager.
  25022. * @returns the current input manager
  25023. */
  25024. addKeyboard(): FreeCameraInputsManager;
  25025. /**
  25026. * Add mouse input support to the input manager.
  25027. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25028. * @returns the current input manager
  25029. */
  25030. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25031. /**
  25032. * Removes the mouse input support from the manager
  25033. * @returns the current input manager
  25034. */
  25035. removeMouse(): FreeCameraInputsManager;
  25036. /**
  25037. * Add mouse wheel input support to the input manager.
  25038. * @returns the current input manager
  25039. */
  25040. addMouseWheel(): FreeCameraInputsManager;
  25041. /**
  25042. * Removes the mouse wheel input support from the manager
  25043. * @returns the current input manager
  25044. */
  25045. removeMouseWheel(): FreeCameraInputsManager;
  25046. /**
  25047. * Add touch input support to the input manager.
  25048. * @returns the current input manager
  25049. */
  25050. addTouch(): FreeCameraInputsManager;
  25051. /**
  25052. * Remove all attached input methods from a camera
  25053. */
  25054. clear(): void;
  25055. }
  25056. }
  25057. declare module BABYLON {
  25058. /**
  25059. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25060. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25061. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25062. */
  25063. export class FreeCamera extends TargetCamera {
  25064. /**
  25065. * Define the collision ellipsoid of the camera.
  25066. * This is helpful to simulate a camera body like the player body around the camera
  25067. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25068. */
  25069. ellipsoid: Vector3;
  25070. /**
  25071. * Define an offset for the position of the ellipsoid around the camera.
  25072. * This can be helpful to determine the center of the body near the gravity center of the body
  25073. * instead of its head.
  25074. */
  25075. ellipsoidOffset: Vector3;
  25076. /**
  25077. * Enable or disable collisions of the camera with the rest of the scene objects.
  25078. */
  25079. checkCollisions: boolean;
  25080. /**
  25081. * Enable or disable gravity on the camera.
  25082. */
  25083. applyGravity: boolean;
  25084. /**
  25085. * Define the input manager associated to the camera.
  25086. */
  25087. inputs: FreeCameraInputsManager;
  25088. /**
  25089. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25090. * Higher values reduce sensitivity.
  25091. */
  25092. get angularSensibility(): number;
  25093. /**
  25094. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25095. * Higher values reduce sensitivity.
  25096. */
  25097. set angularSensibility(value: number);
  25098. /**
  25099. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25100. */
  25101. get keysUp(): number[];
  25102. set keysUp(value: number[]);
  25103. /**
  25104. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25105. */
  25106. get keysUpward(): number[];
  25107. set keysUpward(value: number[]);
  25108. /**
  25109. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25110. */
  25111. get keysDown(): number[];
  25112. set keysDown(value: number[]);
  25113. /**
  25114. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25115. */
  25116. get keysDownward(): number[];
  25117. set keysDownward(value: number[]);
  25118. /**
  25119. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25120. */
  25121. get keysLeft(): number[];
  25122. set keysLeft(value: number[]);
  25123. /**
  25124. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25125. */
  25126. get keysRight(): number[];
  25127. set keysRight(value: number[]);
  25128. /**
  25129. * Event raised when the camera collide with a mesh in the scene.
  25130. */
  25131. onCollide: (collidedMesh: AbstractMesh) => void;
  25132. private _collider;
  25133. private _needMoveForGravity;
  25134. private _oldPosition;
  25135. private _diffPosition;
  25136. private _newPosition;
  25137. /** @hidden */
  25138. _localDirection: Vector3;
  25139. /** @hidden */
  25140. _transformedDirection: Vector3;
  25141. /**
  25142. * Instantiates a Free Camera.
  25143. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25144. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25145. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25146. * @param name Define the name of the camera in the scene
  25147. * @param position Define the start position of the camera in the scene
  25148. * @param scene Define the scene the camera belongs to
  25149. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25150. */
  25151. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25152. /**
  25153. * Attach the input controls to a specific dom element to get the input from.
  25154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25155. */
  25156. attachControl(noPreventDefault?: boolean): void;
  25157. /**
  25158. * Attach the input controls to a specific dom element to get the input from.
  25159. * @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
  25160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25161. * BACK COMPAT SIGNATURE ONLY.
  25162. */
  25163. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25164. /**
  25165. * Detach the current controls from the specified dom element.
  25166. */
  25167. detachControl(): void;
  25168. /**
  25169. * Detach the current controls from the specified dom element.
  25170. * @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
  25171. */
  25172. detachControl(ignored: any): void;
  25173. private _collisionMask;
  25174. /**
  25175. * Define a collision mask to limit the list of object the camera can collide with
  25176. */
  25177. get collisionMask(): number;
  25178. set collisionMask(mask: number);
  25179. /** @hidden */
  25180. _collideWithWorld(displacement: Vector3): void;
  25181. private _onCollisionPositionChange;
  25182. /** @hidden */
  25183. _checkInputs(): void;
  25184. /** @hidden */
  25185. _decideIfNeedsToMove(): boolean;
  25186. /** @hidden */
  25187. _updatePosition(): void;
  25188. /**
  25189. * Destroy the camera and release the current resources hold by it.
  25190. */
  25191. dispose(): void;
  25192. /**
  25193. * Gets the current object class name.
  25194. * @return the class name
  25195. */
  25196. getClassName(): string;
  25197. }
  25198. }
  25199. declare module BABYLON {
  25200. /**
  25201. * Represents a gamepad control stick position
  25202. */
  25203. export class StickValues {
  25204. /**
  25205. * The x component of the control stick
  25206. */
  25207. x: number;
  25208. /**
  25209. * The y component of the control stick
  25210. */
  25211. y: number;
  25212. /**
  25213. * Initializes the gamepad x and y control stick values
  25214. * @param x The x component of the gamepad control stick value
  25215. * @param y The y component of the gamepad control stick value
  25216. */
  25217. constructor(
  25218. /**
  25219. * The x component of the control stick
  25220. */
  25221. x: number,
  25222. /**
  25223. * The y component of the control stick
  25224. */
  25225. y: number);
  25226. }
  25227. /**
  25228. * An interface which manages callbacks for gamepad button changes
  25229. */
  25230. export interface GamepadButtonChanges {
  25231. /**
  25232. * Called when a gamepad has been changed
  25233. */
  25234. changed: boolean;
  25235. /**
  25236. * Called when a gamepad press event has been triggered
  25237. */
  25238. pressChanged: boolean;
  25239. /**
  25240. * Called when a touch event has been triggered
  25241. */
  25242. touchChanged: boolean;
  25243. /**
  25244. * Called when a value has changed
  25245. */
  25246. valueChanged: boolean;
  25247. }
  25248. /**
  25249. * Represents a gamepad
  25250. */
  25251. export class Gamepad {
  25252. /**
  25253. * The id of the gamepad
  25254. */
  25255. id: string;
  25256. /**
  25257. * The index of the gamepad
  25258. */
  25259. index: number;
  25260. /**
  25261. * The browser gamepad
  25262. */
  25263. browserGamepad: any;
  25264. /**
  25265. * Specifies what type of gamepad this represents
  25266. */
  25267. type: number;
  25268. private _leftStick;
  25269. private _rightStick;
  25270. /** @hidden */
  25271. _isConnected: boolean;
  25272. private _leftStickAxisX;
  25273. private _leftStickAxisY;
  25274. private _rightStickAxisX;
  25275. private _rightStickAxisY;
  25276. /**
  25277. * Triggered when the left control stick has been changed
  25278. */
  25279. private _onleftstickchanged;
  25280. /**
  25281. * Triggered when the right control stick has been changed
  25282. */
  25283. private _onrightstickchanged;
  25284. /**
  25285. * Represents a gamepad controller
  25286. */
  25287. static GAMEPAD: number;
  25288. /**
  25289. * Represents a generic controller
  25290. */
  25291. static GENERIC: number;
  25292. /**
  25293. * Represents an XBox controller
  25294. */
  25295. static XBOX: number;
  25296. /**
  25297. * Represents a pose-enabled controller
  25298. */
  25299. static POSE_ENABLED: number;
  25300. /**
  25301. * Represents an Dual Shock controller
  25302. */
  25303. static DUALSHOCK: number;
  25304. /**
  25305. * Specifies whether the left control stick should be Y-inverted
  25306. */
  25307. protected _invertLeftStickY: boolean;
  25308. /**
  25309. * Specifies if the gamepad has been connected
  25310. */
  25311. get isConnected(): boolean;
  25312. /**
  25313. * Initializes the gamepad
  25314. * @param id The id of the gamepad
  25315. * @param index The index of the gamepad
  25316. * @param browserGamepad The browser gamepad
  25317. * @param leftStickX The x component of the left joystick
  25318. * @param leftStickY The y component of the left joystick
  25319. * @param rightStickX The x component of the right joystick
  25320. * @param rightStickY The y component of the right joystick
  25321. */
  25322. constructor(
  25323. /**
  25324. * The id of the gamepad
  25325. */
  25326. id: string,
  25327. /**
  25328. * The index of the gamepad
  25329. */
  25330. index: number,
  25331. /**
  25332. * The browser gamepad
  25333. */
  25334. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25335. /**
  25336. * Callback triggered when the left joystick has changed
  25337. * @param callback
  25338. */
  25339. onleftstickchanged(callback: (values: StickValues) => void): void;
  25340. /**
  25341. * Callback triggered when the right joystick has changed
  25342. * @param callback
  25343. */
  25344. onrightstickchanged(callback: (values: StickValues) => void): void;
  25345. /**
  25346. * Gets the left joystick
  25347. */
  25348. get leftStick(): StickValues;
  25349. /**
  25350. * Sets the left joystick values
  25351. */
  25352. set leftStick(newValues: StickValues);
  25353. /**
  25354. * Gets the right joystick
  25355. */
  25356. get rightStick(): StickValues;
  25357. /**
  25358. * Sets the right joystick value
  25359. */
  25360. set rightStick(newValues: StickValues);
  25361. /**
  25362. * Updates the gamepad joystick positions
  25363. */
  25364. update(): void;
  25365. /**
  25366. * Disposes the gamepad
  25367. */
  25368. dispose(): void;
  25369. }
  25370. /**
  25371. * Represents a generic gamepad
  25372. */
  25373. export class GenericPad extends Gamepad {
  25374. private _buttons;
  25375. private _onbuttondown;
  25376. private _onbuttonup;
  25377. /**
  25378. * Observable triggered when a button has been pressed
  25379. */
  25380. onButtonDownObservable: Observable<number>;
  25381. /**
  25382. * Observable triggered when a button has been released
  25383. */
  25384. onButtonUpObservable: Observable<number>;
  25385. /**
  25386. * Callback triggered when a button has been pressed
  25387. * @param callback Called when a button has been pressed
  25388. */
  25389. onbuttondown(callback: (buttonPressed: number) => void): void;
  25390. /**
  25391. * Callback triggered when a button has been released
  25392. * @param callback Called when a button has been released
  25393. */
  25394. onbuttonup(callback: (buttonReleased: number) => void): void;
  25395. /**
  25396. * Initializes the generic gamepad
  25397. * @param id The id of the generic gamepad
  25398. * @param index The index of the generic gamepad
  25399. * @param browserGamepad The browser gamepad
  25400. */
  25401. constructor(id: string, index: number, browserGamepad: any);
  25402. private _setButtonValue;
  25403. /**
  25404. * Updates the generic gamepad
  25405. */
  25406. update(): void;
  25407. /**
  25408. * Disposes the generic gamepad
  25409. */
  25410. dispose(): void;
  25411. }
  25412. }
  25413. declare module BABYLON {
  25414. /**
  25415. * Defines a runtime animation
  25416. */
  25417. export class RuntimeAnimation {
  25418. private _events;
  25419. /**
  25420. * The current frame of the runtime animation
  25421. */
  25422. private _currentFrame;
  25423. /**
  25424. * The animation used by the runtime animation
  25425. */
  25426. private _animation;
  25427. /**
  25428. * The target of the runtime animation
  25429. */
  25430. private _target;
  25431. /**
  25432. * The initiating animatable
  25433. */
  25434. private _host;
  25435. /**
  25436. * The original value of the runtime animation
  25437. */
  25438. private _originalValue;
  25439. /**
  25440. * The original blend value of the runtime animation
  25441. */
  25442. private _originalBlendValue;
  25443. /**
  25444. * The offsets cache of the runtime animation
  25445. */
  25446. private _offsetsCache;
  25447. /**
  25448. * The high limits cache of the runtime animation
  25449. */
  25450. private _highLimitsCache;
  25451. /**
  25452. * Specifies if the runtime animation has been stopped
  25453. */
  25454. private _stopped;
  25455. /**
  25456. * The blending factor of the runtime animation
  25457. */
  25458. private _blendingFactor;
  25459. /**
  25460. * The BabylonJS scene
  25461. */
  25462. private _scene;
  25463. /**
  25464. * The current value of the runtime animation
  25465. */
  25466. private _currentValue;
  25467. /** @hidden */
  25468. _animationState: _IAnimationState;
  25469. /**
  25470. * The active target of the runtime animation
  25471. */
  25472. private _activeTargets;
  25473. private _currentActiveTarget;
  25474. private _directTarget;
  25475. /**
  25476. * The target path of the runtime animation
  25477. */
  25478. private _targetPath;
  25479. /**
  25480. * The weight of the runtime animation
  25481. */
  25482. private _weight;
  25483. /**
  25484. * The ratio offset of the runtime animation
  25485. */
  25486. private _ratioOffset;
  25487. /**
  25488. * The previous delay of the runtime animation
  25489. */
  25490. private _previousDelay;
  25491. /**
  25492. * The previous ratio of the runtime animation
  25493. */
  25494. private _previousRatio;
  25495. private _enableBlending;
  25496. private _keys;
  25497. private _minFrame;
  25498. private _maxFrame;
  25499. private _minValue;
  25500. private _maxValue;
  25501. private _targetIsArray;
  25502. /**
  25503. * Gets the current frame of the runtime animation
  25504. */
  25505. get currentFrame(): number;
  25506. /**
  25507. * Gets the weight of the runtime animation
  25508. */
  25509. get weight(): number;
  25510. /**
  25511. * Gets the current value of the runtime animation
  25512. */
  25513. get currentValue(): any;
  25514. /**
  25515. * Gets the target path of the runtime animation
  25516. */
  25517. get targetPath(): string;
  25518. /**
  25519. * Gets the actual target of the runtime animation
  25520. */
  25521. get target(): any;
  25522. /**
  25523. * Gets the additive state of the runtime animation
  25524. */
  25525. get isAdditive(): boolean;
  25526. /** @hidden */
  25527. _onLoop: () => void;
  25528. /**
  25529. * Create a new RuntimeAnimation object
  25530. * @param target defines the target of the animation
  25531. * @param animation defines the source animation object
  25532. * @param scene defines the hosting scene
  25533. * @param host defines the initiating Animatable
  25534. */
  25535. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25536. private _preparePath;
  25537. /**
  25538. * Gets the animation from the runtime animation
  25539. */
  25540. get animation(): Animation;
  25541. /**
  25542. * Resets the runtime animation to the beginning
  25543. * @param restoreOriginal defines whether to restore the target property to the original value
  25544. */
  25545. reset(restoreOriginal?: boolean): void;
  25546. /**
  25547. * Specifies if the runtime animation is stopped
  25548. * @returns Boolean specifying if the runtime animation is stopped
  25549. */
  25550. isStopped(): boolean;
  25551. /**
  25552. * Disposes of the runtime animation
  25553. */
  25554. dispose(): void;
  25555. /**
  25556. * Apply the interpolated value to the target
  25557. * @param currentValue defines the value computed by the animation
  25558. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25559. */
  25560. setValue(currentValue: any, weight: number): void;
  25561. private _getOriginalValues;
  25562. private _setValue;
  25563. /**
  25564. * Gets the loop pmode of the runtime animation
  25565. * @returns Loop Mode
  25566. */
  25567. private _getCorrectLoopMode;
  25568. /**
  25569. * Move the current animation to a given frame
  25570. * @param frame defines the frame to move to
  25571. */
  25572. goToFrame(frame: number): void;
  25573. /**
  25574. * @hidden Internal use only
  25575. */
  25576. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25577. /**
  25578. * Execute the current animation
  25579. * @param delay defines the delay to add to the current frame
  25580. * @param from defines the lower bound of the animation range
  25581. * @param to defines the upper bound of the animation range
  25582. * @param loop defines if the current animation must loop
  25583. * @param speedRatio defines the current speed ratio
  25584. * @param weight defines the weight of the animation (default is -1 so no weight)
  25585. * @param onLoop optional callback called when animation loops
  25586. * @returns a boolean indicating if the animation is running
  25587. */
  25588. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25589. }
  25590. }
  25591. declare module BABYLON {
  25592. /**
  25593. * Class used to store an actual running animation
  25594. */
  25595. export class Animatable {
  25596. /** defines the target object */
  25597. target: any;
  25598. /** defines the starting frame number (default is 0) */
  25599. fromFrame: number;
  25600. /** defines the ending frame number (default is 100) */
  25601. toFrame: number;
  25602. /** defines if the animation must loop (default is false) */
  25603. loopAnimation: boolean;
  25604. /** defines a callback to call when animation ends if it is not looping */
  25605. onAnimationEnd?: (() => void) | null | undefined;
  25606. /** defines a callback to call when animation loops */
  25607. onAnimationLoop?: (() => void) | null | undefined;
  25608. /** defines whether the animation should be evaluated additively */
  25609. isAdditive: boolean;
  25610. private _localDelayOffset;
  25611. private _pausedDelay;
  25612. private _runtimeAnimations;
  25613. private _paused;
  25614. private _scene;
  25615. private _speedRatio;
  25616. private _weight;
  25617. private _syncRoot;
  25618. /**
  25619. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25620. * This will only apply for non looping animation (default is true)
  25621. */
  25622. disposeOnEnd: boolean;
  25623. /**
  25624. * Gets a boolean indicating if the animation has started
  25625. */
  25626. animationStarted: boolean;
  25627. /**
  25628. * Observer raised when the animation ends
  25629. */
  25630. onAnimationEndObservable: Observable<Animatable>;
  25631. /**
  25632. * Observer raised when the animation loops
  25633. */
  25634. onAnimationLoopObservable: Observable<Animatable>;
  25635. /**
  25636. * Gets the root Animatable used to synchronize and normalize animations
  25637. */
  25638. get syncRoot(): Nullable<Animatable>;
  25639. /**
  25640. * Gets the current frame of the first RuntimeAnimation
  25641. * Used to synchronize Animatables
  25642. */
  25643. get masterFrame(): number;
  25644. /**
  25645. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25646. */
  25647. get weight(): number;
  25648. set weight(value: number);
  25649. /**
  25650. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25651. */
  25652. get speedRatio(): number;
  25653. set speedRatio(value: number);
  25654. /**
  25655. * Creates a new Animatable
  25656. * @param scene defines the hosting scene
  25657. * @param target defines the target object
  25658. * @param fromFrame defines the starting frame number (default is 0)
  25659. * @param toFrame defines the ending frame number (default is 100)
  25660. * @param loopAnimation defines if the animation must loop (default is false)
  25661. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25662. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25663. * @param animations defines a group of animation to add to the new Animatable
  25664. * @param onAnimationLoop defines a callback to call when animation loops
  25665. * @param isAdditive defines whether the animation should be evaluated additively
  25666. */
  25667. constructor(scene: Scene,
  25668. /** defines the target object */
  25669. target: any,
  25670. /** defines the starting frame number (default is 0) */
  25671. fromFrame?: number,
  25672. /** defines the ending frame number (default is 100) */
  25673. toFrame?: number,
  25674. /** defines if the animation must loop (default is false) */
  25675. loopAnimation?: boolean, speedRatio?: number,
  25676. /** defines a callback to call when animation ends if it is not looping */
  25677. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25678. /** defines a callback to call when animation loops */
  25679. onAnimationLoop?: (() => void) | null | undefined,
  25680. /** defines whether the animation should be evaluated additively */
  25681. isAdditive?: boolean);
  25682. /**
  25683. * Synchronize and normalize current Animatable with a source Animatable
  25684. * This is useful when using animation weights and when animations are not of the same length
  25685. * @param root defines the root Animatable to synchronize with
  25686. * @returns the current Animatable
  25687. */
  25688. syncWith(root: Animatable): Animatable;
  25689. /**
  25690. * Gets the list of runtime animations
  25691. * @returns an array of RuntimeAnimation
  25692. */
  25693. getAnimations(): RuntimeAnimation[];
  25694. /**
  25695. * Adds more animations to the current animatable
  25696. * @param target defines the target of the animations
  25697. * @param animations defines the new animations to add
  25698. */
  25699. appendAnimations(target: any, animations: Animation[]): void;
  25700. /**
  25701. * Gets the source animation for a specific property
  25702. * @param property defines the propertyu to look for
  25703. * @returns null or the source animation for the given property
  25704. */
  25705. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25706. /**
  25707. * Gets the runtime animation for a specific property
  25708. * @param property defines the propertyu to look for
  25709. * @returns null or the runtime animation for the given property
  25710. */
  25711. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25712. /**
  25713. * Resets the animatable to its original state
  25714. */
  25715. reset(): void;
  25716. /**
  25717. * Allows the animatable to blend with current running animations
  25718. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25719. * @param blendingSpeed defines the blending speed to use
  25720. */
  25721. enableBlending(blendingSpeed: number): void;
  25722. /**
  25723. * Disable animation blending
  25724. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25725. */
  25726. disableBlending(): void;
  25727. /**
  25728. * Jump directly to a given frame
  25729. * @param frame defines the frame to jump to
  25730. */
  25731. goToFrame(frame: number): void;
  25732. /**
  25733. * Pause the animation
  25734. */
  25735. pause(): void;
  25736. /**
  25737. * Restart the animation
  25738. */
  25739. restart(): void;
  25740. private _raiseOnAnimationEnd;
  25741. /**
  25742. * Stop and delete the current animation
  25743. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25744. * @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)
  25745. */
  25746. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25747. /**
  25748. * Wait asynchronously for the animation to end
  25749. * @returns a promise which will be fullfilled when the animation ends
  25750. */
  25751. waitAsync(): Promise<Animatable>;
  25752. /** @hidden */
  25753. _animate(delay: number): boolean;
  25754. }
  25755. interface Scene {
  25756. /** @hidden */
  25757. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25758. /** @hidden */
  25759. _processLateAnimationBindingsForMatrices(holder: {
  25760. totalWeight: number;
  25761. totalAdditiveWeight: number;
  25762. animations: RuntimeAnimation[];
  25763. additiveAnimations: RuntimeAnimation[];
  25764. originalValue: Matrix;
  25765. }): any;
  25766. /** @hidden */
  25767. _processLateAnimationBindingsForQuaternions(holder: {
  25768. totalWeight: number;
  25769. totalAdditiveWeight: number;
  25770. animations: RuntimeAnimation[];
  25771. additiveAnimations: RuntimeAnimation[];
  25772. originalValue: Quaternion;
  25773. }, refQuaternion: Quaternion): Quaternion;
  25774. /** @hidden */
  25775. _processLateAnimationBindings(): void;
  25776. /**
  25777. * Will start the animation sequence of a given target
  25778. * @param target defines the target
  25779. * @param from defines from which frame should animation start
  25780. * @param to defines until which frame should animation run.
  25781. * @param weight defines the weight to apply to the animation (1.0 by default)
  25782. * @param loop defines if the animation loops
  25783. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25784. * @param onAnimationEnd defines the function to be executed when the animation ends
  25785. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25786. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25787. * @param onAnimationLoop defines the callback to call when an animation loops
  25788. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25789. * @returns the animatable object created for this animation
  25790. */
  25791. 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;
  25792. /**
  25793. * Will start the animation sequence of a given target
  25794. * @param target defines the target
  25795. * @param from defines from which frame should animation start
  25796. * @param to defines until which frame should animation run.
  25797. * @param loop defines if the animation loops
  25798. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25799. * @param onAnimationEnd defines the function to be executed when the animation ends
  25800. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25801. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25802. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25803. * @param onAnimationLoop defines the callback to call when an animation loops
  25804. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25805. * @returns the animatable object created for this animation
  25806. */
  25807. 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;
  25808. /**
  25809. * Will start the animation sequence of a given target and its hierarchy
  25810. * @param target defines the target
  25811. * @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.
  25812. * @param from defines from which frame should animation start
  25813. * @param to defines until which frame should animation run.
  25814. * @param loop defines if the animation loops
  25815. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25816. * @param onAnimationEnd defines the function to be executed when the animation ends
  25817. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25818. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25819. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25820. * @param onAnimationLoop defines the callback to call when an animation loops
  25821. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25822. * @returns the list of created animatables
  25823. */
  25824. 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[];
  25825. /**
  25826. * Begin a new animation on a given node
  25827. * @param target defines the target where the animation will take place
  25828. * @param animations defines the list of animations to start
  25829. * @param from defines the initial value
  25830. * @param to defines the final value
  25831. * @param loop defines if you want animation to loop (off by default)
  25832. * @param speedRatio defines the speed ratio to apply to all animations
  25833. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25834. * @param onAnimationLoop defines the callback to call when an animation loops
  25835. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25836. * @returns the list of created animatables
  25837. */
  25838. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25839. /**
  25840. * Begin a new animation on a given node and its hierarchy
  25841. * @param target defines the root node where the animation will take place
  25842. * @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.
  25843. * @param animations defines the list of animations to start
  25844. * @param from defines the initial value
  25845. * @param to defines the final value
  25846. * @param loop defines if you want animation to loop (off by default)
  25847. * @param speedRatio defines the speed ratio to apply to all animations
  25848. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25849. * @param onAnimationLoop defines the callback to call when an animation loops
  25850. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25851. * @returns the list of animatables created for all nodes
  25852. */
  25853. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25854. /**
  25855. * Gets the animatable associated with a specific target
  25856. * @param target defines the target of the animatable
  25857. * @returns the required animatable if found
  25858. */
  25859. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25860. /**
  25861. * Gets all animatables associated with a given target
  25862. * @param target defines the target to look animatables for
  25863. * @returns an array of Animatables
  25864. */
  25865. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25866. /**
  25867. * Stops and removes all animations that have been applied to the scene
  25868. */
  25869. stopAllAnimations(): void;
  25870. /**
  25871. * Gets the current delta time used by animation engine
  25872. */
  25873. deltaTime: number;
  25874. }
  25875. interface Bone {
  25876. /**
  25877. * Copy an animation range from another bone
  25878. * @param source defines the source bone
  25879. * @param rangeName defines the range name to copy
  25880. * @param frameOffset defines the frame offset
  25881. * @param rescaleAsRequired defines if rescaling must be applied if required
  25882. * @param skelDimensionsRatio defines the scaling ratio
  25883. * @returns true if operation was successful
  25884. */
  25885. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25886. }
  25887. }
  25888. declare module BABYLON {
  25889. /**
  25890. * Class used to override all child animations of a given target
  25891. */
  25892. export class AnimationPropertiesOverride {
  25893. /**
  25894. * Gets or sets a value indicating if animation blending must be used
  25895. */
  25896. enableBlending: boolean;
  25897. /**
  25898. * Gets or sets the blending speed to use when enableBlending is true
  25899. */
  25900. blendingSpeed: number;
  25901. /**
  25902. * Gets or sets the default loop mode to use
  25903. */
  25904. loopMode: number;
  25905. }
  25906. }
  25907. declare module BABYLON {
  25908. /**
  25909. * Class used to handle skinning animations
  25910. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25911. */
  25912. export class Skeleton implements IAnimatable {
  25913. /** defines the skeleton name */
  25914. name: string;
  25915. /** defines the skeleton Id */
  25916. id: string;
  25917. /**
  25918. * Defines the list of child bones
  25919. */
  25920. bones: Bone[];
  25921. /**
  25922. * Defines an estimate of the dimension of the skeleton at rest
  25923. */
  25924. dimensionsAtRest: Vector3;
  25925. /**
  25926. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25927. */
  25928. needInitialSkinMatrix: boolean;
  25929. /**
  25930. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25931. */
  25932. overrideMesh: Nullable<AbstractMesh>;
  25933. /**
  25934. * Gets the list of animations attached to this skeleton
  25935. */
  25936. animations: Array<Animation>;
  25937. private _scene;
  25938. private _isDirty;
  25939. private _transformMatrices;
  25940. private _transformMatrixTexture;
  25941. private _meshesWithPoseMatrix;
  25942. private _animatables;
  25943. private _identity;
  25944. private _synchronizedWithMesh;
  25945. private _ranges;
  25946. private _lastAbsoluteTransformsUpdateId;
  25947. private _canUseTextureForBones;
  25948. private _uniqueId;
  25949. /** @hidden */
  25950. _numBonesWithLinkedTransformNode: number;
  25951. /** @hidden */
  25952. _hasWaitingData: Nullable<boolean>;
  25953. /** @hidden */
  25954. _waitingOverrideMeshId: Nullable<string>;
  25955. /**
  25956. * Specifies if the skeleton should be serialized
  25957. */
  25958. doNotSerialize: boolean;
  25959. private _useTextureToStoreBoneMatrices;
  25960. /**
  25961. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25962. * Please note that this option is not available if the hardware does not support it
  25963. */
  25964. get useTextureToStoreBoneMatrices(): boolean;
  25965. set useTextureToStoreBoneMatrices(value: boolean);
  25966. private _animationPropertiesOverride;
  25967. /**
  25968. * Gets or sets the animation properties override
  25969. */
  25970. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25971. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25972. /**
  25973. * List of inspectable custom properties (used by the Inspector)
  25974. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25975. */
  25976. inspectableCustomProperties: IInspectable[];
  25977. /**
  25978. * An observable triggered before computing the skeleton's matrices
  25979. */
  25980. onBeforeComputeObservable: Observable<Skeleton>;
  25981. /**
  25982. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25983. */
  25984. get isUsingTextureForMatrices(): boolean;
  25985. /**
  25986. * Gets the unique ID of this skeleton
  25987. */
  25988. get uniqueId(): number;
  25989. /**
  25990. * Creates a new skeleton
  25991. * @param name defines the skeleton name
  25992. * @param id defines the skeleton Id
  25993. * @param scene defines the hosting scene
  25994. */
  25995. constructor(
  25996. /** defines the skeleton name */
  25997. name: string,
  25998. /** defines the skeleton Id */
  25999. id: string, scene: Scene);
  26000. /**
  26001. * Gets the current object class name.
  26002. * @return the class name
  26003. */
  26004. getClassName(): string;
  26005. /**
  26006. * Returns an array containing the root bones
  26007. * @returns an array containing the root bones
  26008. */
  26009. getChildren(): Array<Bone>;
  26010. /**
  26011. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26012. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26013. * @returns a Float32Array containing matrices data
  26014. */
  26015. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26016. /**
  26017. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26018. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26019. * @returns a raw texture containing the data
  26020. */
  26021. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26022. /**
  26023. * Gets the current hosting scene
  26024. * @returns a scene object
  26025. */
  26026. getScene(): Scene;
  26027. /**
  26028. * Gets a string representing the current skeleton data
  26029. * @param fullDetails defines a boolean indicating if we want a verbose version
  26030. * @returns a string representing the current skeleton data
  26031. */
  26032. toString(fullDetails?: boolean): string;
  26033. /**
  26034. * Get bone's index searching by name
  26035. * @param name defines bone's name to search for
  26036. * @return the indice of the bone. Returns -1 if not found
  26037. */
  26038. getBoneIndexByName(name: string): number;
  26039. /**
  26040. * Creater a new animation range
  26041. * @param name defines the name of the range
  26042. * @param from defines the start key
  26043. * @param to defines the end key
  26044. */
  26045. createAnimationRange(name: string, from: number, to: number): void;
  26046. /**
  26047. * Delete a specific animation range
  26048. * @param name defines the name of the range
  26049. * @param deleteFrames defines if frames must be removed as well
  26050. */
  26051. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26052. /**
  26053. * Gets a specific animation range
  26054. * @param name defines the name of the range to look for
  26055. * @returns the requested animation range or null if not found
  26056. */
  26057. getAnimationRange(name: string): Nullable<AnimationRange>;
  26058. /**
  26059. * Gets the list of all animation ranges defined on this skeleton
  26060. * @returns an array
  26061. */
  26062. getAnimationRanges(): Nullable<AnimationRange>[];
  26063. /**
  26064. * Copy animation range from a source skeleton.
  26065. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26066. * @param source defines the source skeleton
  26067. * @param name defines the name of the range to copy
  26068. * @param rescaleAsRequired defines if rescaling must be applied if required
  26069. * @returns true if operation was successful
  26070. */
  26071. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26072. /**
  26073. * Forces the skeleton to go to rest pose
  26074. */
  26075. returnToRest(): void;
  26076. private _getHighestAnimationFrame;
  26077. /**
  26078. * Begin a specific animation range
  26079. * @param name defines the name of the range to start
  26080. * @param loop defines if looping must be turned on (false by default)
  26081. * @param speedRatio defines the speed ratio to apply (1 by default)
  26082. * @param onAnimationEnd defines a callback which will be called when animation will end
  26083. * @returns a new animatable
  26084. */
  26085. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26086. /**
  26087. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26088. * @param skeleton defines the Skeleton containing the animation range to convert
  26089. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26090. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26091. * @returns the original skeleton
  26092. */
  26093. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26094. /** @hidden */
  26095. _markAsDirty(): void;
  26096. /** @hidden */
  26097. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26098. /** @hidden */
  26099. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26100. private _computeTransformMatrices;
  26101. /**
  26102. * Build all resources required to render a skeleton
  26103. */
  26104. prepare(): void;
  26105. /**
  26106. * Gets the list of animatables currently running for this skeleton
  26107. * @returns an array of animatables
  26108. */
  26109. getAnimatables(): IAnimatable[];
  26110. /**
  26111. * Clone the current skeleton
  26112. * @param name defines the name of the new skeleton
  26113. * @param id defines the id of the new skeleton
  26114. * @returns the new skeleton
  26115. */
  26116. clone(name: string, id?: string): Skeleton;
  26117. /**
  26118. * Enable animation blending for this skeleton
  26119. * @param blendingSpeed defines the blending speed to apply
  26120. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26121. */
  26122. enableBlending(blendingSpeed?: number): void;
  26123. /**
  26124. * Releases all resources associated with the current skeleton
  26125. */
  26126. dispose(): void;
  26127. /**
  26128. * Serialize the skeleton in a JSON object
  26129. * @returns a JSON object
  26130. */
  26131. serialize(): any;
  26132. /**
  26133. * Creates a new skeleton from serialized data
  26134. * @param parsedSkeleton defines the serialized data
  26135. * @param scene defines the hosting scene
  26136. * @returns a new skeleton
  26137. */
  26138. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26139. /**
  26140. * Compute all node absolute transforms
  26141. * @param forceUpdate defines if computation must be done even if cache is up to date
  26142. */
  26143. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26144. /**
  26145. * Gets the root pose matrix
  26146. * @returns a matrix
  26147. */
  26148. getPoseMatrix(): Nullable<Matrix>;
  26149. /**
  26150. * Sorts bones per internal index
  26151. */
  26152. sortBones(): void;
  26153. private _sortBones;
  26154. /**
  26155. * Set the current local matrix as the restPose for all bones in the skeleton.
  26156. */
  26157. setCurrentPoseAsRest(): void;
  26158. }
  26159. }
  26160. declare module BABYLON {
  26161. /**
  26162. * Class used to store bone information
  26163. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26164. */
  26165. export class Bone extends Node {
  26166. /**
  26167. * defines the bone name
  26168. */
  26169. name: string;
  26170. private static _tmpVecs;
  26171. private static _tmpQuat;
  26172. private static _tmpMats;
  26173. /**
  26174. * Gets the list of child bones
  26175. */
  26176. children: Bone[];
  26177. /** Gets the animations associated with this bone */
  26178. animations: Animation[];
  26179. /**
  26180. * Gets or sets bone length
  26181. */
  26182. length: number;
  26183. /**
  26184. * @hidden Internal only
  26185. * Set this value to map this bone to a different index in the transform matrices
  26186. * Set this value to -1 to exclude the bone from the transform matrices
  26187. */
  26188. _index: Nullable<number>;
  26189. private _skeleton;
  26190. private _localMatrix;
  26191. private _restPose;
  26192. private _bindPose;
  26193. private _baseMatrix;
  26194. private _absoluteTransform;
  26195. private _invertedAbsoluteTransform;
  26196. private _parent;
  26197. private _scalingDeterminant;
  26198. private _worldTransform;
  26199. private _localScaling;
  26200. private _localRotation;
  26201. private _localPosition;
  26202. private _needToDecompose;
  26203. private _needToCompose;
  26204. /** @hidden */
  26205. _linkedTransformNode: Nullable<TransformNode>;
  26206. /** @hidden */
  26207. _waitingTransformNodeId: Nullable<string>;
  26208. /** @hidden */
  26209. get _matrix(): Matrix;
  26210. /** @hidden */
  26211. set _matrix(value: Matrix);
  26212. /**
  26213. * Create a new bone
  26214. * @param name defines the bone name
  26215. * @param skeleton defines the parent skeleton
  26216. * @param parentBone defines the parent (can be null if the bone is the root)
  26217. * @param localMatrix defines the local matrix
  26218. * @param restPose defines the rest pose matrix
  26219. * @param baseMatrix defines the base matrix
  26220. * @param index defines index of the bone in the hiearchy
  26221. */
  26222. constructor(
  26223. /**
  26224. * defines the bone name
  26225. */
  26226. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26227. /**
  26228. * Gets the current object class name.
  26229. * @return the class name
  26230. */
  26231. getClassName(): string;
  26232. /**
  26233. * Gets the parent skeleton
  26234. * @returns a skeleton
  26235. */
  26236. getSkeleton(): Skeleton;
  26237. /**
  26238. * Gets parent bone
  26239. * @returns a bone or null if the bone is the root of the bone hierarchy
  26240. */
  26241. getParent(): Nullable<Bone>;
  26242. /**
  26243. * Returns an array containing the root bones
  26244. * @returns an array containing the root bones
  26245. */
  26246. getChildren(): Array<Bone>;
  26247. /**
  26248. * Gets the node index in matrix array generated for rendering
  26249. * @returns the node index
  26250. */
  26251. getIndex(): number;
  26252. /**
  26253. * Sets the parent bone
  26254. * @param parent defines the parent (can be null if the bone is the root)
  26255. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26256. */
  26257. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26258. /**
  26259. * Gets the local matrix
  26260. * @returns a matrix
  26261. */
  26262. getLocalMatrix(): Matrix;
  26263. /**
  26264. * Gets the base matrix (initial matrix which remains unchanged)
  26265. * @returns a matrix
  26266. */
  26267. getBaseMatrix(): Matrix;
  26268. /**
  26269. * Gets the rest pose matrix
  26270. * @returns a matrix
  26271. */
  26272. getRestPose(): Matrix;
  26273. /**
  26274. * Sets the rest pose matrix
  26275. * @param matrix the local-space rest pose to set for this bone
  26276. */
  26277. setRestPose(matrix: Matrix): void;
  26278. /**
  26279. * Gets the bind pose matrix
  26280. * @returns the bind pose matrix
  26281. */
  26282. getBindPose(): Matrix;
  26283. /**
  26284. * Sets the bind pose matrix
  26285. * @param matrix the local-space bind pose to set for this bone
  26286. */
  26287. setBindPose(matrix: Matrix): void;
  26288. /**
  26289. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26290. */
  26291. getWorldMatrix(): Matrix;
  26292. /**
  26293. * Sets the local matrix to rest pose matrix
  26294. */
  26295. returnToRest(): void;
  26296. /**
  26297. * Gets the inverse of the absolute transform matrix.
  26298. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26299. * @returns a matrix
  26300. */
  26301. getInvertedAbsoluteTransform(): Matrix;
  26302. /**
  26303. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26304. * @returns a matrix
  26305. */
  26306. getAbsoluteTransform(): Matrix;
  26307. /**
  26308. * Links with the given transform node.
  26309. * The local matrix of this bone is copied from the transform node every frame.
  26310. * @param transformNode defines the transform node to link to
  26311. */
  26312. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26313. /**
  26314. * Gets the node used to drive the bone's transformation
  26315. * @returns a transform node or null
  26316. */
  26317. getTransformNode(): Nullable<TransformNode>;
  26318. /** Gets or sets current position (in local space) */
  26319. get position(): Vector3;
  26320. set position(newPosition: Vector3);
  26321. /** Gets or sets current rotation (in local space) */
  26322. get rotation(): Vector3;
  26323. set rotation(newRotation: Vector3);
  26324. /** Gets or sets current rotation quaternion (in local space) */
  26325. get rotationQuaternion(): Quaternion;
  26326. set rotationQuaternion(newRotation: Quaternion);
  26327. /** Gets or sets current scaling (in local space) */
  26328. get scaling(): Vector3;
  26329. set scaling(newScaling: Vector3);
  26330. /**
  26331. * Gets the animation properties override
  26332. */
  26333. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26334. private _decompose;
  26335. private _compose;
  26336. /**
  26337. * Update the base and local matrices
  26338. * @param matrix defines the new base or local matrix
  26339. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26340. * @param updateLocalMatrix defines if the local matrix should be updated
  26341. */
  26342. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26343. /** @hidden */
  26344. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26345. /**
  26346. * Flag the bone as dirty (Forcing it to update everything)
  26347. */
  26348. markAsDirty(): void;
  26349. /** @hidden */
  26350. _markAsDirtyAndCompose(): void;
  26351. private _markAsDirtyAndDecompose;
  26352. /**
  26353. * Translate the bone in local or world space
  26354. * @param vec The amount to translate the bone
  26355. * @param space The space that the translation is in
  26356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26357. */
  26358. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26359. /**
  26360. * Set the postion of the bone in local or world space
  26361. * @param position The position to set the bone
  26362. * @param space The space that the position is in
  26363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26364. */
  26365. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26366. /**
  26367. * Set the absolute position of the bone (world space)
  26368. * @param position The position to set the bone
  26369. * @param mesh The mesh that this bone is attached to
  26370. */
  26371. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26372. /**
  26373. * Scale the bone on the x, y and z axes (in local space)
  26374. * @param x The amount to scale the bone on the x axis
  26375. * @param y The amount to scale the bone on the y axis
  26376. * @param z The amount to scale the bone on the z axis
  26377. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26378. */
  26379. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26380. /**
  26381. * Set the bone scaling in local space
  26382. * @param scale defines the scaling vector
  26383. */
  26384. setScale(scale: Vector3): void;
  26385. /**
  26386. * Gets the current scaling in local space
  26387. * @returns the current scaling vector
  26388. */
  26389. getScale(): Vector3;
  26390. /**
  26391. * Gets the current scaling in local space and stores it in a target vector
  26392. * @param result defines the target vector
  26393. */
  26394. getScaleToRef(result: Vector3): void;
  26395. /**
  26396. * Set the yaw, pitch, and roll of the bone in local or world space
  26397. * @param yaw The rotation of the bone on the y axis
  26398. * @param pitch The rotation of the bone on the x axis
  26399. * @param roll The rotation of the bone on the z axis
  26400. * @param space The space that the axes of rotation are in
  26401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26402. */
  26403. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26404. /**
  26405. * Add a rotation to the bone on an axis in local or world space
  26406. * @param axis The axis to rotate the bone on
  26407. * @param amount The amount to rotate the bone
  26408. * @param space The space that the axis is in
  26409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26410. */
  26411. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26412. /**
  26413. * Set the rotation of the bone to a particular axis angle in local or world space
  26414. * @param axis The axis to rotate the bone on
  26415. * @param angle The angle that the bone should be rotated to
  26416. * @param space The space that the axis is in
  26417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26418. */
  26419. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26420. /**
  26421. * Set the euler rotation of the bone in local or world space
  26422. * @param rotation The euler rotation that the bone should be set to
  26423. * @param space The space that the rotation is in
  26424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26425. */
  26426. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26427. /**
  26428. * Set the quaternion rotation of the bone in local or world space
  26429. * @param quat The quaternion rotation that the bone should be set to
  26430. * @param space The space that the rotation is in
  26431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26432. */
  26433. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26434. /**
  26435. * Set the rotation matrix of the bone in local or world space
  26436. * @param rotMat The rotation matrix that the bone should be set to
  26437. * @param space The space that the rotation is in
  26438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26439. */
  26440. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26441. private _rotateWithMatrix;
  26442. private _getNegativeRotationToRef;
  26443. /**
  26444. * Get the position of the bone in local or world space
  26445. * @param space The space that the returned position is in
  26446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26447. * @returns The position of the bone
  26448. */
  26449. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26450. /**
  26451. * Copy the position of the bone to a vector3 in local or world space
  26452. * @param space The space that the returned position is in
  26453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26454. * @param result The vector3 to copy the position to
  26455. */
  26456. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26457. /**
  26458. * Get the absolute position of the bone (world space)
  26459. * @param mesh The mesh that this bone is attached to
  26460. * @returns The absolute position of the bone
  26461. */
  26462. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26463. /**
  26464. * Copy the absolute position of the bone (world space) to the result param
  26465. * @param mesh The mesh that this bone is attached to
  26466. * @param result The vector3 to copy the absolute position to
  26467. */
  26468. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26469. /**
  26470. * Compute the absolute transforms of this bone and its children
  26471. */
  26472. computeAbsoluteTransforms(): void;
  26473. /**
  26474. * Get the world direction from an axis that is in the local space of the bone
  26475. * @param localAxis The local direction that is used to compute the world direction
  26476. * @param mesh The mesh that this bone is attached to
  26477. * @returns The world direction
  26478. */
  26479. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26480. /**
  26481. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26482. * @param localAxis The local direction that is used to compute the world direction
  26483. * @param mesh The mesh that this bone is attached to
  26484. * @param result The vector3 that the world direction will be copied to
  26485. */
  26486. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26487. /**
  26488. * Get the euler rotation of the bone in local or world space
  26489. * @param space The space that the rotation should be in
  26490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26491. * @returns The euler rotation
  26492. */
  26493. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26494. /**
  26495. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26496. * @param space The space that the rotation should be in
  26497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26498. * @param result The vector3 that the rotation should be copied to
  26499. */
  26500. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26501. /**
  26502. * Get the quaternion rotation of the bone in either local or world space
  26503. * @param space The space that the rotation should be in
  26504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26505. * @returns The quaternion rotation
  26506. */
  26507. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26508. /**
  26509. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26510. * @param space The space that the rotation should be in
  26511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26512. * @param result The quaternion that the rotation should be copied to
  26513. */
  26514. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26515. /**
  26516. * Get the rotation matrix of the bone in local or world space
  26517. * @param space The space that the rotation should be in
  26518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26519. * @returns The rotation matrix
  26520. */
  26521. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26522. /**
  26523. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26524. * @param space The space that the rotation should be in
  26525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26526. * @param result The quaternion that the rotation should be copied to
  26527. */
  26528. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26529. /**
  26530. * Get the world position of a point that is in the local space of the bone
  26531. * @param position The local position
  26532. * @param mesh The mesh that this bone is attached to
  26533. * @returns The world position
  26534. */
  26535. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26536. /**
  26537. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26538. * @param position The local position
  26539. * @param mesh The mesh that this bone is attached to
  26540. * @param result The vector3 that the world position should be copied to
  26541. */
  26542. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26543. /**
  26544. * Get the local position of a point that is in world space
  26545. * @param position The world position
  26546. * @param mesh The mesh that this bone is attached to
  26547. * @returns The local position
  26548. */
  26549. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26550. /**
  26551. * Get the local position of a point that is in world space and copy it to the result param
  26552. * @param position The world position
  26553. * @param mesh The mesh that this bone is attached to
  26554. * @param result The vector3 that the local position should be copied to
  26555. */
  26556. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26557. /**
  26558. * Set the current local matrix as the restPose for this bone.
  26559. */
  26560. setCurrentPoseAsRest(): void;
  26561. }
  26562. }
  26563. declare module BABYLON {
  26564. /**
  26565. * 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.
  26566. * @see https://doc.babylonjs.com/how_to/transformnode
  26567. */
  26568. export class TransformNode extends Node {
  26569. /**
  26570. * Object will not rotate to face the camera
  26571. */
  26572. static BILLBOARDMODE_NONE: number;
  26573. /**
  26574. * Object will rotate to face the camera but only on the x axis
  26575. */
  26576. static BILLBOARDMODE_X: number;
  26577. /**
  26578. * Object will rotate to face the camera but only on the y axis
  26579. */
  26580. static BILLBOARDMODE_Y: number;
  26581. /**
  26582. * Object will rotate to face the camera but only on the z axis
  26583. */
  26584. static BILLBOARDMODE_Z: number;
  26585. /**
  26586. * Object will rotate to face the camera
  26587. */
  26588. static BILLBOARDMODE_ALL: number;
  26589. /**
  26590. * Object will rotate to face the camera's position instead of orientation
  26591. */
  26592. static BILLBOARDMODE_USE_POSITION: number;
  26593. private static _TmpRotation;
  26594. private static _TmpScaling;
  26595. private static _TmpTranslation;
  26596. private _forward;
  26597. private _forwardInverted;
  26598. private _up;
  26599. private _right;
  26600. private _rightInverted;
  26601. private _position;
  26602. private _rotation;
  26603. private _rotationQuaternion;
  26604. protected _scaling: Vector3;
  26605. protected _isDirty: boolean;
  26606. private _transformToBoneReferal;
  26607. private _isAbsoluteSynced;
  26608. private _billboardMode;
  26609. /**
  26610. * Gets or sets the billboard mode. Default is 0.
  26611. *
  26612. * | Value | Type | Description |
  26613. * | --- | --- | --- |
  26614. * | 0 | BILLBOARDMODE_NONE | |
  26615. * | 1 | BILLBOARDMODE_X | |
  26616. * | 2 | BILLBOARDMODE_Y | |
  26617. * | 4 | BILLBOARDMODE_Z | |
  26618. * | 7 | BILLBOARDMODE_ALL | |
  26619. *
  26620. */
  26621. get billboardMode(): number;
  26622. set billboardMode(value: number);
  26623. private _preserveParentRotationForBillboard;
  26624. /**
  26625. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26626. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26627. */
  26628. get preserveParentRotationForBillboard(): boolean;
  26629. set preserveParentRotationForBillboard(value: boolean);
  26630. /**
  26631. * 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
  26632. */
  26633. scalingDeterminant: number;
  26634. private _infiniteDistance;
  26635. /**
  26636. * Gets or sets the distance of the object to max, often used by skybox
  26637. */
  26638. get infiniteDistance(): boolean;
  26639. set infiniteDistance(value: boolean);
  26640. /**
  26641. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26642. * By default the system will update normals to compensate
  26643. */
  26644. ignoreNonUniformScaling: boolean;
  26645. /**
  26646. * 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
  26647. */
  26648. reIntegrateRotationIntoRotationQuaternion: boolean;
  26649. /** @hidden */
  26650. _poseMatrix: Nullable<Matrix>;
  26651. /** @hidden */
  26652. _localMatrix: Matrix;
  26653. private _usePivotMatrix;
  26654. private _absolutePosition;
  26655. private _absoluteScaling;
  26656. private _absoluteRotationQuaternion;
  26657. private _pivotMatrix;
  26658. private _pivotMatrixInverse;
  26659. /** @hidden */
  26660. _postMultiplyPivotMatrix: boolean;
  26661. protected _isWorldMatrixFrozen: boolean;
  26662. /** @hidden */
  26663. _indexInSceneTransformNodesArray: number;
  26664. /**
  26665. * An event triggered after the world matrix is updated
  26666. */
  26667. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26668. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26669. /**
  26670. * Gets a string identifying the name of the class
  26671. * @returns "TransformNode" string
  26672. */
  26673. getClassName(): string;
  26674. /**
  26675. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26676. */
  26677. get position(): Vector3;
  26678. set position(newPosition: Vector3);
  26679. /**
  26680. * 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)).
  26681. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26682. */
  26683. get rotation(): Vector3;
  26684. set rotation(newRotation: Vector3);
  26685. /**
  26686. * 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)).
  26687. */
  26688. get scaling(): Vector3;
  26689. set scaling(newScaling: Vector3);
  26690. /**
  26691. * 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).
  26692. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26693. */
  26694. get rotationQuaternion(): Nullable<Quaternion>;
  26695. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26696. /**
  26697. * The forward direction of that transform in world space.
  26698. */
  26699. get forward(): Vector3;
  26700. /**
  26701. * The up direction of that transform in world space.
  26702. */
  26703. get up(): Vector3;
  26704. /**
  26705. * The right direction of that transform in world space.
  26706. */
  26707. get right(): Vector3;
  26708. /**
  26709. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26710. * @param matrix the matrix to copy the pose from
  26711. * @returns this TransformNode.
  26712. */
  26713. updatePoseMatrix(matrix: Matrix): TransformNode;
  26714. /**
  26715. * Returns the mesh Pose matrix.
  26716. * @returns the pose matrix
  26717. */
  26718. getPoseMatrix(): Matrix;
  26719. /** @hidden */
  26720. _isSynchronized(): boolean;
  26721. /** @hidden */
  26722. _initCache(): void;
  26723. /**
  26724. * Flag the transform node as dirty (Forcing it to update everything)
  26725. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26726. * @returns this transform node
  26727. */
  26728. markAsDirty(property: string): TransformNode;
  26729. /**
  26730. * Returns the current mesh absolute position.
  26731. * Returns a Vector3.
  26732. */
  26733. get absolutePosition(): Vector3;
  26734. /**
  26735. * Returns the current mesh absolute scaling.
  26736. * Returns a Vector3.
  26737. */
  26738. get absoluteScaling(): Vector3;
  26739. /**
  26740. * Returns the current mesh absolute rotation.
  26741. * Returns a Quaternion.
  26742. */
  26743. get absoluteRotationQuaternion(): Quaternion;
  26744. /**
  26745. * Sets a new matrix to apply before all other transformation
  26746. * @param matrix defines the transform matrix
  26747. * @returns the current TransformNode
  26748. */
  26749. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26750. /**
  26751. * Sets a new pivot matrix to the current node
  26752. * @param matrix defines the new pivot matrix to use
  26753. * @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
  26754. * @returns the current TransformNode
  26755. */
  26756. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26757. /**
  26758. * Returns the mesh pivot matrix.
  26759. * Default : Identity.
  26760. * @returns the matrix
  26761. */
  26762. getPivotMatrix(): Matrix;
  26763. /**
  26764. * Instantiate (when possible) or clone that node with its hierarchy
  26765. * @param newParent defines the new parent to use for the instance (or clone)
  26766. * @param options defines options to configure how copy is done
  26767. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26768. * @returns an instance (or a clone) of the current node with its hiearchy
  26769. */
  26770. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26771. doNotInstantiate: boolean;
  26772. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26773. /**
  26774. * Prevents the World matrix to be computed any longer
  26775. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26776. * @returns the TransformNode.
  26777. */
  26778. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26779. /**
  26780. * Allows back the World matrix computation.
  26781. * @returns the TransformNode.
  26782. */
  26783. unfreezeWorldMatrix(): this;
  26784. /**
  26785. * True if the World matrix has been frozen.
  26786. */
  26787. get isWorldMatrixFrozen(): boolean;
  26788. /**
  26789. * Retuns the mesh absolute position in the World.
  26790. * @returns a Vector3.
  26791. */
  26792. getAbsolutePosition(): Vector3;
  26793. /**
  26794. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26795. * @param absolutePosition the absolute position to set
  26796. * @returns the TransformNode.
  26797. */
  26798. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26799. /**
  26800. * Sets the mesh position in its local space.
  26801. * @param vector3 the position to set in localspace
  26802. * @returns the TransformNode.
  26803. */
  26804. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26805. /**
  26806. * Returns the mesh position in the local space from the current World matrix values.
  26807. * @returns a new Vector3.
  26808. */
  26809. getPositionExpressedInLocalSpace(): Vector3;
  26810. /**
  26811. * Translates the mesh along the passed Vector3 in its local space.
  26812. * @param vector3 the distance to translate in localspace
  26813. * @returns the TransformNode.
  26814. */
  26815. locallyTranslate(vector3: Vector3): TransformNode;
  26816. private static _lookAtVectorCache;
  26817. /**
  26818. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26819. * @param targetPoint the position (must be in same space as current mesh) to look at
  26820. * @param yawCor optional yaw (y-axis) correction in radians
  26821. * @param pitchCor optional pitch (x-axis) correction in radians
  26822. * @param rollCor optional roll (z-axis) correction in radians
  26823. * @param space the choosen space of the target
  26824. * @returns the TransformNode.
  26825. */
  26826. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26827. /**
  26828. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26829. * This Vector3 is expressed in the World space.
  26830. * @param localAxis axis to rotate
  26831. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26832. */
  26833. getDirection(localAxis: Vector3): Vector3;
  26834. /**
  26835. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26836. * localAxis is expressed in the mesh local space.
  26837. * result is computed in the Wordl space from the mesh World matrix.
  26838. * @param localAxis axis to rotate
  26839. * @param result the resulting transformnode
  26840. * @returns this TransformNode.
  26841. */
  26842. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26843. /**
  26844. * Sets this transform node rotation to the given local axis.
  26845. * @param localAxis the axis in local space
  26846. * @param yawCor optional yaw (y-axis) correction in radians
  26847. * @param pitchCor optional pitch (x-axis) correction in radians
  26848. * @param rollCor optional roll (z-axis) correction in radians
  26849. * @returns this TransformNode
  26850. */
  26851. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26852. /**
  26853. * Sets a new pivot point to the current node
  26854. * @param point defines the new pivot point to use
  26855. * @param space defines if the point is in world or local space (local by default)
  26856. * @returns the current TransformNode
  26857. */
  26858. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26859. /**
  26860. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26861. * @returns the pivot point
  26862. */
  26863. getPivotPoint(): Vector3;
  26864. /**
  26865. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26866. * @param result the vector3 to store the result
  26867. * @returns this TransformNode.
  26868. */
  26869. getPivotPointToRef(result: Vector3): TransformNode;
  26870. /**
  26871. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26872. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26873. */
  26874. getAbsolutePivotPoint(): Vector3;
  26875. /**
  26876. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26877. * @param result vector3 to store the result
  26878. * @returns this TransformNode.
  26879. */
  26880. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26881. /**
  26882. * Defines the passed node as the parent of the current node.
  26883. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26884. * @see https://doc.babylonjs.com/how_to/parenting
  26885. * @param node the node ot set as the parent
  26886. * @returns this TransformNode.
  26887. */
  26888. setParent(node: Nullable<Node>): TransformNode;
  26889. private _nonUniformScaling;
  26890. /**
  26891. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26892. */
  26893. get nonUniformScaling(): boolean;
  26894. /** @hidden */
  26895. _updateNonUniformScalingState(value: boolean): boolean;
  26896. /**
  26897. * Attach the current TransformNode to another TransformNode associated with a bone
  26898. * @param bone Bone affecting the TransformNode
  26899. * @param affectedTransformNode TransformNode associated with the bone
  26900. * @returns this object
  26901. */
  26902. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26903. /**
  26904. * Detach the transform node if its associated with a bone
  26905. * @returns this object
  26906. */
  26907. detachFromBone(): TransformNode;
  26908. private static _rotationAxisCache;
  26909. /**
  26910. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26911. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26912. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26913. * The passed axis is also normalized.
  26914. * @param axis the axis to rotate around
  26915. * @param amount the amount to rotate in radians
  26916. * @param space Space to rotate in (Default: local)
  26917. * @returns the TransformNode.
  26918. */
  26919. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26920. /**
  26921. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26922. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26923. * The passed axis is also normalized. .
  26924. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26925. * @param point the point to rotate around
  26926. * @param axis the axis to rotate around
  26927. * @param amount the amount to rotate in radians
  26928. * @returns the TransformNode
  26929. */
  26930. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26931. /**
  26932. * Translates the mesh along the axis vector for the passed distance in the given space.
  26933. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26934. * @param axis the axis to translate in
  26935. * @param distance the distance to translate
  26936. * @param space Space to rotate in (Default: local)
  26937. * @returns the TransformNode.
  26938. */
  26939. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26940. /**
  26941. * Adds a rotation step to the mesh current rotation.
  26942. * x, y, z are Euler angles expressed in radians.
  26943. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26944. * This means this rotation is made in the mesh local space only.
  26945. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26946. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26947. * ```javascript
  26948. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26949. * ```
  26950. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26951. * 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.
  26952. * @param x Rotation to add
  26953. * @param y Rotation to add
  26954. * @param z Rotation to add
  26955. * @returns the TransformNode.
  26956. */
  26957. addRotation(x: number, y: number, z: number): TransformNode;
  26958. /**
  26959. * @hidden
  26960. */
  26961. protected _getEffectiveParent(): Nullable<Node>;
  26962. /**
  26963. * Computes the world matrix of the node
  26964. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26965. * @returns the world matrix
  26966. */
  26967. computeWorldMatrix(force?: boolean): Matrix;
  26968. /**
  26969. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26970. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26971. */
  26972. resetLocalMatrix(independentOfChildren?: boolean): void;
  26973. protected _afterComputeWorldMatrix(): void;
  26974. /**
  26975. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26976. * @param func callback function to add
  26977. *
  26978. * @returns the TransformNode.
  26979. */
  26980. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26981. /**
  26982. * Removes a registered callback function.
  26983. * @param func callback function to remove
  26984. * @returns the TransformNode.
  26985. */
  26986. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26987. /**
  26988. * Gets the position of the current mesh in camera space
  26989. * @param camera defines the camera to use
  26990. * @returns a position
  26991. */
  26992. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26993. /**
  26994. * Returns the distance from the mesh to the active camera
  26995. * @param camera defines the camera to use
  26996. * @returns the distance
  26997. */
  26998. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26999. /**
  27000. * Clone the current transform node
  27001. * @param name Name of the new clone
  27002. * @param newParent New parent for the clone
  27003. * @param doNotCloneChildren Do not clone children hierarchy
  27004. * @returns the new transform node
  27005. */
  27006. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27007. /**
  27008. * Serializes the objects information.
  27009. * @param currentSerializationObject defines the object to serialize in
  27010. * @returns the serialized object
  27011. */
  27012. serialize(currentSerializationObject?: any): any;
  27013. /**
  27014. * Returns a new TransformNode object parsed from the source provided.
  27015. * @param parsedTransformNode is the source.
  27016. * @param scene the scne the object belongs to
  27017. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27018. * @returns a new TransformNode object parsed from the source provided.
  27019. */
  27020. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27021. /**
  27022. * Get all child-transformNodes of this node
  27023. * @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
  27024. * @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
  27025. * @returns an array of TransformNode
  27026. */
  27027. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27028. /**
  27029. * Releases resources associated with this transform node.
  27030. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27031. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27032. */
  27033. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27034. /**
  27035. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27036. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27037. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27038. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27039. * @returns the current mesh
  27040. */
  27041. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27042. private _syncAbsoluteScalingAndRotation;
  27043. }
  27044. }
  27045. declare module BABYLON {
  27046. /**
  27047. * Defines the types of pose enabled controllers that are supported
  27048. */
  27049. export enum PoseEnabledControllerType {
  27050. /**
  27051. * HTC Vive
  27052. */
  27053. VIVE = 0,
  27054. /**
  27055. * Oculus Rift
  27056. */
  27057. OCULUS = 1,
  27058. /**
  27059. * Windows mixed reality
  27060. */
  27061. WINDOWS = 2,
  27062. /**
  27063. * Samsung gear VR
  27064. */
  27065. GEAR_VR = 3,
  27066. /**
  27067. * Google Daydream
  27068. */
  27069. DAYDREAM = 4,
  27070. /**
  27071. * Generic
  27072. */
  27073. GENERIC = 5
  27074. }
  27075. /**
  27076. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27077. */
  27078. export interface MutableGamepadButton {
  27079. /**
  27080. * Value of the button/trigger
  27081. */
  27082. value: number;
  27083. /**
  27084. * If the button/trigger is currently touched
  27085. */
  27086. touched: boolean;
  27087. /**
  27088. * If the button/trigger is currently pressed
  27089. */
  27090. pressed: boolean;
  27091. }
  27092. /**
  27093. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27094. * @hidden
  27095. */
  27096. export interface ExtendedGamepadButton extends GamepadButton {
  27097. /**
  27098. * If the button/trigger is currently pressed
  27099. */
  27100. readonly pressed: boolean;
  27101. /**
  27102. * If the button/trigger is currently touched
  27103. */
  27104. readonly touched: boolean;
  27105. /**
  27106. * Value of the button/trigger
  27107. */
  27108. readonly value: number;
  27109. }
  27110. /** @hidden */
  27111. export interface _GamePadFactory {
  27112. /**
  27113. * Returns whether or not the current gamepad can be created for this type of controller.
  27114. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27115. * @returns true if it can be created, otherwise false
  27116. */
  27117. canCreate(gamepadInfo: any): boolean;
  27118. /**
  27119. * Creates a new instance of the Gamepad.
  27120. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27121. * @returns the new gamepad instance
  27122. */
  27123. create(gamepadInfo: any): Gamepad;
  27124. }
  27125. /**
  27126. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27127. */
  27128. export class PoseEnabledControllerHelper {
  27129. /** @hidden */
  27130. static _ControllerFactories: _GamePadFactory[];
  27131. /** @hidden */
  27132. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27133. /**
  27134. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27135. * @param vrGamepad the gamepad to initialized
  27136. * @returns a vr controller of the type the gamepad identified as
  27137. */
  27138. static InitiateController(vrGamepad: any): Gamepad;
  27139. }
  27140. /**
  27141. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27142. */
  27143. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27144. /**
  27145. * If the controller is used in a webXR session
  27146. */
  27147. isXR: boolean;
  27148. private _deviceRoomPosition;
  27149. private _deviceRoomRotationQuaternion;
  27150. /**
  27151. * The device position in babylon space
  27152. */
  27153. devicePosition: Vector3;
  27154. /**
  27155. * The device rotation in babylon space
  27156. */
  27157. deviceRotationQuaternion: Quaternion;
  27158. /**
  27159. * The scale factor of the device in babylon space
  27160. */
  27161. deviceScaleFactor: number;
  27162. /**
  27163. * (Likely devicePosition should be used instead) The device position in its room space
  27164. */
  27165. position: Vector3;
  27166. /**
  27167. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27168. */
  27169. rotationQuaternion: Quaternion;
  27170. /**
  27171. * The type of controller (Eg. Windows mixed reality)
  27172. */
  27173. controllerType: PoseEnabledControllerType;
  27174. protected _calculatedPosition: Vector3;
  27175. private _calculatedRotation;
  27176. /**
  27177. * The raw pose from the device
  27178. */
  27179. rawPose: DevicePose;
  27180. private _trackPosition;
  27181. private _maxRotationDistFromHeadset;
  27182. private _draggedRoomRotation;
  27183. /**
  27184. * @hidden
  27185. */
  27186. _disableTrackPosition(fixedPosition: Vector3): void;
  27187. /**
  27188. * Internal, the mesh attached to the controller
  27189. * @hidden
  27190. */
  27191. _mesh: Nullable<AbstractMesh>;
  27192. private _poseControlledCamera;
  27193. private _leftHandSystemQuaternion;
  27194. /**
  27195. * Internal, matrix used to convert room space to babylon space
  27196. * @hidden
  27197. */
  27198. _deviceToWorld: Matrix;
  27199. /**
  27200. * Node to be used when casting a ray from the controller
  27201. * @hidden
  27202. */
  27203. _pointingPoseNode: Nullable<TransformNode>;
  27204. /**
  27205. * Name of the child mesh that can be used to cast a ray from the controller
  27206. */
  27207. static readonly POINTING_POSE: string;
  27208. /**
  27209. * Creates a new PoseEnabledController from a gamepad
  27210. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27211. */
  27212. constructor(browserGamepad: any);
  27213. private _workingMatrix;
  27214. /**
  27215. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27216. */
  27217. update(): void;
  27218. /**
  27219. * Updates only the pose device and mesh without doing any button event checking
  27220. */
  27221. protected _updatePoseAndMesh(): void;
  27222. /**
  27223. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27224. * @param poseData raw pose fromthe device
  27225. */
  27226. updateFromDevice(poseData: DevicePose): void;
  27227. /**
  27228. * @hidden
  27229. */
  27230. _meshAttachedObservable: Observable<AbstractMesh>;
  27231. /**
  27232. * Attaches a mesh to the controller
  27233. * @param mesh the mesh to be attached
  27234. */
  27235. attachToMesh(mesh: AbstractMesh): void;
  27236. /**
  27237. * Attaches the controllers mesh to a camera
  27238. * @param camera the camera the mesh should be attached to
  27239. */
  27240. attachToPoseControlledCamera(camera: TargetCamera): void;
  27241. /**
  27242. * Disposes of the controller
  27243. */
  27244. dispose(): void;
  27245. /**
  27246. * The mesh that is attached to the controller
  27247. */
  27248. get mesh(): Nullable<AbstractMesh>;
  27249. /**
  27250. * Gets the ray of the controller in the direction the controller is pointing
  27251. * @param length the length the resulting ray should be
  27252. * @returns a ray in the direction the controller is pointing
  27253. */
  27254. getForwardRay(length?: number): Ray;
  27255. }
  27256. }
  27257. declare module BABYLON {
  27258. /**
  27259. * Defines the WebVRController object that represents controllers tracked in 3D space
  27260. */
  27261. export abstract class WebVRController extends PoseEnabledController {
  27262. /**
  27263. * Internal, the default controller model for the controller
  27264. */
  27265. protected _defaultModel: Nullable<AbstractMesh>;
  27266. /**
  27267. * Fired when the trigger state has changed
  27268. */
  27269. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27270. /**
  27271. * Fired when the main button state has changed
  27272. */
  27273. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27274. /**
  27275. * Fired when the secondary button state has changed
  27276. */
  27277. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27278. /**
  27279. * Fired when the pad state has changed
  27280. */
  27281. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27282. /**
  27283. * Fired when controllers stick values have changed
  27284. */
  27285. onPadValuesChangedObservable: Observable<StickValues>;
  27286. /**
  27287. * Array of button availible on the controller
  27288. */
  27289. protected _buttons: Array<MutableGamepadButton>;
  27290. private _onButtonStateChange;
  27291. /**
  27292. * Fired when a controller button's state has changed
  27293. * @param callback the callback containing the button that was modified
  27294. */
  27295. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27296. /**
  27297. * X and Y axis corresponding to the controllers joystick
  27298. */
  27299. pad: StickValues;
  27300. /**
  27301. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27302. */
  27303. hand: string;
  27304. /**
  27305. * The default controller model for the controller
  27306. */
  27307. get defaultModel(): Nullable<AbstractMesh>;
  27308. /**
  27309. * Creates a new WebVRController from a gamepad
  27310. * @param vrGamepad the gamepad that the WebVRController should be created from
  27311. */
  27312. constructor(vrGamepad: any);
  27313. /**
  27314. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27315. */
  27316. update(): void;
  27317. /**
  27318. * Function to be called when a button is modified
  27319. */
  27320. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27321. /**
  27322. * Loads a mesh and attaches it to the controller
  27323. * @param scene the scene the mesh should be added to
  27324. * @param meshLoaded callback for when the mesh has been loaded
  27325. */
  27326. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27327. private _setButtonValue;
  27328. private _changes;
  27329. private _checkChanges;
  27330. /**
  27331. * Disposes of th webVRCOntroller
  27332. */
  27333. dispose(): void;
  27334. }
  27335. }
  27336. declare module BABYLON {
  27337. /**
  27338. * The HemisphericLight simulates the ambient environment light,
  27339. * so the passed direction is the light reflection direction, not the incoming direction.
  27340. */
  27341. export class HemisphericLight extends Light {
  27342. /**
  27343. * The groundColor is the light in the opposite direction to the one specified during creation.
  27344. * 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.
  27345. */
  27346. groundColor: Color3;
  27347. /**
  27348. * The light reflection direction, not the incoming direction.
  27349. */
  27350. direction: Vector3;
  27351. /**
  27352. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27353. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27354. * The HemisphericLight can't cast shadows.
  27355. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27356. * @param name The friendly name of the light
  27357. * @param direction The direction of the light reflection
  27358. * @param scene The scene the light belongs to
  27359. */
  27360. constructor(name: string, direction: Vector3, scene: Scene);
  27361. protected _buildUniformLayout(): void;
  27362. /**
  27363. * Returns the string "HemisphericLight".
  27364. * @return The class name
  27365. */
  27366. getClassName(): string;
  27367. /**
  27368. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27369. * Returns the updated direction.
  27370. * @param target The target the direction should point to
  27371. * @return The computed direction
  27372. */
  27373. setDirectionToTarget(target: Vector3): Vector3;
  27374. /**
  27375. * Returns the shadow generator associated to the light.
  27376. * @returns Always null for hemispheric lights because it does not support shadows.
  27377. */
  27378. getShadowGenerator(): Nullable<IShadowGenerator>;
  27379. /**
  27380. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27381. * @param effect The effect to update
  27382. * @param lightIndex The index of the light in the effect to update
  27383. * @returns The hemispheric light
  27384. */
  27385. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27386. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27387. /**
  27388. * Computes the world matrix of the node
  27389. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27390. * @param useWasUpdatedFlag defines a reserved property
  27391. * @returns the world matrix
  27392. */
  27393. computeWorldMatrix(): Matrix;
  27394. /**
  27395. * Returns the integer 3.
  27396. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27397. */
  27398. getTypeID(): number;
  27399. /**
  27400. * Prepares the list of defines specific to the light type.
  27401. * @param defines the list of defines
  27402. * @param lightIndex defines the index of the light for the effect
  27403. */
  27404. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27405. }
  27406. }
  27407. declare module BABYLON {
  27408. /** @hidden */
  27409. export var vrMultiviewToSingleviewPixelShader: {
  27410. name: string;
  27411. shader: string;
  27412. };
  27413. }
  27414. declare module BABYLON {
  27415. /**
  27416. * Renders to multiple views with a single draw call
  27417. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27418. */
  27419. export class MultiviewRenderTarget extends RenderTargetTexture {
  27420. /**
  27421. * Creates a multiview render target
  27422. * @param scene scene used with the render target
  27423. * @param size the size of the render target (used for each view)
  27424. */
  27425. constructor(scene: Scene, size?: number | {
  27426. width: number;
  27427. height: number;
  27428. } | {
  27429. ratio: number;
  27430. });
  27431. /**
  27432. * @hidden
  27433. * @param faceIndex the face index, if its a cube texture
  27434. */
  27435. _bindFrameBuffer(faceIndex?: number): void;
  27436. /**
  27437. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27438. * @returns the view count
  27439. */
  27440. getViewCount(): number;
  27441. }
  27442. }
  27443. declare module BABYLON {
  27444. interface Engine {
  27445. /**
  27446. * Creates a new multiview render target
  27447. * @param width defines the width of the texture
  27448. * @param height defines the height of the texture
  27449. * @returns the created multiview texture
  27450. */
  27451. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27452. /**
  27453. * Binds a multiview framebuffer to be drawn to
  27454. * @param multiviewTexture texture to bind
  27455. */
  27456. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27457. }
  27458. interface Camera {
  27459. /**
  27460. * @hidden
  27461. * 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)
  27462. */
  27463. _useMultiviewToSingleView: boolean;
  27464. /**
  27465. * @hidden
  27466. * 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)
  27467. */
  27468. _multiviewTexture: Nullable<RenderTargetTexture>;
  27469. /**
  27470. * @hidden
  27471. * ensures the multiview texture of the camera exists and has the specified width/height
  27472. * @param width height to set on the multiview texture
  27473. * @param height width to set on the multiview texture
  27474. */
  27475. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27476. }
  27477. interface Scene {
  27478. /** @hidden */
  27479. _transformMatrixR: Matrix;
  27480. /** @hidden */
  27481. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27482. /** @hidden */
  27483. _createMultiviewUbo(): void;
  27484. /** @hidden */
  27485. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27486. /** @hidden */
  27487. _renderMultiviewToSingleView(camera: Camera): void;
  27488. }
  27489. }
  27490. declare module BABYLON {
  27491. /**
  27492. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27493. * This will not be used for webXR as it supports displaying texture arrays directly
  27494. */
  27495. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27496. /**
  27497. * Gets a string identifying the name of the class
  27498. * @returns "VRMultiviewToSingleviewPostProcess" string
  27499. */
  27500. getClassName(): string;
  27501. /**
  27502. * Initializes a VRMultiviewToSingleview
  27503. * @param name name of the post process
  27504. * @param camera camera to be applied to
  27505. * @param scaleFactor scaling factor to the size of the output texture
  27506. */
  27507. constructor(name: string, camera: Camera, scaleFactor: number);
  27508. }
  27509. }
  27510. declare module BABYLON {
  27511. /**
  27512. * Interface used to define additional presentation attributes
  27513. */
  27514. export interface IVRPresentationAttributes {
  27515. /**
  27516. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27517. */
  27518. highRefreshRate: boolean;
  27519. /**
  27520. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27521. */
  27522. foveationLevel: number;
  27523. }
  27524. interface Engine {
  27525. /** @hidden */
  27526. _vrDisplay: any;
  27527. /** @hidden */
  27528. _vrSupported: boolean;
  27529. /** @hidden */
  27530. _oldSize: Size;
  27531. /** @hidden */
  27532. _oldHardwareScaleFactor: number;
  27533. /** @hidden */
  27534. _vrExclusivePointerMode: boolean;
  27535. /** @hidden */
  27536. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27537. /** @hidden */
  27538. _onVRDisplayPointerRestricted: () => void;
  27539. /** @hidden */
  27540. _onVRDisplayPointerUnrestricted: () => void;
  27541. /** @hidden */
  27542. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27543. /** @hidden */
  27544. _onVrDisplayDisconnect: Nullable<() => void>;
  27545. /** @hidden */
  27546. _onVrDisplayPresentChange: Nullable<() => void>;
  27547. /**
  27548. * Observable signaled when VR display mode changes
  27549. */
  27550. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27551. /**
  27552. * Observable signaled when VR request present is complete
  27553. */
  27554. onVRRequestPresentComplete: Observable<boolean>;
  27555. /**
  27556. * Observable signaled when VR request present starts
  27557. */
  27558. onVRRequestPresentStart: Observable<Engine>;
  27559. /**
  27560. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27561. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27562. */
  27563. isInVRExclusivePointerMode: boolean;
  27564. /**
  27565. * Gets a boolean indicating if a webVR device was detected
  27566. * @returns true if a webVR device was detected
  27567. */
  27568. isVRDevicePresent(): boolean;
  27569. /**
  27570. * Gets the current webVR device
  27571. * @returns the current webVR device (or null)
  27572. */
  27573. getVRDevice(): any;
  27574. /**
  27575. * Initializes a webVR display and starts listening to display change events
  27576. * The onVRDisplayChangedObservable will be notified upon these changes
  27577. * @returns A promise containing a VRDisplay and if vr is supported
  27578. */
  27579. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27580. /** @hidden */
  27581. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27582. /**
  27583. * Gets or sets the presentation attributes used to configure VR rendering
  27584. */
  27585. vrPresentationAttributes?: IVRPresentationAttributes;
  27586. /**
  27587. * Call this function to switch to webVR mode
  27588. * Will do nothing if webVR is not supported or if there is no webVR device
  27589. * @param options the webvr options provided to the camera. mainly used for multiview
  27590. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27591. */
  27592. enableVR(options: WebVROptions): void;
  27593. /** @hidden */
  27594. _onVRFullScreenTriggered(): void;
  27595. }
  27596. }
  27597. declare module BABYLON {
  27598. /**
  27599. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27600. * IMPORTANT!! The data is right-hand data.
  27601. * @export
  27602. * @interface DevicePose
  27603. */
  27604. export interface DevicePose {
  27605. /**
  27606. * The position of the device, values in array are [x,y,z].
  27607. */
  27608. readonly position: Nullable<Float32Array>;
  27609. /**
  27610. * The linearVelocity of the device, values in array are [x,y,z].
  27611. */
  27612. readonly linearVelocity: Nullable<Float32Array>;
  27613. /**
  27614. * The linearAcceleration of the device, values in array are [x,y,z].
  27615. */
  27616. readonly linearAcceleration: Nullable<Float32Array>;
  27617. /**
  27618. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27619. */
  27620. readonly orientation: Nullable<Float32Array>;
  27621. /**
  27622. * The angularVelocity of the device, values in array are [x,y,z].
  27623. */
  27624. readonly angularVelocity: Nullable<Float32Array>;
  27625. /**
  27626. * The angularAcceleration of the device, values in array are [x,y,z].
  27627. */
  27628. readonly angularAcceleration: Nullable<Float32Array>;
  27629. }
  27630. /**
  27631. * Interface representing a pose controlled object in Babylon.
  27632. * A pose controlled object has both regular pose values as well as pose values
  27633. * from an external device such as a VR head mounted display
  27634. */
  27635. export interface PoseControlled {
  27636. /**
  27637. * The position of the object in babylon space.
  27638. */
  27639. position: Vector3;
  27640. /**
  27641. * The rotation quaternion of the object in babylon space.
  27642. */
  27643. rotationQuaternion: Quaternion;
  27644. /**
  27645. * The position of the device in babylon space.
  27646. */
  27647. devicePosition?: Vector3;
  27648. /**
  27649. * The rotation quaternion of the device in babylon space.
  27650. */
  27651. deviceRotationQuaternion: Quaternion;
  27652. /**
  27653. * The raw pose coming from the device.
  27654. */
  27655. rawPose: Nullable<DevicePose>;
  27656. /**
  27657. * The scale of the device to be used when translating from device space to babylon space.
  27658. */
  27659. deviceScaleFactor: number;
  27660. /**
  27661. * Updates the poseControlled values based on the input device pose.
  27662. * @param poseData the pose data to update the object with
  27663. */
  27664. updateFromDevice(poseData: DevicePose): void;
  27665. }
  27666. /**
  27667. * Set of options to customize the webVRCamera
  27668. */
  27669. export interface WebVROptions {
  27670. /**
  27671. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27672. */
  27673. trackPosition?: boolean;
  27674. /**
  27675. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27676. */
  27677. positionScale?: number;
  27678. /**
  27679. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27680. */
  27681. displayName?: string;
  27682. /**
  27683. * Should the native controller meshes be initialized. (default: true)
  27684. */
  27685. controllerMeshes?: boolean;
  27686. /**
  27687. * Creating a default HemiLight only on controllers. (default: true)
  27688. */
  27689. defaultLightingOnControllers?: boolean;
  27690. /**
  27691. * If you don't want to use the default VR button of the helper. (default: false)
  27692. */
  27693. useCustomVRButton?: boolean;
  27694. /**
  27695. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27696. */
  27697. customVRButton?: HTMLButtonElement;
  27698. /**
  27699. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27700. */
  27701. rayLength?: number;
  27702. /**
  27703. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27704. */
  27705. defaultHeight?: number;
  27706. /**
  27707. * If multiview should be used if availible (default: false)
  27708. */
  27709. useMultiview?: boolean;
  27710. }
  27711. /**
  27712. * This represents a WebVR camera.
  27713. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27714. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27715. */
  27716. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27717. private webVROptions;
  27718. /**
  27719. * @hidden
  27720. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27721. */
  27722. _vrDevice: any;
  27723. /**
  27724. * The rawPose of the vrDevice.
  27725. */
  27726. rawPose: Nullable<DevicePose>;
  27727. private _onVREnabled;
  27728. private _specsVersion;
  27729. private _attached;
  27730. private _frameData;
  27731. protected _descendants: Array<Node>;
  27732. private _deviceRoomPosition;
  27733. /** @hidden */
  27734. _deviceRoomRotationQuaternion: Quaternion;
  27735. private _standingMatrix;
  27736. /**
  27737. * Represents device position in babylon space.
  27738. */
  27739. devicePosition: Vector3;
  27740. /**
  27741. * Represents device rotation in babylon space.
  27742. */
  27743. deviceRotationQuaternion: Quaternion;
  27744. /**
  27745. * The scale of the device to be used when translating from device space to babylon space.
  27746. */
  27747. deviceScaleFactor: number;
  27748. private _deviceToWorld;
  27749. private _worldToDevice;
  27750. /**
  27751. * References to the webVR controllers for the vrDevice.
  27752. */
  27753. controllers: Array<WebVRController>;
  27754. /**
  27755. * Emits an event when a controller is attached.
  27756. */
  27757. onControllersAttachedObservable: Observable<WebVRController[]>;
  27758. /**
  27759. * Emits an event when a controller's mesh has been loaded;
  27760. */
  27761. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27762. /**
  27763. * Emits an event when the HMD's pose has been updated.
  27764. */
  27765. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27766. private _poseSet;
  27767. /**
  27768. * If the rig cameras be used as parent instead of this camera.
  27769. */
  27770. rigParenting: boolean;
  27771. private _lightOnControllers;
  27772. private _defaultHeight?;
  27773. /**
  27774. * Instantiates a WebVRFreeCamera.
  27775. * @param name The name of the WebVRFreeCamera
  27776. * @param position The starting anchor position for the camera
  27777. * @param scene The scene the camera belongs to
  27778. * @param webVROptions a set of customizable options for the webVRCamera
  27779. */
  27780. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27781. /**
  27782. * Gets the device distance from the ground in meters.
  27783. * @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.
  27784. */
  27785. deviceDistanceToRoomGround(): number;
  27786. /**
  27787. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27788. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27789. */
  27790. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27791. /**
  27792. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27793. * @returns A promise with a boolean set to if the standing matrix is supported.
  27794. */
  27795. useStandingMatrixAsync(): Promise<boolean>;
  27796. /**
  27797. * Disposes the camera
  27798. */
  27799. dispose(): void;
  27800. /**
  27801. * Gets a vrController by name.
  27802. * @param name The name of the controller to retreive
  27803. * @returns the controller matching the name specified or null if not found
  27804. */
  27805. getControllerByName(name: string): Nullable<WebVRController>;
  27806. private _leftController;
  27807. /**
  27808. * The controller corresponding to the users left hand.
  27809. */
  27810. get leftController(): Nullable<WebVRController>;
  27811. private _rightController;
  27812. /**
  27813. * The controller corresponding to the users right hand.
  27814. */
  27815. get rightController(): Nullable<WebVRController>;
  27816. /**
  27817. * Casts a ray forward from the vrCamera's gaze.
  27818. * @param length Length of the ray (default: 100)
  27819. * @returns the ray corresponding to the gaze
  27820. */
  27821. getForwardRay(length?: number): Ray;
  27822. /**
  27823. * @hidden
  27824. * Updates the camera based on device's frame data
  27825. */
  27826. _checkInputs(): void;
  27827. /**
  27828. * Updates the poseControlled values based on the input device pose.
  27829. * @param poseData Pose coming from the device
  27830. */
  27831. updateFromDevice(poseData: DevicePose): void;
  27832. private _detachIfAttached;
  27833. /**
  27834. * WebVR's attach control will start broadcasting frames to the device.
  27835. * Note that in certain browsers (chrome for example) this function must be called
  27836. * within a user-interaction callback. Example:
  27837. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27838. *
  27839. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27840. */
  27841. attachControl(noPreventDefault?: boolean): void;
  27842. /**
  27843. * Detach the current controls from the specified dom element.
  27844. */
  27845. detachControl(): void;
  27846. /**
  27847. * @returns the name of this class
  27848. */
  27849. getClassName(): string;
  27850. /**
  27851. * Calls resetPose on the vrDisplay
  27852. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27853. */
  27854. resetToCurrentRotation(): void;
  27855. /**
  27856. * @hidden
  27857. * Updates the rig cameras (left and right eye)
  27858. */
  27859. _updateRigCameras(): void;
  27860. private _workingVector;
  27861. private _oneVector;
  27862. private _workingMatrix;
  27863. private updateCacheCalled;
  27864. private _correctPositionIfNotTrackPosition;
  27865. /**
  27866. * @hidden
  27867. * Updates the cached values of the camera
  27868. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27869. */
  27870. _updateCache(ignoreParentClass?: boolean): void;
  27871. /**
  27872. * @hidden
  27873. * Get current device position in babylon world
  27874. */
  27875. _computeDevicePosition(): void;
  27876. /**
  27877. * Updates the current device position and rotation in the babylon world
  27878. */
  27879. update(): void;
  27880. /**
  27881. * @hidden
  27882. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27883. * @returns an identity matrix
  27884. */
  27885. _getViewMatrix(): Matrix;
  27886. private _tmpMatrix;
  27887. /**
  27888. * This function is called by the two RIG cameras.
  27889. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27890. * @hidden
  27891. */
  27892. _getWebVRViewMatrix(): Matrix;
  27893. /** @hidden */
  27894. _getWebVRProjectionMatrix(): Matrix;
  27895. private _onGamepadConnectedObserver;
  27896. private _onGamepadDisconnectedObserver;
  27897. private _updateCacheWhenTrackingDisabledObserver;
  27898. /**
  27899. * Initializes the controllers and their meshes
  27900. */
  27901. initControllers(): void;
  27902. }
  27903. }
  27904. declare module BABYLON {
  27905. /**
  27906. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27907. *
  27908. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27909. *
  27910. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27911. */
  27912. export class MaterialHelper {
  27913. /**
  27914. * Bind the current view position to an effect.
  27915. * @param effect The effect to be bound
  27916. * @param scene The scene the eyes position is used from
  27917. * @param variableName name of the shader variable that will hold the eye position
  27918. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  27919. * @return the computed eye position
  27920. */
  27921. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  27922. /**
  27923. * Helps preparing the defines values about the UVs in used in the effect.
  27924. * UVs are shared as much as we can accross channels in the shaders.
  27925. * @param texture The texture we are preparing the UVs for
  27926. * @param defines The defines to update
  27927. * @param key The channel key "diffuse", "specular"... used in the shader
  27928. */
  27929. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27930. /**
  27931. * Binds a texture matrix value to its corrsponding uniform
  27932. * @param texture The texture to bind the matrix for
  27933. * @param uniformBuffer The uniform buffer receivin the data
  27934. * @param key The channel key "diffuse", "specular"... used in the shader
  27935. */
  27936. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27937. /**
  27938. * Gets the current status of the fog (should it be enabled?)
  27939. * @param mesh defines the mesh to evaluate for fog support
  27940. * @param scene defines the hosting scene
  27941. * @returns true if fog must be enabled
  27942. */
  27943. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27944. /**
  27945. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27946. * @param mesh defines the current mesh
  27947. * @param scene defines the current scene
  27948. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27949. * @param pointsCloud defines if point cloud rendering has to be turned on
  27950. * @param fogEnabled defines if fog has to be turned on
  27951. * @param alphaTest defines if alpha testing has to be turned on
  27952. * @param defines defines the current list of defines
  27953. */
  27954. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27955. /**
  27956. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27957. * @param scene defines the current scene
  27958. * @param engine defines the current engine
  27959. * @param defines specifies the list of active defines
  27960. * @param useInstances defines if instances have to be turned on
  27961. * @param useClipPlane defines if clip plane have to be turned on
  27962. * @param useInstances defines if instances have to be turned on
  27963. * @param useThinInstances defines if thin instances have to be turned on
  27964. */
  27965. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27966. /**
  27967. * Prepares the defines for bones
  27968. * @param mesh The mesh containing the geometry data we will draw
  27969. * @param defines The defines to update
  27970. */
  27971. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27972. /**
  27973. * Prepares the defines for morph targets
  27974. * @param mesh The mesh containing the geometry data we will draw
  27975. * @param defines The defines to update
  27976. */
  27977. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27978. /**
  27979. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27980. * @param mesh The mesh containing the geometry data we will draw
  27981. * @param defines The defines to update
  27982. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27983. * @param useBones Precise whether bones should be used or not (override mesh info)
  27984. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27985. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27986. * @returns false if defines are considered not dirty and have not been checked
  27987. */
  27988. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27989. /**
  27990. * Prepares the defines related to multiview
  27991. * @param scene The scene we are intending to draw
  27992. * @param defines The defines to update
  27993. */
  27994. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27995. /**
  27996. * Prepares the defines related to the prepass
  27997. * @param scene The scene we are intending to draw
  27998. * @param defines The defines to update
  27999. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28000. */
  28001. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28002. /**
  28003. * Prepares the defines related to the light information passed in parameter
  28004. * @param scene The scene we are intending to draw
  28005. * @param mesh The mesh the effect is compiling for
  28006. * @param light The light the effect is compiling for
  28007. * @param lightIndex The index of the light
  28008. * @param defines The defines to update
  28009. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28010. * @param state Defines the current state regarding what is needed (normals, etc...)
  28011. */
  28012. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28013. needNormals: boolean;
  28014. needRebuild: boolean;
  28015. shadowEnabled: boolean;
  28016. specularEnabled: boolean;
  28017. lightmapMode: boolean;
  28018. }): void;
  28019. /**
  28020. * Prepares the defines related to the light information passed in parameter
  28021. * @param scene The scene we are intending to draw
  28022. * @param mesh The mesh the effect is compiling for
  28023. * @param defines The defines to update
  28024. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28025. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28026. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28027. * @returns true if normals will be required for the rest of the effect
  28028. */
  28029. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28030. /**
  28031. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28032. * @param lightIndex defines the light index
  28033. * @param uniformsList The uniform list
  28034. * @param samplersList The sampler list
  28035. * @param projectedLightTexture defines if projected texture must be used
  28036. * @param uniformBuffersList defines an optional list of uniform buffers
  28037. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28038. */
  28039. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28040. /**
  28041. * Prepares the uniforms and samplers list to be used in the effect
  28042. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28043. * @param samplersList The sampler list
  28044. * @param defines The defines helping in the list generation
  28045. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28046. */
  28047. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28048. /**
  28049. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28050. * @param defines The defines to update while falling back
  28051. * @param fallbacks The authorized effect fallbacks
  28052. * @param maxSimultaneousLights The maximum number of lights allowed
  28053. * @param rank the current rank of the Effect
  28054. * @returns The newly affected rank
  28055. */
  28056. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28057. private static _TmpMorphInfluencers;
  28058. /**
  28059. * Prepares the list of attributes required for morph targets according to the effect defines.
  28060. * @param attribs The current list of supported attribs
  28061. * @param mesh The mesh to prepare the morph targets attributes for
  28062. * @param influencers The number of influencers
  28063. */
  28064. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28065. /**
  28066. * Prepares the list of attributes required for morph targets according to the effect defines.
  28067. * @param attribs The current list of supported attribs
  28068. * @param mesh The mesh to prepare the morph targets attributes for
  28069. * @param defines The current Defines of the effect
  28070. */
  28071. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28072. /**
  28073. * Prepares the list of attributes required for bones according to the effect defines.
  28074. * @param attribs The current list of supported attribs
  28075. * @param mesh The mesh to prepare the bones attributes for
  28076. * @param defines The current Defines of the effect
  28077. * @param fallbacks The current efffect fallback strategy
  28078. */
  28079. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28080. /**
  28081. * Check and prepare the list of attributes required for instances according to the effect defines.
  28082. * @param attribs The current list of supported attribs
  28083. * @param defines The current MaterialDefines of the effect
  28084. */
  28085. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28086. /**
  28087. * Add the list of attributes required for instances to the attribs array.
  28088. * @param attribs The current list of supported attribs
  28089. */
  28090. static PushAttributesForInstances(attribs: string[]): void;
  28091. /**
  28092. * Binds the light information to the effect.
  28093. * @param light The light containing the generator
  28094. * @param effect The effect we are binding the data to
  28095. * @param lightIndex The light index in the effect used to render
  28096. */
  28097. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28098. /**
  28099. * Binds the lights information from the scene to the effect for the given mesh.
  28100. * @param light Light to bind
  28101. * @param lightIndex Light index
  28102. * @param scene The scene where the light belongs to
  28103. * @param effect The effect we are binding the data to
  28104. * @param useSpecular Defines if specular is supported
  28105. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28106. */
  28107. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28108. /**
  28109. * Binds the lights information from the scene to the effect for the given mesh.
  28110. * @param scene The scene the lights belongs to
  28111. * @param mesh The mesh we are binding the information to render
  28112. * @param effect The effect we are binding the data to
  28113. * @param defines The generated defines for the effect
  28114. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28115. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28116. */
  28117. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28118. private static _tempFogColor;
  28119. /**
  28120. * Binds the fog information from the scene to the effect for the given mesh.
  28121. * @param scene The scene the lights belongs to
  28122. * @param mesh The mesh we are binding the information to render
  28123. * @param effect The effect we are binding the data to
  28124. * @param linearSpace Defines if the fog effect is applied in linear space
  28125. */
  28126. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28127. /**
  28128. * Binds the bones information from the mesh to the effect.
  28129. * @param mesh The mesh we are binding the information to render
  28130. * @param effect The effect we are binding the data to
  28131. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28132. */
  28133. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28134. private static _CopyBonesTransformationMatrices;
  28135. /**
  28136. * Binds the morph targets information from the mesh to the effect.
  28137. * @param abstractMesh The mesh we are binding the information to render
  28138. * @param effect The effect we are binding the data to
  28139. */
  28140. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28141. /**
  28142. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28143. * @param defines The generated defines used in the effect
  28144. * @param effect The effect we are binding the data to
  28145. * @param scene The scene we are willing to render with logarithmic scale for
  28146. */
  28147. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28148. /**
  28149. * Binds the clip plane information from the scene to the effect.
  28150. * @param scene The scene the clip plane information are extracted from
  28151. * @param effect The effect we are binding the data to
  28152. */
  28153. static BindClipPlane(effect: Effect, scene: Scene): void;
  28154. }
  28155. }
  28156. declare module BABYLON {
  28157. /** @hidden */
  28158. export var bayerDitherFunctions: {
  28159. name: string;
  28160. shader: string;
  28161. };
  28162. }
  28163. declare module BABYLON {
  28164. /** @hidden */
  28165. export var shadowMapFragmentDeclaration: {
  28166. name: string;
  28167. shader: string;
  28168. };
  28169. }
  28170. declare module BABYLON {
  28171. /** @hidden */
  28172. export var shadowMapFragment: {
  28173. name: string;
  28174. shader: string;
  28175. };
  28176. }
  28177. declare module BABYLON {
  28178. /** @hidden */
  28179. export var shadowMapPixelShader: {
  28180. name: string;
  28181. shader: string;
  28182. };
  28183. }
  28184. declare module BABYLON {
  28185. /** @hidden */
  28186. export var shadowMapVertexDeclaration: {
  28187. name: string;
  28188. shader: string;
  28189. };
  28190. }
  28191. declare module BABYLON {
  28192. /** @hidden */
  28193. export var shadowMapVertexNormalBias: {
  28194. name: string;
  28195. shader: string;
  28196. };
  28197. }
  28198. declare module BABYLON {
  28199. /** @hidden */
  28200. export var shadowMapVertexMetric: {
  28201. name: string;
  28202. shader: string;
  28203. };
  28204. }
  28205. declare module BABYLON {
  28206. /** @hidden */
  28207. export var shadowMapVertexShader: {
  28208. name: string;
  28209. shader: string;
  28210. };
  28211. }
  28212. declare module BABYLON {
  28213. /** @hidden */
  28214. export var depthBoxBlurPixelShader: {
  28215. name: string;
  28216. shader: string;
  28217. };
  28218. }
  28219. declare module BABYLON {
  28220. /** @hidden */
  28221. export var shadowMapFragmentSoftTransparentShadow: {
  28222. name: string;
  28223. shader: string;
  28224. };
  28225. }
  28226. declare module BABYLON {
  28227. /**
  28228. * Creates an instance based on a source mesh.
  28229. */
  28230. export class InstancedMesh extends AbstractMesh {
  28231. private _sourceMesh;
  28232. private _currentLOD;
  28233. /** @hidden */
  28234. _indexInSourceMeshInstanceArray: number;
  28235. constructor(name: string, source: Mesh);
  28236. /**
  28237. * Returns the string "InstancedMesh".
  28238. */
  28239. getClassName(): string;
  28240. /** Gets the list of lights affecting that mesh */
  28241. get lightSources(): Light[];
  28242. _resyncLightSources(): void;
  28243. _resyncLightSource(light: Light): void;
  28244. _removeLightSource(light: Light, dispose: boolean): void;
  28245. /**
  28246. * If the source mesh receives shadows
  28247. */
  28248. get receiveShadows(): boolean;
  28249. /**
  28250. * The material of the source mesh
  28251. */
  28252. get material(): Nullable<Material>;
  28253. /**
  28254. * Visibility of the source mesh
  28255. */
  28256. get visibility(): number;
  28257. /**
  28258. * Skeleton of the source mesh
  28259. */
  28260. get skeleton(): Nullable<Skeleton>;
  28261. /**
  28262. * Rendering ground id of the source mesh
  28263. */
  28264. get renderingGroupId(): number;
  28265. set renderingGroupId(value: number);
  28266. /**
  28267. * Returns the total number of vertices (integer).
  28268. */
  28269. getTotalVertices(): number;
  28270. /**
  28271. * Returns a positive integer : the total number of indices in this mesh geometry.
  28272. * @returns the numner of indices or zero if the mesh has no geometry.
  28273. */
  28274. getTotalIndices(): number;
  28275. /**
  28276. * The source mesh of the instance
  28277. */
  28278. get sourceMesh(): Mesh;
  28279. /**
  28280. * Creates a new InstancedMesh object from the mesh model.
  28281. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28282. * @param name defines the name of the new instance
  28283. * @returns a new InstancedMesh
  28284. */
  28285. createInstance(name: string): InstancedMesh;
  28286. /**
  28287. * Is this node ready to be used/rendered
  28288. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28289. * @return {boolean} is it ready
  28290. */
  28291. isReady(completeCheck?: boolean): boolean;
  28292. /**
  28293. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28294. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28295. * @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.
  28296. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28297. */
  28298. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28299. /**
  28300. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28301. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28302. * The `data` are either a numeric array either a Float32Array.
  28303. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28304. * 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).
  28305. * Note that a new underlying VertexBuffer object is created each call.
  28306. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28307. *
  28308. * Possible `kind` values :
  28309. * - VertexBuffer.PositionKind
  28310. * - VertexBuffer.UVKind
  28311. * - VertexBuffer.UV2Kind
  28312. * - VertexBuffer.UV3Kind
  28313. * - VertexBuffer.UV4Kind
  28314. * - VertexBuffer.UV5Kind
  28315. * - VertexBuffer.UV6Kind
  28316. * - VertexBuffer.ColorKind
  28317. * - VertexBuffer.MatricesIndicesKind
  28318. * - VertexBuffer.MatricesIndicesExtraKind
  28319. * - VertexBuffer.MatricesWeightsKind
  28320. * - VertexBuffer.MatricesWeightsExtraKind
  28321. *
  28322. * Returns the Mesh.
  28323. */
  28324. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28325. /**
  28326. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28327. * If the mesh has no geometry, it is simply returned as it is.
  28328. * The `data` are either a numeric array either a Float32Array.
  28329. * No new underlying VertexBuffer object is created.
  28330. * 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.
  28331. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28332. *
  28333. * Possible `kind` values :
  28334. * - VertexBuffer.PositionKind
  28335. * - VertexBuffer.UVKind
  28336. * - VertexBuffer.UV2Kind
  28337. * - VertexBuffer.UV3Kind
  28338. * - VertexBuffer.UV4Kind
  28339. * - VertexBuffer.UV5Kind
  28340. * - VertexBuffer.UV6Kind
  28341. * - VertexBuffer.ColorKind
  28342. * - VertexBuffer.MatricesIndicesKind
  28343. * - VertexBuffer.MatricesIndicesExtraKind
  28344. * - VertexBuffer.MatricesWeightsKind
  28345. * - VertexBuffer.MatricesWeightsExtraKind
  28346. *
  28347. * Returns the Mesh.
  28348. */
  28349. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28350. /**
  28351. * Sets the mesh indices.
  28352. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28353. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28354. * This method creates a new index buffer each call.
  28355. * Returns the Mesh.
  28356. */
  28357. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28358. /**
  28359. * Boolean : True if the mesh owns the requested kind of data.
  28360. */
  28361. isVerticesDataPresent(kind: string): boolean;
  28362. /**
  28363. * Returns an array of indices (IndicesArray).
  28364. */
  28365. getIndices(): Nullable<IndicesArray>;
  28366. get _positions(): Nullable<Vector3[]>;
  28367. /**
  28368. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28369. * This means the mesh underlying bounding box and sphere are recomputed.
  28370. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28371. * @returns the current mesh
  28372. */
  28373. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28374. /** @hidden */
  28375. _preActivate(): InstancedMesh;
  28376. /** @hidden */
  28377. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28378. /** @hidden */
  28379. _postActivate(): void;
  28380. getWorldMatrix(): Matrix;
  28381. get isAnInstance(): boolean;
  28382. /**
  28383. * Returns the current associated LOD AbstractMesh.
  28384. */
  28385. getLOD(camera: Camera): AbstractMesh;
  28386. /** @hidden */
  28387. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28388. /** @hidden */
  28389. _syncSubMeshes(): InstancedMesh;
  28390. /** @hidden */
  28391. _generatePointsArray(): boolean;
  28392. /** @hidden */
  28393. _updateBoundingInfo(): AbstractMesh;
  28394. /**
  28395. * Creates a new InstancedMesh from the current mesh.
  28396. * - name (string) : the cloned mesh name
  28397. * - newParent (optional Node) : the optional Node to parent the clone to.
  28398. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28399. *
  28400. * Returns the clone.
  28401. */
  28402. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28403. /**
  28404. * Disposes the InstancedMesh.
  28405. * Returns nothing.
  28406. */
  28407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28408. }
  28409. interface Mesh {
  28410. /**
  28411. * Register a custom buffer that will be instanced
  28412. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28413. * @param kind defines the buffer kind
  28414. * @param stride defines the stride in floats
  28415. */
  28416. registerInstancedBuffer(kind: string, stride: number): void;
  28417. /**
  28418. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28419. */
  28420. _invalidateInstanceVertexArrayObject(): void;
  28421. /**
  28422. * true to use the edge renderer for all instances of this mesh
  28423. */
  28424. edgesShareWithInstances: boolean;
  28425. /** @hidden */
  28426. _userInstancedBuffersStorage: {
  28427. data: {
  28428. [key: string]: Float32Array;
  28429. };
  28430. sizes: {
  28431. [key: string]: number;
  28432. };
  28433. vertexBuffers: {
  28434. [key: string]: Nullable<VertexBuffer>;
  28435. };
  28436. strides: {
  28437. [key: string]: number;
  28438. };
  28439. vertexArrayObjects?: {
  28440. [key: string]: WebGLVertexArrayObject;
  28441. };
  28442. };
  28443. }
  28444. interface AbstractMesh {
  28445. /**
  28446. * Object used to store instanced buffers defined by user
  28447. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28448. */
  28449. instancedBuffers: {
  28450. [key: string]: any;
  28451. };
  28452. }
  28453. }
  28454. declare module BABYLON {
  28455. /**
  28456. * Defines the options associated with the creation of a shader material.
  28457. */
  28458. export interface IShaderMaterialOptions {
  28459. /**
  28460. * Does the material work in alpha blend mode
  28461. */
  28462. needAlphaBlending: boolean;
  28463. /**
  28464. * Does the material work in alpha test mode
  28465. */
  28466. needAlphaTesting: boolean;
  28467. /**
  28468. * The list of attribute names used in the shader
  28469. */
  28470. attributes: string[];
  28471. /**
  28472. * The list of unifrom names used in the shader
  28473. */
  28474. uniforms: string[];
  28475. /**
  28476. * The list of UBO names used in the shader
  28477. */
  28478. uniformBuffers: string[];
  28479. /**
  28480. * The list of sampler names used in the shader
  28481. */
  28482. samplers: string[];
  28483. /**
  28484. * The list of defines used in the shader
  28485. */
  28486. defines: string[];
  28487. }
  28488. /**
  28489. * 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.
  28490. *
  28491. * This returned material effects how the mesh will look based on the code in the shaders.
  28492. *
  28493. * @see https://doc.babylonjs.com/how_to/shader_material
  28494. */
  28495. export class ShaderMaterial extends Material {
  28496. private _shaderPath;
  28497. private _options;
  28498. private _textures;
  28499. private _textureArrays;
  28500. private _floats;
  28501. private _ints;
  28502. private _floatsArrays;
  28503. private _colors3;
  28504. private _colors3Arrays;
  28505. private _colors4;
  28506. private _colors4Arrays;
  28507. private _vectors2;
  28508. private _vectors3;
  28509. private _vectors4;
  28510. private _matrices;
  28511. private _matrixArrays;
  28512. private _matrices3x3;
  28513. private _matrices2x2;
  28514. private _vectors2Arrays;
  28515. private _vectors3Arrays;
  28516. private _vectors4Arrays;
  28517. private _cachedWorldViewMatrix;
  28518. private _cachedWorldViewProjectionMatrix;
  28519. private _renderId;
  28520. private _multiview;
  28521. private _cachedDefines;
  28522. /** Define the Url to load snippets */
  28523. static SnippetUrl: string;
  28524. /** Snippet ID if the material was created from the snippet server */
  28525. snippetId: string;
  28526. /**
  28527. * Instantiate a new shader material.
  28528. * 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.
  28529. * This returned material effects how the mesh will look based on the code in the shaders.
  28530. * @see https://doc.babylonjs.com/how_to/shader_material
  28531. * @param name Define the name of the material in the scene
  28532. * @param scene Define the scene the material belongs to
  28533. * @param shaderPath Defines the route to the shader code in one of three ways:
  28534. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28535. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28536. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28537. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28538. * @param options Define the options used to create the shader
  28539. */
  28540. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28541. /**
  28542. * Gets the shader path used to define the shader code
  28543. * It can be modified to trigger a new compilation
  28544. */
  28545. get shaderPath(): any;
  28546. /**
  28547. * Sets the shader path used to define the shader code
  28548. * It can be modified to trigger a new compilation
  28549. */
  28550. set shaderPath(shaderPath: any);
  28551. /**
  28552. * Gets the options used to compile the shader.
  28553. * They can be modified to trigger a new compilation
  28554. */
  28555. get options(): IShaderMaterialOptions;
  28556. /**
  28557. * Gets the current class name of the material e.g. "ShaderMaterial"
  28558. * Mainly use in serialization.
  28559. * @returns the class name
  28560. */
  28561. getClassName(): string;
  28562. /**
  28563. * Specifies if the material will require alpha blending
  28564. * @returns a boolean specifying if alpha blending is needed
  28565. */
  28566. needAlphaBlending(): boolean;
  28567. /**
  28568. * Specifies if this material should be rendered in alpha test mode
  28569. * @returns a boolean specifying if an alpha test is needed.
  28570. */
  28571. needAlphaTesting(): boolean;
  28572. private _checkUniform;
  28573. /**
  28574. * Set a texture in the shader.
  28575. * @param name Define the name of the uniform samplers as defined in the shader
  28576. * @param texture Define the texture to bind to this sampler
  28577. * @return the material itself allowing "fluent" like uniform updates
  28578. */
  28579. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28580. /**
  28581. * Set a texture array in the shader.
  28582. * @param name Define the name of the uniform sampler array as defined in the shader
  28583. * @param textures Define the list of textures to bind to this sampler
  28584. * @return the material itself allowing "fluent" like uniform updates
  28585. */
  28586. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28587. /**
  28588. * Set a float in the shader.
  28589. * @param name Define the name of the uniform as defined in the shader
  28590. * @param value Define the value to give to the uniform
  28591. * @return the material itself allowing "fluent" like uniform updates
  28592. */
  28593. setFloat(name: string, value: number): ShaderMaterial;
  28594. /**
  28595. * Set a int in the shader.
  28596. * @param name Define the name of the uniform as defined in the shader
  28597. * @param value Define the value to give to the uniform
  28598. * @return the material itself allowing "fluent" like uniform updates
  28599. */
  28600. setInt(name: string, value: number): ShaderMaterial;
  28601. /**
  28602. * Set an array of floats in the shader.
  28603. * @param name Define the name of the uniform as defined in the shader
  28604. * @param value Define the value to give to the uniform
  28605. * @return the material itself allowing "fluent" like uniform updates
  28606. */
  28607. setFloats(name: string, value: number[]): ShaderMaterial;
  28608. /**
  28609. * Set a vec3 in the shader from a Color3.
  28610. * @param name Define the name of the uniform as defined in the shader
  28611. * @param value Define the value to give to the uniform
  28612. * @return the material itself allowing "fluent" like uniform updates
  28613. */
  28614. setColor3(name: string, value: Color3): ShaderMaterial;
  28615. /**
  28616. * Set a vec3 array in the shader from a Color3 array.
  28617. * @param name Define the name of the uniform as defined in the shader
  28618. * @param value Define the value to give to the uniform
  28619. * @return the material itself allowing "fluent" like uniform updates
  28620. */
  28621. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28622. /**
  28623. * Set a vec4 in the shader from a Color4.
  28624. * @param name Define the name of the uniform as defined in the shader
  28625. * @param value Define the value to give to the uniform
  28626. * @return the material itself allowing "fluent" like uniform updates
  28627. */
  28628. setColor4(name: string, value: Color4): ShaderMaterial;
  28629. /**
  28630. * Set a vec4 array in the shader from a Color4 array.
  28631. * @param name Define the name of the uniform as defined in the shader
  28632. * @param value Define the value to give to the uniform
  28633. * @return the material itself allowing "fluent" like uniform updates
  28634. */
  28635. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28636. /**
  28637. * Set a vec2 in the shader from a Vector2.
  28638. * @param name Define the name of the uniform as defined in the shader
  28639. * @param value Define the value to give to the uniform
  28640. * @return the material itself allowing "fluent" like uniform updates
  28641. */
  28642. setVector2(name: string, value: Vector2): ShaderMaterial;
  28643. /**
  28644. * Set a vec3 in the shader from a Vector3.
  28645. * @param name Define the name of the uniform as defined in the shader
  28646. * @param value Define the value to give to the uniform
  28647. * @return the material itself allowing "fluent" like uniform updates
  28648. */
  28649. setVector3(name: string, value: Vector3): ShaderMaterial;
  28650. /**
  28651. * Set a vec4 in the shader from a Vector4.
  28652. * @param name Define the name of the uniform as defined in the shader
  28653. * @param value Define the value to give to the uniform
  28654. * @return the material itself allowing "fluent" like uniform updates
  28655. */
  28656. setVector4(name: string, value: Vector4): ShaderMaterial;
  28657. /**
  28658. * Set a mat4 in the shader from a Matrix.
  28659. * @param name Define the name of the uniform as defined in the shader
  28660. * @param value Define the value to give to the uniform
  28661. * @return the material itself allowing "fluent" like uniform updates
  28662. */
  28663. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28664. /**
  28665. * Set a float32Array in the shader from a matrix array.
  28666. * @param name Define the name of the uniform as defined in the shader
  28667. * @param value Define the value to give to the uniform
  28668. * @return the material itself allowing "fluent" like uniform updates
  28669. */
  28670. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28671. /**
  28672. * Set a mat3 in the shader from a Float32Array.
  28673. * @param name Define the name of the uniform as defined in the shader
  28674. * @param value Define the value to give to the uniform
  28675. * @return the material itself allowing "fluent" like uniform updates
  28676. */
  28677. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28678. /**
  28679. * Set a mat2 in the shader from a Float32Array.
  28680. * @param name Define the name of the uniform as defined in the shader
  28681. * @param value Define the value to give to the uniform
  28682. * @return the material itself allowing "fluent" like uniform updates
  28683. */
  28684. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28685. /**
  28686. * Set a vec2 array in the shader from a number array.
  28687. * @param name Define the name of the uniform as defined in the shader
  28688. * @param value Define the value to give to the uniform
  28689. * @return the material itself allowing "fluent" like uniform updates
  28690. */
  28691. setArray2(name: string, value: number[]): ShaderMaterial;
  28692. /**
  28693. * Set a vec3 array in the shader from a number array.
  28694. * @param name Define the name of the uniform as defined in the shader
  28695. * @param value Define the value to give to the uniform
  28696. * @return the material itself allowing "fluent" like uniform updates
  28697. */
  28698. setArray3(name: string, value: number[]): ShaderMaterial;
  28699. /**
  28700. * Set a vec4 array in the shader from a number array.
  28701. * @param name Define the name of the uniform as defined in the shader
  28702. * @param value Define the value to give to the uniform
  28703. * @return the material itself allowing "fluent" like uniform updates
  28704. */
  28705. setArray4(name: string, value: number[]): ShaderMaterial;
  28706. private _checkCache;
  28707. /**
  28708. * Specifies that the submesh is ready to be used
  28709. * @param mesh defines the mesh to check
  28710. * @param subMesh defines which submesh to check
  28711. * @param useInstances specifies that instances should be used
  28712. * @returns a boolean indicating that the submesh is ready or not
  28713. */
  28714. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28715. /**
  28716. * Checks if the material is ready to render the requested mesh
  28717. * @param mesh Define the mesh to render
  28718. * @param useInstances Define whether or not the material is used with instances
  28719. * @returns true if ready, otherwise false
  28720. */
  28721. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28722. /**
  28723. * Binds the world matrix to the material
  28724. * @param world defines the world transformation matrix
  28725. * @param effectOverride - If provided, use this effect instead of internal effect
  28726. */
  28727. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28728. /**
  28729. * Binds the submesh to this material by preparing the effect and shader to draw
  28730. * @param world defines the world transformation matrix
  28731. * @param mesh defines the mesh containing the submesh
  28732. * @param subMesh defines the submesh to bind the material to
  28733. */
  28734. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28735. /**
  28736. * Binds the material to the mesh
  28737. * @param world defines the world transformation matrix
  28738. * @param mesh defines the mesh to bind the material to
  28739. * @param effectOverride - If provided, use this effect instead of internal effect
  28740. */
  28741. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  28742. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  28743. /**
  28744. * Gets the active textures from the material
  28745. * @returns an array of textures
  28746. */
  28747. getActiveTextures(): BaseTexture[];
  28748. /**
  28749. * Specifies if the material uses a texture
  28750. * @param texture defines the texture to check against the material
  28751. * @returns a boolean specifying if the material uses the texture
  28752. */
  28753. hasTexture(texture: BaseTexture): boolean;
  28754. /**
  28755. * Makes a duplicate of the material, and gives it a new name
  28756. * @param name defines the new name for the duplicated material
  28757. * @returns the cloned material
  28758. */
  28759. clone(name: string): ShaderMaterial;
  28760. /**
  28761. * Disposes the material
  28762. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28763. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28764. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28765. */
  28766. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28767. /**
  28768. * Serializes this material in a JSON representation
  28769. * @returns the serialized material object
  28770. */
  28771. serialize(): any;
  28772. /**
  28773. * Creates a shader material from parsed shader material data
  28774. * @param source defines the JSON represnetation of the material
  28775. * @param scene defines the hosting scene
  28776. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28777. * @returns a new material
  28778. */
  28779. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28780. /**
  28781. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28782. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28783. * @param url defines the url to load from
  28784. * @param scene defines the hosting scene
  28785. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28786. * @returns a promise that will resolve to the new ShaderMaterial
  28787. */
  28788. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28789. /**
  28790. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28791. * @param snippetId defines the snippet to load
  28792. * @param scene defines the hosting scene
  28793. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28794. * @returns a promise that will resolve to the new ShaderMaterial
  28795. */
  28796. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28797. }
  28798. }
  28799. declare module BABYLON {
  28800. /** @hidden */
  28801. export var colorPixelShader: {
  28802. name: string;
  28803. shader: string;
  28804. };
  28805. }
  28806. declare module BABYLON {
  28807. /** @hidden */
  28808. export var colorVertexShader: {
  28809. name: string;
  28810. shader: string;
  28811. };
  28812. }
  28813. declare module BABYLON {
  28814. /**
  28815. * Line mesh
  28816. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28817. */
  28818. export class LinesMesh extends Mesh {
  28819. /**
  28820. * If vertex color should be applied to the mesh
  28821. */
  28822. readonly useVertexColor?: boolean | undefined;
  28823. /**
  28824. * If vertex alpha should be applied to the mesh
  28825. */
  28826. readonly useVertexAlpha?: boolean | undefined;
  28827. /**
  28828. * Color of the line (Default: White)
  28829. */
  28830. color: Color3;
  28831. /**
  28832. * Alpha of the line (Default: 1)
  28833. */
  28834. alpha: number;
  28835. /**
  28836. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28837. * This margin is expressed in world space coordinates, so its value may vary.
  28838. * Default value is 0.1
  28839. */
  28840. intersectionThreshold: number;
  28841. private _colorShader;
  28842. private color4;
  28843. /**
  28844. * Creates a new LinesMesh
  28845. * @param name defines the name
  28846. * @param scene defines the hosting scene
  28847. * @param parent defines the parent mesh if any
  28848. * @param source defines the optional source LinesMesh used to clone data from
  28849. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28850. * When false, achieved by calling a clone(), also passing False.
  28851. * This will make creation of children, recursive.
  28852. * @param useVertexColor defines if this LinesMesh supports vertex color
  28853. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28854. */
  28855. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28856. /**
  28857. * If vertex color should be applied to the mesh
  28858. */
  28859. useVertexColor?: boolean | undefined,
  28860. /**
  28861. * If vertex alpha should be applied to the mesh
  28862. */
  28863. useVertexAlpha?: boolean | undefined);
  28864. private _addClipPlaneDefine;
  28865. private _removeClipPlaneDefine;
  28866. isReady(): boolean;
  28867. /**
  28868. * Returns the string "LineMesh"
  28869. */
  28870. getClassName(): string;
  28871. /**
  28872. * @hidden
  28873. */
  28874. get material(): Material;
  28875. /**
  28876. * @hidden
  28877. */
  28878. set material(value: Material);
  28879. /**
  28880. * @hidden
  28881. */
  28882. get checkCollisions(): boolean;
  28883. set checkCollisions(value: boolean);
  28884. /** @hidden */
  28885. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28886. /** @hidden */
  28887. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28888. /**
  28889. * Disposes of the line mesh
  28890. * @param doNotRecurse If children should be disposed
  28891. */
  28892. dispose(doNotRecurse?: boolean): void;
  28893. /**
  28894. * Returns a new LineMesh object cloned from the current one.
  28895. */
  28896. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28897. /**
  28898. * Creates a new InstancedLinesMesh object from the mesh model.
  28899. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28900. * @param name defines the name of the new instance
  28901. * @returns a new InstancedLinesMesh
  28902. */
  28903. createInstance(name: string): InstancedLinesMesh;
  28904. }
  28905. /**
  28906. * Creates an instance based on a source LinesMesh
  28907. */
  28908. export class InstancedLinesMesh extends InstancedMesh {
  28909. /**
  28910. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28911. * This margin is expressed in world space coordinates, so its value may vary.
  28912. * Initilized with the intersectionThreshold value of the source LinesMesh
  28913. */
  28914. intersectionThreshold: number;
  28915. constructor(name: string, source: LinesMesh);
  28916. /**
  28917. * Returns the string "InstancedLinesMesh".
  28918. */
  28919. getClassName(): string;
  28920. }
  28921. }
  28922. declare module BABYLON {
  28923. /** @hidden */
  28924. export var linePixelShader: {
  28925. name: string;
  28926. shader: string;
  28927. };
  28928. }
  28929. declare module BABYLON {
  28930. /** @hidden */
  28931. export var lineVertexShader: {
  28932. name: string;
  28933. shader: string;
  28934. };
  28935. }
  28936. declare module BABYLON {
  28937. interface Scene {
  28938. /** @hidden */
  28939. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28940. }
  28941. interface AbstractMesh {
  28942. /**
  28943. * Gets the edgesRenderer associated with the mesh
  28944. */
  28945. edgesRenderer: Nullable<EdgesRenderer>;
  28946. }
  28947. interface LinesMesh {
  28948. /**
  28949. * Enables the edge rendering mode on the mesh.
  28950. * This mode makes the mesh edges visible
  28951. * @param epsilon defines the maximal distance between two angles to detect a face
  28952. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28953. * @returns the currentAbstractMesh
  28954. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28955. */
  28956. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28957. }
  28958. interface InstancedLinesMesh {
  28959. /**
  28960. * Enables the edge rendering mode on the mesh.
  28961. * This mode makes the mesh edges visible
  28962. * @param epsilon defines the maximal distance between two angles to detect a face
  28963. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28964. * @returns the current InstancedLinesMesh
  28965. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28966. */
  28967. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28968. }
  28969. /**
  28970. * Defines the minimum contract an Edges renderer should follow.
  28971. */
  28972. export interface IEdgesRenderer extends IDisposable {
  28973. /**
  28974. * Gets or sets a boolean indicating if the edgesRenderer is active
  28975. */
  28976. isEnabled: boolean;
  28977. /**
  28978. * Renders the edges of the attached mesh,
  28979. */
  28980. render(): void;
  28981. /**
  28982. * Checks wether or not the edges renderer is ready to render.
  28983. * @return true if ready, otherwise false.
  28984. */
  28985. isReady(): boolean;
  28986. /**
  28987. * List of instances to render in case the source mesh has instances
  28988. */
  28989. customInstances: SmartArray<Matrix>;
  28990. }
  28991. /**
  28992. * Defines the additional options of the edges renderer
  28993. */
  28994. export interface IEdgesRendererOptions {
  28995. /**
  28996. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28997. * If not defined, the default value is true
  28998. */
  28999. useAlternateEdgeFinder?: boolean;
  29000. /**
  29001. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29002. * If not defined, the default value is true.
  29003. * 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)
  29004. * This option is used only if useAlternateEdgeFinder = true
  29005. */
  29006. useFastVertexMerger?: boolean;
  29007. /**
  29008. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  29009. * The default value is 1e-6
  29010. * This option is used only if useAlternateEdgeFinder = true
  29011. */
  29012. epsilonVertexMerge?: number;
  29013. /**
  29014. * 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
  29015. * 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.
  29016. * This option is used only if useAlternateEdgeFinder = true
  29017. */
  29018. applyTessellation?: boolean;
  29019. /**
  29020. * 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
  29021. * The default value is 1e-6
  29022. * This option is used only if useAlternateEdgeFinder = true
  29023. */
  29024. epsilonVertexAligned?: number;
  29025. }
  29026. /**
  29027. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29028. */
  29029. export class EdgesRenderer implements IEdgesRenderer {
  29030. /**
  29031. * Define the size of the edges with an orthographic camera
  29032. */
  29033. edgesWidthScalerForOrthographic: number;
  29034. /**
  29035. * Define the size of the edges with a perspective camera
  29036. */
  29037. edgesWidthScalerForPerspective: number;
  29038. protected _source: AbstractMesh;
  29039. protected _linesPositions: number[];
  29040. protected _linesNormals: number[];
  29041. protected _linesIndices: number[];
  29042. protected _epsilon: number;
  29043. protected _indicesCount: number;
  29044. protected _lineShader: ShaderMaterial;
  29045. protected _ib: DataBuffer;
  29046. protected _buffers: {
  29047. [key: string]: Nullable<VertexBuffer>;
  29048. };
  29049. protected _buffersForInstances: {
  29050. [key: string]: Nullable<VertexBuffer>;
  29051. };
  29052. protected _checkVerticesInsteadOfIndices: boolean;
  29053. protected _options: Nullable<IEdgesRendererOptions>;
  29054. private _meshRebuildObserver;
  29055. private _meshDisposeObserver;
  29056. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29057. isEnabled: boolean;
  29058. /** Gets the vertices generated by the edge renderer */
  29059. get linesPositions(): Immutable<Array<number>>;
  29060. /** Gets the normals generated by the edge renderer */
  29061. get linesNormals(): Immutable<Array<number>>;
  29062. /** Gets the indices generated by the edge renderer */
  29063. get linesIndices(): Immutable<Array<number>>;
  29064. /**
  29065. * List of instances to render in case the source mesh has instances
  29066. */
  29067. customInstances: SmartArray<Matrix>;
  29068. private static GetShader;
  29069. /**
  29070. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29071. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29072. * @param source Mesh used to create edges
  29073. * @param epsilon sum of angles in adjacency to check for edge
  29074. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29075. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29076. * @param options The options to apply when generating the edges
  29077. */
  29078. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29079. protected _prepareRessources(): void;
  29080. /** @hidden */
  29081. _rebuild(): void;
  29082. /**
  29083. * Releases the required resources for the edges renderer
  29084. */
  29085. dispose(): void;
  29086. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29087. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29088. /**
  29089. * Checks if the pair of p0 and p1 is en edge
  29090. * @param faceIndex
  29091. * @param edge
  29092. * @param faceNormals
  29093. * @param p0
  29094. * @param p1
  29095. * @private
  29096. */
  29097. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29098. /**
  29099. * push line into the position, normal and index buffer
  29100. * @protected
  29101. */
  29102. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29103. /**
  29104. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29105. */
  29106. private _tessellateTriangle;
  29107. private _generateEdgesLinesAlternate;
  29108. /**
  29109. * Generates lines edges from adjacencjes
  29110. * @private
  29111. */
  29112. _generateEdgesLines(): void;
  29113. /**
  29114. * Checks wether or not the edges renderer is ready to render.
  29115. * @return true if ready, otherwise false.
  29116. */
  29117. isReady(): boolean;
  29118. /**
  29119. * Renders the edges of the attached mesh,
  29120. */
  29121. render(): void;
  29122. }
  29123. /**
  29124. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29125. */
  29126. export class LineEdgesRenderer extends EdgesRenderer {
  29127. /**
  29128. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29129. * @param source LineMesh used to generate edges
  29130. * @param epsilon not important (specified angle for edge detection)
  29131. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29132. */
  29133. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29134. /**
  29135. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29136. */
  29137. _generateEdgesLines(): void;
  29138. }
  29139. }
  29140. declare module BABYLON {
  29141. /**
  29142. * This represents the object necessary to create a rendering group.
  29143. * This is exclusively used and created by the rendering manager.
  29144. * To modify the behavior, you use the available helpers in your scene or meshes.
  29145. * @hidden
  29146. */
  29147. export class RenderingGroup {
  29148. index: number;
  29149. private static _zeroVector;
  29150. private _scene;
  29151. private _opaqueSubMeshes;
  29152. private _transparentSubMeshes;
  29153. private _alphaTestSubMeshes;
  29154. private _depthOnlySubMeshes;
  29155. private _particleSystems;
  29156. private _spriteManagers;
  29157. private _opaqueSortCompareFn;
  29158. private _alphaTestSortCompareFn;
  29159. private _transparentSortCompareFn;
  29160. private _renderOpaque;
  29161. private _renderAlphaTest;
  29162. private _renderTransparent;
  29163. /** @hidden */
  29164. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29165. onBeforeTransparentRendering: () => void;
  29166. /**
  29167. * Set the opaque sort comparison function.
  29168. * If null the sub meshes will be render in the order they were created
  29169. */
  29170. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29171. /**
  29172. * Set the alpha test sort comparison function.
  29173. * If null the sub meshes will be render in the order they were created
  29174. */
  29175. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29176. /**
  29177. * Set the transparent sort comparison function.
  29178. * If null the sub meshes will be render in the order they were created
  29179. */
  29180. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29181. /**
  29182. * Creates a new rendering group.
  29183. * @param index The rendering group index
  29184. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29185. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29186. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29187. */
  29188. 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>);
  29189. /**
  29190. * Render all the sub meshes contained in the group.
  29191. * @param customRenderFunction Used to override the default render behaviour of the group.
  29192. * @returns true if rendered some submeshes.
  29193. */
  29194. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29195. /**
  29196. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29197. * @param subMeshes The submeshes to render
  29198. */
  29199. private renderOpaqueSorted;
  29200. /**
  29201. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29202. * @param subMeshes The submeshes to render
  29203. */
  29204. private renderAlphaTestSorted;
  29205. /**
  29206. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29207. * @param subMeshes The submeshes to render
  29208. */
  29209. private renderTransparentSorted;
  29210. /**
  29211. * Renders the submeshes in a specified order.
  29212. * @param subMeshes The submeshes to sort before render
  29213. * @param sortCompareFn The comparison function use to sort
  29214. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29215. * @param transparent Specifies to activate blending if true
  29216. */
  29217. private static renderSorted;
  29218. /**
  29219. * Renders the submeshes in the order they were dispatched (no sort applied).
  29220. * @param subMeshes The submeshes to render
  29221. */
  29222. private static renderUnsorted;
  29223. /**
  29224. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29225. * are rendered back to front if in the same alpha index.
  29226. *
  29227. * @param a The first submesh
  29228. * @param b The second submesh
  29229. * @returns The result of the comparison
  29230. */
  29231. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29232. /**
  29233. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29234. * are rendered back to front.
  29235. *
  29236. * @param a The first submesh
  29237. * @param b The second submesh
  29238. * @returns The result of the comparison
  29239. */
  29240. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29241. /**
  29242. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29243. * are rendered front to back (prevent overdraw).
  29244. *
  29245. * @param a The first submesh
  29246. * @param b The second submesh
  29247. * @returns The result of the comparison
  29248. */
  29249. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29250. /**
  29251. * Resets the different lists of submeshes to prepare a new frame.
  29252. */
  29253. prepare(): void;
  29254. dispose(): void;
  29255. /**
  29256. * Inserts the submesh in its correct queue depending on its material.
  29257. * @param subMesh The submesh to dispatch
  29258. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29259. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29260. */
  29261. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29262. dispatchSprites(spriteManager: ISpriteManager): void;
  29263. dispatchParticles(particleSystem: IParticleSystem): void;
  29264. private _renderParticles;
  29265. private _renderSprites;
  29266. }
  29267. }
  29268. declare module BABYLON {
  29269. /**
  29270. * Interface describing the different options available in the rendering manager
  29271. * regarding Auto Clear between groups.
  29272. */
  29273. export interface IRenderingManagerAutoClearSetup {
  29274. /**
  29275. * Defines whether or not autoclear is enable.
  29276. */
  29277. autoClear: boolean;
  29278. /**
  29279. * Defines whether or not to autoclear the depth buffer.
  29280. */
  29281. depth: boolean;
  29282. /**
  29283. * Defines whether or not to autoclear the stencil buffer.
  29284. */
  29285. stencil: boolean;
  29286. }
  29287. /**
  29288. * This class is used by the onRenderingGroupObservable
  29289. */
  29290. export class RenderingGroupInfo {
  29291. /**
  29292. * The Scene that being rendered
  29293. */
  29294. scene: Scene;
  29295. /**
  29296. * The camera currently used for the rendering pass
  29297. */
  29298. camera: Nullable<Camera>;
  29299. /**
  29300. * The ID of the renderingGroup being processed
  29301. */
  29302. renderingGroupId: number;
  29303. }
  29304. /**
  29305. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29306. * It is enable to manage the different groups as well as the different necessary sort functions.
  29307. * This should not be used directly aside of the few static configurations
  29308. */
  29309. export class RenderingManager {
  29310. /**
  29311. * The max id used for rendering groups (not included)
  29312. */
  29313. static MAX_RENDERINGGROUPS: number;
  29314. /**
  29315. * The min id used for rendering groups (included)
  29316. */
  29317. static MIN_RENDERINGGROUPS: number;
  29318. /**
  29319. * Used to globally prevent autoclearing scenes.
  29320. */
  29321. static AUTOCLEAR: boolean;
  29322. /**
  29323. * @hidden
  29324. */
  29325. _useSceneAutoClearSetup: boolean;
  29326. private _scene;
  29327. private _renderingGroups;
  29328. private _depthStencilBufferAlreadyCleaned;
  29329. private _autoClearDepthStencil;
  29330. private _customOpaqueSortCompareFn;
  29331. private _customAlphaTestSortCompareFn;
  29332. private _customTransparentSortCompareFn;
  29333. private _renderingGroupInfo;
  29334. /**
  29335. * Instantiates a new rendering group for a particular scene
  29336. * @param scene Defines the scene the groups belongs to
  29337. */
  29338. constructor(scene: Scene);
  29339. private _clearDepthStencilBuffer;
  29340. /**
  29341. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29342. * @hidden
  29343. */
  29344. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29345. /**
  29346. * Resets the different information of the group to prepare a new frame
  29347. * @hidden
  29348. */
  29349. reset(): void;
  29350. /**
  29351. * Dispose and release the group and its associated resources.
  29352. * @hidden
  29353. */
  29354. dispose(): void;
  29355. /**
  29356. * Clear the info related to rendering groups preventing retention points during dispose.
  29357. */
  29358. freeRenderingGroups(): void;
  29359. private _prepareRenderingGroup;
  29360. /**
  29361. * Add a sprite manager to the rendering manager in order to render it this frame.
  29362. * @param spriteManager Define the sprite manager to render
  29363. */
  29364. dispatchSprites(spriteManager: ISpriteManager): void;
  29365. /**
  29366. * Add a particle system to the rendering manager in order to render it this frame.
  29367. * @param particleSystem Define the particle system to render
  29368. */
  29369. dispatchParticles(particleSystem: IParticleSystem): void;
  29370. /**
  29371. * Add a submesh to the manager in order to render it this frame
  29372. * @param subMesh The submesh to dispatch
  29373. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29374. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29375. */
  29376. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29377. /**
  29378. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29379. * This allowed control for front to back rendering or reversly depending of the special needs.
  29380. *
  29381. * @param renderingGroupId The rendering group id corresponding to its index
  29382. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29383. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29384. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29385. */
  29386. 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;
  29387. /**
  29388. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29389. *
  29390. * @param renderingGroupId The rendering group id corresponding to its index
  29391. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29392. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29393. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29394. */
  29395. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29396. /**
  29397. * Gets the current auto clear configuration for one rendering group of the rendering
  29398. * manager.
  29399. * @param index the rendering group index to get the information for
  29400. * @returns The auto clear setup for the requested rendering group
  29401. */
  29402. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29403. }
  29404. }
  29405. declare module BABYLON {
  29406. /**
  29407. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29408. */
  29409. export interface ICustomShaderOptions {
  29410. /**
  29411. * Gets or sets the custom shader name to use
  29412. */
  29413. shaderName: string;
  29414. /**
  29415. * The list of attribute names used in the shader
  29416. */
  29417. attributes?: string[];
  29418. /**
  29419. * The list of unifrom names used in the shader
  29420. */
  29421. uniforms?: string[];
  29422. /**
  29423. * The list of sampler names used in the shader
  29424. */
  29425. samplers?: string[];
  29426. /**
  29427. * The list of defines used in the shader
  29428. */
  29429. defines?: string[];
  29430. }
  29431. /**
  29432. * Interface to implement to create a shadow generator compatible with BJS.
  29433. */
  29434. export interface IShadowGenerator {
  29435. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29436. id: string;
  29437. /**
  29438. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29439. * @returns The render target texture if present otherwise, null
  29440. */
  29441. getShadowMap(): Nullable<RenderTargetTexture>;
  29442. /**
  29443. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29444. * @param subMesh The submesh we want to render in the shadow map
  29445. * @param useInstances Defines wether will draw in the map using instances
  29446. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29447. * @returns true if ready otherwise, false
  29448. */
  29449. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29450. /**
  29451. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29452. * @param defines Defines of the material we want to update
  29453. * @param lightIndex Index of the light in the enabled light list of the material
  29454. */
  29455. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29456. /**
  29457. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29458. * defined in the generator but impacting the effect).
  29459. * It implies the unifroms available on the materials are the standard BJS ones.
  29460. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29461. * @param effect The effect we are binfing the information for
  29462. */
  29463. bindShadowLight(lightIndex: string, effect: Effect): void;
  29464. /**
  29465. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29466. * (eq to shadow prjection matrix * light transform matrix)
  29467. * @returns The transform matrix used to create the shadow map
  29468. */
  29469. getTransformMatrix(): Matrix;
  29470. /**
  29471. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29472. * Cube and 2D textures for instance.
  29473. */
  29474. recreateShadowMap(): void;
  29475. /**
  29476. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29477. * @param onCompiled Callback triggered at the and of the effects compilation
  29478. * @param options Sets of optional options forcing the compilation with different modes
  29479. */
  29480. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29481. useInstances: boolean;
  29482. }>): void;
  29483. /**
  29484. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29485. * @param options Sets of optional options forcing the compilation with different modes
  29486. * @returns A promise that resolves when the compilation completes
  29487. */
  29488. forceCompilationAsync(options?: Partial<{
  29489. useInstances: boolean;
  29490. }>): Promise<void>;
  29491. /**
  29492. * Serializes the shadow generator setup to a json object.
  29493. * @returns The serialized JSON object
  29494. */
  29495. serialize(): any;
  29496. /**
  29497. * Disposes the Shadow map and related Textures and effects.
  29498. */
  29499. dispose(): void;
  29500. }
  29501. /**
  29502. * Default implementation IShadowGenerator.
  29503. * This is the main object responsible of generating shadows in the framework.
  29504. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29505. */
  29506. export class ShadowGenerator implements IShadowGenerator {
  29507. private static _Counter;
  29508. /**
  29509. * Name of the shadow generator class
  29510. */
  29511. static CLASSNAME: string;
  29512. /**
  29513. * Shadow generator mode None: no filtering applied.
  29514. */
  29515. static readonly FILTER_NONE: number;
  29516. /**
  29517. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29519. */
  29520. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29521. /**
  29522. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29523. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29524. */
  29525. static readonly FILTER_POISSONSAMPLING: number;
  29526. /**
  29527. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29528. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29529. */
  29530. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29531. /**
  29532. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29533. * edge artifacts on steep falloff.
  29534. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29535. */
  29536. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29537. /**
  29538. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29539. * edge artifacts on steep falloff.
  29540. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29541. */
  29542. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29543. /**
  29544. * Shadow generator mode PCF: Percentage Closer Filtering
  29545. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29546. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29547. */
  29548. static readonly FILTER_PCF: number;
  29549. /**
  29550. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29551. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29552. * Contact Hardening
  29553. */
  29554. static readonly FILTER_PCSS: number;
  29555. /**
  29556. * Reserved for PCF and PCSS
  29557. * Highest Quality.
  29558. *
  29559. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29560. *
  29561. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29562. */
  29563. static readonly QUALITY_HIGH: number;
  29564. /**
  29565. * Reserved for PCF and PCSS
  29566. * Good tradeoff for quality/perf cross devices
  29567. *
  29568. * Execute PCF on a 3*3 kernel.
  29569. *
  29570. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29571. */
  29572. static readonly QUALITY_MEDIUM: number;
  29573. /**
  29574. * Reserved for PCF and PCSS
  29575. * The lowest quality but the fastest.
  29576. *
  29577. * Execute PCF on a 1*1 kernel.
  29578. *
  29579. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29580. */
  29581. static readonly QUALITY_LOW: number;
  29582. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29583. id: string;
  29584. /** Gets or sets the custom shader name to use */
  29585. customShaderOptions: ICustomShaderOptions;
  29586. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29587. customAllowRendering: (subMesh: SubMesh) => boolean;
  29588. /**
  29589. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29590. */
  29591. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29592. /**
  29593. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29594. */
  29595. onAfterShadowMapRenderObservable: Observable<Effect>;
  29596. /**
  29597. * Observable triggered before a mesh is rendered in the shadow map.
  29598. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29599. */
  29600. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29601. /**
  29602. * Observable triggered after a mesh is rendered in the shadow map.
  29603. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29604. */
  29605. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29606. protected _bias: number;
  29607. /**
  29608. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29609. */
  29610. get bias(): number;
  29611. /**
  29612. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29613. */
  29614. set bias(bias: number);
  29615. protected _normalBias: number;
  29616. /**
  29617. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29618. */
  29619. get normalBias(): number;
  29620. /**
  29621. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29622. */
  29623. set normalBias(normalBias: number);
  29624. protected _blurBoxOffset: number;
  29625. /**
  29626. * Gets the blur box offset: offset applied during the blur pass.
  29627. * Only useful if useKernelBlur = false
  29628. */
  29629. get blurBoxOffset(): number;
  29630. /**
  29631. * Sets the blur box offset: offset applied during the blur pass.
  29632. * Only useful if useKernelBlur = false
  29633. */
  29634. set blurBoxOffset(value: number);
  29635. protected _blurScale: number;
  29636. /**
  29637. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29638. * 2 means half of the size.
  29639. */
  29640. get blurScale(): number;
  29641. /**
  29642. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29643. * 2 means half of the size.
  29644. */
  29645. set blurScale(value: number);
  29646. protected _blurKernel: number;
  29647. /**
  29648. * Gets the blur kernel: kernel size of the blur pass.
  29649. * Only useful if useKernelBlur = true
  29650. */
  29651. get blurKernel(): number;
  29652. /**
  29653. * Sets the blur kernel: kernel size of the blur pass.
  29654. * Only useful if useKernelBlur = true
  29655. */
  29656. set blurKernel(value: number);
  29657. protected _useKernelBlur: boolean;
  29658. /**
  29659. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29660. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29661. */
  29662. get useKernelBlur(): boolean;
  29663. /**
  29664. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29665. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29666. */
  29667. set useKernelBlur(value: boolean);
  29668. protected _depthScale: number;
  29669. /**
  29670. * Gets the depth scale used in ESM mode.
  29671. */
  29672. get depthScale(): number;
  29673. /**
  29674. * Sets the depth scale used in ESM mode.
  29675. * This can override the scale stored on the light.
  29676. */
  29677. set depthScale(value: number);
  29678. protected _validateFilter(filter: number): number;
  29679. protected _filter: number;
  29680. /**
  29681. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29682. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29683. */
  29684. get filter(): number;
  29685. /**
  29686. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29687. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29688. */
  29689. set filter(value: number);
  29690. /**
  29691. * Gets if the current filter is set to Poisson Sampling.
  29692. */
  29693. get usePoissonSampling(): boolean;
  29694. /**
  29695. * Sets the current filter to Poisson Sampling.
  29696. */
  29697. set usePoissonSampling(value: boolean);
  29698. /**
  29699. * Gets if the current filter is set to ESM.
  29700. */
  29701. get useExponentialShadowMap(): boolean;
  29702. /**
  29703. * Sets the current filter is to ESM.
  29704. */
  29705. set useExponentialShadowMap(value: boolean);
  29706. /**
  29707. * Gets if the current filter is set to filtered ESM.
  29708. */
  29709. get useBlurExponentialShadowMap(): boolean;
  29710. /**
  29711. * Gets if the current filter is set to filtered ESM.
  29712. */
  29713. set useBlurExponentialShadowMap(value: boolean);
  29714. /**
  29715. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29716. * exponential to prevent steep falloff artifacts).
  29717. */
  29718. get useCloseExponentialShadowMap(): boolean;
  29719. /**
  29720. * Sets the current filter to "close ESM" (using the inverse of the
  29721. * exponential to prevent steep falloff artifacts).
  29722. */
  29723. set useCloseExponentialShadowMap(value: boolean);
  29724. /**
  29725. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29726. * exponential to prevent steep falloff artifacts).
  29727. */
  29728. get useBlurCloseExponentialShadowMap(): boolean;
  29729. /**
  29730. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29731. * exponential to prevent steep falloff artifacts).
  29732. */
  29733. set useBlurCloseExponentialShadowMap(value: boolean);
  29734. /**
  29735. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29736. */
  29737. get usePercentageCloserFiltering(): boolean;
  29738. /**
  29739. * Sets the current filter to "PCF" (percentage closer filtering).
  29740. */
  29741. set usePercentageCloserFiltering(value: boolean);
  29742. protected _filteringQuality: number;
  29743. /**
  29744. * Gets the PCF or PCSS Quality.
  29745. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29746. */
  29747. get filteringQuality(): number;
  29748. /**
  29749. * Sets the PCF or PCSS Quality.
  29750. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29751. */
  29752. set filteringQuality(filteringQuality: number);
  29753. /**
  29754. * Gets if the current filter is set to "PCSS" (contact hardening).
  29755. */
  29756. get useContactHardeningShadow(): boolean;
  29757. /**
  29758. * Sets the current filter to "PCSS" (contact hardening).
  29759. */
  29760. set useContactHardeningShadow(value: boolean);
  29761. protected _contactHardeningLightSizeUVRatio: number;
  29762. /**
  29763. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29764. * Using a ratio helps keeping shape stability independently of the map size.
  29765. *
  29766. * It does not account for the light projection as it was having too much
  29767. * instability during the light setup or during light position changes.
  29768. *
  29769. * Only valid if useContactHardeningShadow is true.
  29770. */
  29771. get contactHardeningLightSizeUVRatio(): number;
  29772. /**
  29773. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29774. * Using a ratio helps keeping shape stability independently of the map size.
  29775. *
  29776. * It does not account for the light projection as it was having too much
  29777. * instability during the light setup or during light position changes.
  29778. *
  29779. * Only valid if useContactHardeningShadow is true.
  29780. */
  29781. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29782. protected _darkness: number;
  29783. /** Gets or sets the actual darkness of a shadow */
  29784. get darkness(): number;
  29785. set darkness(value: number);
  29786. /**
  29787. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29788. * 0 means strongest and 1 would means no shadow.
  29789. * @returns the darkness.
  29790. */
  29791. getDarkness(): number;
  29792. /**
  29793. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29794. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29795. * @returns the shadow generator allowing fluent coding.
  29796. */
  29797. setDarkness(darkness: number): ShadowGenerator;
  29798. protected _transparencyShadow: boolean;
  29799. /** Gets or sets the ability to have transparent shadow */
  29800. get transparencyShadow(): boolean;
  29801. set transparencyShadow(value: boolean);
  29802. /**
  29803. * Sets the ability to have transparent shadow (boolean).
  29804. * @param transparent True if transparent else False
  29805. * @returns the shadow generator allowing fluent coding
  29806. */
  29807. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29808. /**
  29809. * Enables or disables shadows with varying strength based on the transparency
  29810. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29811. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29812. * mesh.visibility * alphaTexture.a
  29813. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29814. */
  29815. enableSoftTransparentShadow: boolean;
  29816. protected _shadowMap: Nullable<RenderTargetTexture>;
  29817. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29818. /**
  29819. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29820. * @returns The render target texture if present otherwise, null
  29821. */
  29822. getShadowMap(): Nullable<RenderTargetTexture>;
  29823. /**
  29824. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29825. * @returns The render target texture if the shadow map is present otherwise, null
  29826. */
  29827. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29828. /**
  29829. * Gets the class name of that object
  29830. * @returns "ShadowGenerator"
  29831. */
  29832. getClassName(): string;
  29833. /**
  29834. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29835. * @param mesh Mesh to add
  29836. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29837. * @returns the Shadow Generator itself
  29838. */
  29839. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29840. /**
  29841. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29842. * @param mesh Mesh to remove
  29843. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29844. * @returns the Shadow Generator itself
  29845. */
  29846. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29847. /**
  29848. * Controls the extent to which the shadows fade out at the edge of the frustum
  29849. */
  29850. frustumEdgeFalloff: number;
  29851. protected _light: IShadowLight;
  29852. /**
  29853. * Returns the associated light object.
  29854. * @returns the light generating the shadow
  29855. */
  29856. getLight(): IShadowLight;
  29857. /**
  29858. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29859. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29860. * It might on the other hand introduce peter panning.
  29861. */
  29862. forceBackFacesOnly: boolean;
  29863. protected _scene: Scene;
  29864. protected _lightDirection: Vector3;
  29865. protected _viewMatrix: Matrix;
  29866. protected _projectionMatrix: Matrix;
  29867. protected _transformMatrix: Matrix;
  29868. protected _cachedPosition: Vector3;
  29869. protected _cachedDirection: Vector3;
  29870. protected _cachedDefines: string;
  29871. protected _currentRenderID: number;
  29872. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29873. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29874. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29875. protected _blurPostProcesses: PostProcess[];
  29876. protected _mapSize: number;
  29877. protected _currentFaceIndex: number;
  29878. protected _currentFaceIndexCache: number;
  29879. protected _textureType: number;
  29880. protected _defaultTextureMatrix: Matrix;
  29881. protected _storedUniqueId: Nullable<number>;
  29882. protected _nameForCustomEffect: string;
  29883. /** @hidden */
  29884. static _SceneComponentInitialization: (scene: Scene) => void;
  29885. /**
  29886. * Gets or sets the size of the texture what stores the shadows
  29887. */
  29888. get mapSize(): number;
  29889. set mapSize(size: number);
  29890. /**
  29891. * Creates a ShadowGenerator object.
  29892. * A ShadowGenerator is the required tool to use the shadows.
  29893. * Each light casting shadows needs to use its own ShadowGenerator.
  29894. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29895. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29896. * @param light The light object generating the shadows.
  29897. * @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.
  29898. */
  29899. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29900. protected _initializeGenerator(): void;
  29901. protected _createTargetRenderTexture(): void;
  29902. protected _initializeShadowMap(): void;
  29903. protected _initializeBlurRTTAndPostProcesses(): void;
  29904. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29905. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29906. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29907. protected _applyFilterValues(): void;
  29908. /**
  29909. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29910. * @param onCompiled Callback triggered at the and of the effects compilation
  29911. * @param options Sets of optional options forcing the compilation with different modes
  29912. */
  29913. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29914. useInstances: boolean;
  29915. }>): void;
  29916. /**
  29917. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29918. * @param options Sets of optional options forcing the compilation with different modes
  29919. * @returns A promise that resolves when the compilation completes
  29920. */
  29921. forceCompilationAsync(options?: Partial<{
  29922. useInstances: boolean;
  29923. }>): Promise<void>;
  29924. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29925. private _prepareShadowDefines;
  29926. /**
  29927. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29928. * @param subMesh The submesh we want to render in the shadow map
  29929. * @param useInstances Defines wether will draw in the map using instances
  29930. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29931. * @returns true if ready otherwise, false
  29932. */
  29933. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29934. /**
  29935. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29936. * @param defines Defines of the material we want to update
  29937. * @param lightIndex Index of the light in the enabled light list of the material
  29938. */
  29939. prepareDefines(defines: any, lightIndex: number): void;
  29940. /**
  29941. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29942. * defined in the generator but impacting the effect).
  29943. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29944. * @param effect The effect we are binfing the information for
  29945. */
  29946. bindShadowLight(lightIndex: string, effect: Effect): void;
  29947. /**
  29948. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29949. * (eq to shadow prjection matrix * light transform matrix)
  29950. * @returns The transform matrix used to create the shadow map
  29951. */
  29952. getTransformMatrix(): Matrix;
  29953. /**
  29954. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29955. * Cube and 2D textures for instance.
  29956. */
  29957. recreateShadowMap(): void;
  29958. protected _disposeBlurPostProcesses(): void;
  29959. protected _disposeRTTandPostProcesses(): void;
  29960. /**
  29961. * Disposes the ShadowGenerator.
  29962. * Returns nothing.
  29963. */
  29964. dispose(): void;
  29965. /**
  29966. * Serializes the shadow generator setup to a json object.
  29967. * @returns The serialized JSON object
  29968. */
  29969. serialize(): any;
  29970. /**
  29971. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29972. * @param parsedShadowGenerator The JSON object to parse
  29973. * @param scene The scene to create the shadow map for
  29974. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29975. * @returns The parsed shadow generator
  29976. */
  29977. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29978. }
  29979. }
  29980. declare module BABYLON {
  29981. /**
  29982. * Options to be used when creating a shadow depth material
  29983. */
  29984. export interface IIOptionShadowDepthMaterial {
  29985. /** Variables in the vertex shader code that need to have their names remapped.
  29986. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29987. * "var_name" should be either: worldPos or vNormalW
  29988. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29989. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29990. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29991. */
  29992. remappedVariables?: string[];
  29993. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29994. standalone?: boolean;
  29995. }
  29996. /**
  29997. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29998. */
  29999. export class ShadowDepthWrapper {
  30000. private _scene;
  30001. private _options?;
  30002. private _baseMaterial;
  30003. private _onEffectCreatedObserver;
  30004. private _subMeshToEffect;
  30005. private _subMeshToDepthEffect;
  30006. private _meshes;
  30007. /** @hidden */
  30008. _matriceNames: any;
  30009. /** Gets the standalone status of the wrapper */
  30010. get standalone(): boolean;
  30011. /** Gets the base material the wrapper is built upon */
  30012. get baseMaterial(): Material;
  30013. /**
  30014. * Instantiate a new shadow depth wrapper.
  30015. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30016. * generate the shadow depth map. For more information, please refer to the documentation:
  30017. * https://doc.babylonjs.com/babylon101/shadows
  30018. * @param baseMaterial Material to wrap
  30019. * @param scene Define the scene the material belongs to
  30020. * @param options Options used to create the wrapper
  30021. */
  30022. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30023. /**
  30024. * Gets the effect to use to generate the depth map
  30025. * @param subMesh subMesh to get the effect for
  30026. * @param shadowGenerator shadow generator to get the effect for
  30027. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30028. */
  30029. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30030. /**
  30031. * Specifies that the submesh is ready to be used for depth rendering
  30032. * @param subMesh submesh to check
  30033. * @param defines the list of defines to take into account when checking the effect
  30034. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30035. * @param useInstances specifies that instances should be used
  30036. * @returns a boolean indicating that the submesh is ready or not
  30037. */
  30038. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30039. /**
  30040. * Disposes the resources
  30041. */
  30042. dispose(): void;
  30043. private _makeEffect;
  30044. }
  30045. }
  30046. declare module BABYLON {
  30047. /**
  30048. * Options for compiling materials.
  30049. */
  30050. export interface IMaterialCompilationOptions {
  30051. /**
  30052. * Defines whether clip planes are enabled.
  30053. */
  30054. clipPlane: boolean;
  30055. /**
  30056. * Defines whether instances are enabled.
  30057. */
  30058. useInstances: boolean;
  30059. }
  30060. /**
  30061. * Options passed when calling customShaderNameResolve
  30062. */
  30063. export interface ICustomShaderNameResolveOptions {
  30064. /**
  30065. * 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
  30066. */
  30067. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30068. }
  30069. /**
  30070. * Base class for the main features of a material in Babylon.js
  30071. */
  30072. export class Material implements IAnimatable {
  30073. /**
  30074. * Returns the triangle fill mode
  30075. */
  30076. static readonly TriangleFillMode: number;
  30077. /**
  30078. * Returns the wireframe mode
  30079. */
  30080. static readonly WireFrameFillMode: number;
  30081. /**
  30082. * Returns the point fill mode
  30083. */
  30084. static readonly PointFillMode: number;
  30085. /**
  30086. * Returns the point list draw mode
  30087. */
  30088. static readonly PointListDrawMode: number;
  30089. /**
  30090. * Returns the line list draw mode
  30091. */
  30092. static readonly LineListDrawMode: number;
  30093. /**
  30094. * Returns the line loop draw mode
  30095. */
  30096. static readonly LineLoopDrawMode: number;
  30097. /**
  30098. * Returns the line strip draw mode
  30099. */
  30100. static readonly LineStripDrawMode: number;
  30101. /**
  30102. * Returns the triangle strip draw mode
  30103. */
  30104. static readonly TriangleStripDrawMode: number;
  30105. /**
  30106. * Returns the triangle fan draw mode
  30107. */
  30108. static readonly TriangleFanDrawMode: number;
  30109. /**
  30110. * Stores the clock-wise side orientation
  30111. */
  30112. static readonly ClockWiseSideOrientation: number;
  30113. /**
  30114. * Stores the counter clock-wise side orientation
  30115. */
  30116. static readonly CounterClockWiseSideOrientation: number;
  30117. /**
  30118. * The dirty texture flag value
  30119. */
  30120. static readonly TextureDirtyFlag: number;
  30121. /**
  30122. * The dirty light flag value
  30123. */
  30124. static readonly LightDirtyFlag: number;
  30125. /**
  30126. * The dirty fresnel flag value
  30127. */
  30128. static readonly FresnelDirtyFlag: number;
  30129. /**
  30130. * The dirty attribute flag value
  30131. */
  30132. static readonly AttributesDirtyFlag: number;
  30133. /**
  30134. * The dirty misc flag value
  30135. */
  30136. static readonly MiscDirtyFlag: number;
  30137. /**
  30138. * The dirty prepass flag value
  30139. */
  30140. static readonly PrePassDirtyFlag: number;
  30141. /**
  30142. * The all dirty flag value
  30143. */
  30144. static readonly AllDirtyFlag: number;
  30145. /**
  30146. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30147. */
  30148. static readonly MATERIAL_OPAQUE: number;
  30149. /**
  30150. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30151. */
  30152. static readonly MATERIAL_ALPHATEST: number;
  30153. /**
  30154. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30155. */
  30156. static readonly MATERIAL_ALPHABLEND: number;
  30157. /**
  30158. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30159. * They are also discarded below the alpha cutoff threshold to improve performances.
  30160. */
  30161. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30162. /**
  30163. * The Whiteout method is used to blend normals.
  30164. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30165. */
  30166. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30167. /**
  30168. * The Reoriented Normal Mapping method is used to blend normals.
  30169. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30170. */
  30171. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30172. /**
  30173. * Custom callback helping to override the default shader used in the material.
  30174. */
  30175. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30176. /**
  30177. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30178. */
  30179. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30180. /**
  30181. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30182. * This means that the material can keep using a previous shader while a new one is being compiled.
  30183. * This is mostly used when shader parallel compilation is supported (true by default)
  30184. */
  30185. allowShaderHotSwapping: boolean;
  30186. /**
  30187. * The ID of the material
  30188. */
  30189. id: string;
  30190. /**
  30191. * Gets or sets the unique id of the material
  30192. */
  30193. uniqueId: number;
  30194. /**
  30195. * The name of the material
  30196. */
  30197. name: string;
  30198. /**
  30199. * Gets or sets user defined metadata
  30200. */
  30201. metadata: any;
  30202. /**
  30203. * For internal use only. Please do not use.
  30204. */
  30205. reservedDataStore: any;
  30206. /**
  30207. * Specifies if the ready state should be checked on each call
  30208. */
  30209. checkReadyOnEveryCall: boolean;
  30210. /**
  30211. * Specifies if the ready state should be checked once
  30212. */
  30213. checkReadyOnlyOnce: boolean;
  30214. /**
  30215. * The state of the material
  30216. */
  30217. state: string;
  30218. /**
  30219. * If the material can be rendered to several textures with MRT extension
  30220. */
  30221. get canRenderToMRT(): boolean;
  30222. /**
  30223. * The alpha value of the material
  30224. */
  30225. protected _alpha: number;
  30226. /**
  30227. * List of inspectable custom properties (used by the Inspector)
  30228. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30229. */
  30230. inspectableCustomProperties: IInspectable[];
  30231. /**
  30232. * Sets the alpha value of the material
  30233. */
  30234. set alpha(value: number);
  30235. /**
  30236. * Gets the alpha value of the material
  30237. */
  30238. get alpha(): number;
  30239. /**
  30240. * Specifies if back face culling is enabled
  30241. */
  30242. protected _backFaceCulling: boolean;
  30243. /**
  30244. * Sets the back-face culling state
  30245. */
  30246. set backFaceCulling(value: boolean);
  30247. /**
  30248. * Gets the back-face culling state
  30249. */
  30250. get backFaceCulling(): boolean;
  30251. /**
  30252. * Stores the value for side orientation
  30253. */
  30254. sideOrientation: number;
  30255. /**
  30256. * Callback triggered when the material is compiled
  30257. */
  30258. onCompiled: Nullable<(effect: Effect) => void>;
  30259. /**
  30260. * Callback triggered when an error occurs
  30261. */
  30262. onError: Nullable<(effect: Effect, errors: string) => void>;
  30263. /**
  30264. * Callback triggered to get the render target textures
  30265. */
  30266. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30267. /**
  30268. * Gets a boolean indicating that current material needs to register RTT
  30269. */
  30270. get hasRenderTargetTextures(): boolean;
  30271. /**
  30272. * Specifies if the material should be serialized
  30273. */
  30274. doNotSerialize: boolean;
  30275. /**
  30276. * @hidden
  30277. */
  30278. _storeEffectOnSubMeshes: boolean;
  30279. /**
  30280. * Stores the animations for the material
  30281. */
  30282. animations: Nullable<Array<Animation>>;
  30283. /**
  30284. * An event triggered when the material is disposed
  30285. */
  30286. onDisposeObservable: Observable<Material>;
  30287. /**
  30288. * An observer which watches for dispose events
  30289. */
  30290. private _onDisposeObserver;
  30291. private _onUnBindObservable;
  30292. /**
  30293. * Called during a dispose event
  30294. */
  30295. set onDispose(callback: () => void);
  30296. private _onBindObservable;
  30297. /**
  30298. * An event triggered when the material is bound
  30299. */
  30300. get onBindObservable(): Observable<AbstractMesh>;
  30301. /**
  30302. * An observer which watches for bind events
  30303. */
  30304. private _onBindObserver;
  30305. /**
  30306. * Called during a bind event
  30307. */
  30308. set onBind(callback: (Mesh: AbstractMesh) => void);
  30309. /**
  30310. * An event triggered when the material is unbound
  30311. */
  30312. get onUnBindObservable(): Observable<Material>;
  30313. protected _onEffectCreatedObservable: Nullable<Observable<{
  30314. effect: Effect;
  30315. subMesh: Nullable<SubMesh>;
  30316. }>>;
  30317. /**
  30318. * An event triggered when the effect is (re)created
  30319. */
  30320. get onEffectCreatedObservable(): Observable<{
  30321. effect: Effect;
  30322. subMesh: Nullable<SubMesh>;
  30323. }>;
  30324. /**
  30325. * Stores the value of the alpha mode
  30326. */
  30327. private _alphaMode;
  30328. /**
  30329. * Sets the value of the alpha mode.
  30330. *
  30331. * | Value | Type | Description |
  30332. * | --- | --- | --- |
  30333. * | 0 | ALPHA_DISABLE | |
  30334. * | 1 | ALPHA_ADD | |
  30335. * | 2 | ALPHA_COMBINE | |
  30336. * | 3 | ALPHA_SUBTRACT | |
  30337. * | 4 | ALPHA_MULTIPLY | |
  30338. * | 5 | ALPHA_MAXIMIZED | |
  30339. * | 6 | ALPHA_ONEONE | |
  30340. * | 7 | ALPHA_PREMULTIPLIED | |
  30341. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30342. * | 9 | ALPHA_INTERPOLATE | |
  30343. * | 10 | ALPHA_SCREENMODE | |
  30344. *
  30345. */
  30346. set alphaMode(value: number);
  30347. /**
  30348. * Gets the value of the alpha mode
  30349. */
  30350. get alphaMode(): number;
  30351. /**
  30352. * Stores the state of the need depth pre-pass value
  30353. */
  30354. private _needDepthPrePass;
  30355. /**
  30356. * Sets the need depth pre-pass value
  30357. */
  30358. set needDepthPrePass(value: boolean);
  30359. /**
  30360. * Gets the depth pre-pass value
  30361. */
  30362. get needDepthPrePass(): boolean;
  30363. /**
  30364. * Specifies if depth writing should be disabled
  30365. */
  30366. disableDepthWrite: boolean;
  30367. /**
  30368. * Specifies if color writing should be disabled
  30369. */
  30370. disableColorWrite: boolean;
  30371. /**
  30372. * Specifies if depth writing should be forced
  30373. */
  30374. forceDepthWrite: boolean;
  30375. /**
  30376. * Specifies the depth function that should be used. 0 means the default engine function
  30377. */
  30378. depthFunction: number;
  30379. /**
  30380. * Specifies if there should be a separate pass for culling
  30381. */
  30382. separateCullingPass: boolean;
  30383. /**
  30384. * Stores the state specifing if fog should be enabled
  30385. */
  30386. private _fogEnabled;
  30387. /**
  30388. * Sets the state for enabling fog
  30389. */
  30390. set fogEnabled(value: boolean);
  30391. /**
  30392. * Gets the value of the fog enabled state
  30393. */
  30394. get fogEnabled(): boolean;
  30395. /**
  30396. * Stores the size of points
  30397. */
  30398. pointSize: number;
  30399. /**
  30400. * Stores the z offset value
  30401. */
  30402. zOffset: number;
  30403. get wireframe(): boolean;
  30404. /**
  30405. * Sets the state of wireframe mode
  30406. */
  30407. set wireframe(value: boolean);
  30408. /**
  30409. * Gets the value specifying if point clouds are enabled
  30410. */
  30411. get pointsCloud(): boolean;
  30412. /**
  30413. * Sets the state of point cloud mode
  30414. */
  30415. set pointsCloud(value: boolean);
  30416. /**
  30417. * Gets the material fill mode
  30418. */
  30419. get fillMode(): number;
  30420. /**
  30421. * Sets the material fill mode
  30422. */
  30423. set fillMode(value: number);
  30424. /**
  30425. * @hidden
  30426. * Stores the effects for the material
  30427. */
  30428. _effect: Nullable<Effect>;
  30429. /**
  30430. * Specifies if uniform buffers should be used
  30431. */
  30432. private _useUBO;
  30433. /**
  30434. * Stores a reference to the scene
  30435. */
  30436. private _scene;
  30437. private _needToBindSceneUbo;
  30438. /**
  30439. * Stores the fill mode state
  30440. */
  30441. private _fillMode;
  30442. /**
  30443. * Specifies if the depth write state should be cached
  30444. */
  30445. private _cachedDepthWriteState;
  30446. /**
  30447. * Specifies if the color write state should be cached
  30448. */
  30449. private _cachedColorWriteState;
  30450. /**
  30451. * Specifies if the depth function state should be cached
  30452. */
  30453. private _cachedDepthFunctionState;
  30454. /**
  30455. * Stores the uniform buffer
  30456. */
  30457. protected _uniformBuffer: UniformBuffer;
  30458. /** @hidden */
  30459. _indexInSceneMaterialArray: number;
  30460. /** @hidden */
  30461. meshMap: Nullable<{
  30462. [id: string]: AbstractMesh | undefined;
  30463. }>;
  30464. /**
  30465. * Creates a material instance
  30466. * @param name defines the name of the material
  30467. * @param scene defines the scene to reference
  30468. * @param doNotAdd specifies if the material should be added to the scene
  30469. */
  30470. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30471. /**
  30472. * Returns a string representation of the current material
  30473. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30474. * @returns a string with material information
  30475. */
  30476. toString(fullDetails?: boolean): string;
  30477. /**
  30478. * Gets the class name of the material
  30479. * @returns a string with the class name of the material
  30480. */
  30481. getClassName(): string;
  30482. /**
  30483. * Specifies if updates for the material been locked
  30484. */
  30485. get isFrozen(): boolean;
  30486. /**
  30487. * Locks updates for the material
  30488. */
  30489. freeze(): void;
  30490. /**
  30491. * Unlocks updates for the material
  30492. */
  30493. unfreeze(): void;
  30494. /**
  30495. * Specifies if the material is ready to be used
  30496. * @param mesh defines the mesh to check
  30497. * @param useInstances specifies if instances should be used
  30498. * @returns a boolean indicating if the material is ready to be used
  30499. */
  30500. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30501. /**
  30502. * Specifies that the submesh is ready to be used
  30503. * @param mesh defines the mesh to check
  30504. * @param subMesh defines which submesh to check
  30505. * @param useInstances specifies that instances should be used
  30506. * @returns a boolean indicating that the submesh is ready or not
  30507. */
  30508. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30509. /**
  30510. * Returns the material effect
  30511. * @returns the effect associated with the material
  30512. */
  30513. getEffect(): Nullable<Effect>;
  30514. /**
  30515. * Returns the current scene
  30516. * @returns a Scene
  30517. */
  30518. getScene(): Scene;
  30519. /**
  30520. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30521. */
  30522. protected _forceAlphaTest: boolean;
  30523. /**
  30524. * The transparency mode of the material.
  30525. */
  30526. protected _transparencyMode: Nullable<number>;
  30527. /**
  30528. * Gets the current transparency mode.
  30529. */
  30530. get transparencyMode(): Nullable<number>;
  30531. /**
  30532. * Sets the transparency mode of the material.
  30533. *
  30534. * | Value | Type | Description |
  30535. * | ----- | ----------------------------------- | ----------- |
  30536. * | 0 | OPAQUE | |
  30537. * | 1 | ALPHATEST | |
  30538. * | 2 | ALPHABLEND | |
  30539. * | 3 | ALPHATESTANDBLEND | |
  30540. *
  30541. */
  30542. set transparencyMode(value: Nullable<number>);
  30543. /**
  30544. * Returns true if alpha blending should be disabled.
  30545. */
  30546. protected get _disableAlphaBlending(): boolean;
  30547. /**
  30548. * Specifies whether or not this material should be rendered in alpha blend mode.
  30549. * @returns a boolean specifying if alpha blending is needed
  30550. */
  30551. needAlphaBlending(): boolean;
  30552. /**
  30553. * Specifies if the mesh will require alpha blending
  30554. * @param mesh defines the mesh to check
  30555. * @returns a boolean specifying if alpha blending is needed for the mesh
  30556. */
  30557. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30558. /**
  30559. * Specifies whether or not this material should be rendered in alpha test mode.
  30560. * @returns a boolean specifying if an alpha test is needed.
  30561. */
  30562. needAlphaTesting(): boolean;
  30563. /**
  30564. * Specifies if material alpha testing should be turned on for the mesh
  30565. * @param mesh defines the mesh to check
  30566. */
  30567. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30568. /**
  30569. * Gets the texture used for the alpha test
  30570. * @returns the texture to use for alpha testing
  30571. */
  30572. getAlphaTestTexture(): Nullable<BaseTexture>;
  30573. /**
  30574. * Marks the material to indicate that it needs to be re-calculated
  30575. */
  30576. markDirty(): void;
  30577. /** @hidden */
  30578. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30579. /**
  30580. * Binds the material to the mesh
  30581. * @param world defines the world transformation matrix
  30582. * @param mesh defines the mesh to bind the material to
  30583. */
  30584. bind(world: Matrix, mesh?: Mesh): void;
  30585. /**
  30586. * Binds the submesh to the material
  30587. * @param world defines the world transformation matrix
  30588. * @param mesh defines the mesh containing the submesh
  30589. * @param subMesh defines the submesh to bind the material to
  30590. */
  30591. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30592. /**
  30593. * Binds the world matrix to the material
  30594. * @param world defines the world transformation matrix
  30595. */
  30596. bindOnlyWorldMatrix(world: Matrix): void;
  30597. /**
  30598. * Update the scene ubo before it can be used in rendering processing
  30599. * @param scene the scene to retrieve the ubo from
  30600. * @returns the scene UniformBuffer
  30601. */
  30602. finalizeSceneUbo(scene: Scene): UniformBuffer;
  30603. /**
  30604. * Binds the scene's uniform buffer to the effect.
  30605. * @param effect defines the effect to bind to the scene uniform buffer
  30606. * @param sceneUbo defines the uniform buffer storing scene data
  30607. */
  30608. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30609. /**
  30610. * Binds the view matrix to the effect
  30611. * @param effect defines the effect to bind the view matrix to
  30612. */
  30613. bindView(effect: Effect): void;
  30614. /**
  30615. * Binds the view projection and projection matrices to the effect
  30616. * @param effect defines the effect to bind the view projection and projection matrices to
  30617. */
  30618. bindViewProjection(effect: Effect): void;
  30619. /**
  30620. * Binds the view matrix to the effect
  30621. * @param effect defines the effect to bind the view matrix to
  30622. * @param variableName name of the shader variable that will hold the eye position
  30623. */
  30624. bindEyePosition(effect: Effect, variableName?: string): void;
  30625. /**
  30626. * Processes to execute after binding the material to a mesh
  30627. * @param mesh defines the rendered mesh
  30628. */
  30629. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30630. /**
  30631. * Unbinds the material from the mesh
  30632. */
  30633. unbind(): void;
  30634. /**
  30635. * Gets the active textures from the material
  30636. * @returns an array of textures
  30637. */
  30638. getActiveTextures(): BaseTexture[];
  30639. /**
  30640. * Specifies if the material uses a texture
  30641. * @param texture defines the texture to check against the material
  30642. * @returns a boolean specifying if the material uses the texture
  30643. */
  30644. hasTexture(texture: BaseTexture): boolean;
  30645. /**
  30646. * Makes a duplicate of the material, and gives it a new name
  30647. * @param name defines the new name for the duplicated material
  30648. * @returns the cloned material
  30649. */
  30650. clone(name: string): Nullable<Material>;
  30651. /**
  30652. * Gets the meshes bound to the material
  30653. * @returns an array of meshes bound to the material
  30654. */
  30655. getBindedMeshes(): AbstractMesh[];
  30656. /**
  30657. * Force shader compilation
  30658. * @param mesh defines the mesh associated with this material
  30659. * @param onCompiled defines a function to execute once the material is compiled
  30660. * @param options defines the options to configure the compilation
  30661. * @param onError defines a function to execute if the material fails compiling
  30662. */
  30663. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30664. /**
  30665. * Force shader compilation
  30666. * @param mesh defines the mesh that will use this material
  30667. * @param options defines additional options for compiling the shaders
  30668. * @returns a promise that resolves when the compilation completes
  30669. */
  30670. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30671. private static readonly _AllDirtyCallBack;
  30672. private static readonly _ImageProcessingDirtyCallBack;
  30673. private static readonly _TextureDirtyCallBack;
  30674. private static readonly _FresnelDirtyCallBack;
  30675. private static readonly _MiscDirtyCallBack;
  30676. private static readonly _PrePassDirtyCallBack;
  30677. private static readonly _LightsDirtyCallBack;
  30678. private static readonly _AttributeDirtyCallBack;
  30679. private static _FresnelAndMiscDirtyCallBack;
  30680. private static _TextureAndMiscDirtyCallBack;
  30681. private static readonly _DirtyCallbackArray;
  30682. private static readonly _RunDirtyCallBacks;
  30683. /**
  30684. * Marks a define in the material to indicate that it needs to be re-computed
  30685. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30686. */
  30687. markAsDirty(flag: number): void;
  30688. /**
  30689. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30690. * @param func defines a function which checks material defines against the submeshes
  30691. */
  30692. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30693. /**
  30694. * Indicates that the scene should check if the rendering now needs a prepass
  30695. */
  30696. protected _markScenePrePassDirty(): void;
  30697. /**
  30698. * Indicates that we need to re-calculated for all submeshes
  30699. */
  30700. protected _markAllSubMeshesAsAllDirty(): void;
  30701. /**
  30702. * Indicates that image processing needs to be re-calculated for all submeshes
  30703. */
  30704. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30705. /**
  30706. * Indicates that textures need to be re-calculated for all submeshes
  30707. */
  30708. protected _markAllSubMeshesAsTexturesDirty(): void;
  30709. /**
  30710. * Indicates that fresnel needs to be re-calculated for all submeshes
  30711. */
  30712. protected _markAllSubMeshesAsFresnelDirty(): void;
  30713. /**
  30714. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30715. */
  30716. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30717. /**
  30718. * Indicates that lights need to be re-calculated for all submeshes
  30719. */
  30720. protected _markAllSubMeshesAsLightsDirty(): void;
  30721. /**
  30722. * Indicates that attributes need to be re-calculated for all submeshes
  30723. */
  30724. protected _markAllSubMeshesAsAttributesDirty(): void;
  30725. /**
  30726. * Indicates that misc needs to be re-calculated for all submeshes
  30727. */
  30728. protected _markAllSubMeshesAsMiscDirty(): void;
  30729. /**
  30730. * Indicates that prepass needs to be re-calculated for all submeshes
  30731. */
  30732. protected _markAllSubMeshesAsPrePassDirty(): void;
  30733. /**
  30734. * Indicates that textures and misc need to be re-calculated for all submeshes
  30735. */
  30736. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30737. /**
  30738. * Sets the required values to the prepass renderer.
  30739. * @param prePassRenderer defines the prepass renderer to setup.
  30740. * @returns true if the pre pass is needed.
  30741. */
  30742. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30743. /**
  30744. * Disposes the material
  30745. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30746. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30747. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30748. */
  30749. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30750. /** @hidden */
  30751. private releaseVertexArrayObject;
  30752. /**
  30753. * Serializes this material
  30754. * @returns the serialized material object
  30755. */
  30756. serialize(): any;
  30757. /**
  30758. * Creates a material from parsed material data
  30759. * @param parsedMaterial defines parsed material data
  30760. * @param scene defines the hosting scene
  30761. * @param rootUrl defines the root URL to use to load textures
  30762. * @returns a new material
  30763. */
  30764. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30765. }
  30766. }
  30767. declare module BABYLON {
  30768. /**
  30769. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30770. * separate meshes. This can be use to improve performances.
  30771. * @see https://doc.babylonjs.com/how_to/multi_materials
  30772. */
  30773. export class MultiMaterial extends Material {
  30774. private _subMaterials;
  30775. /**
  30776. * Gets or Sets the list of Materials used within the multi material.
  30777. * They need to be ordered according to the submeshes order in the associated mesh
  30778. */
  30779. get subMaterials(): Nullable<Material>[];
  30780. set subMaterials(value: Nullable<Material>[]);
  30781. /**
  30782. * Function used to align with Node.getChildren()
  30783. * @returns the list of Materials used within the multi material
  30784. */
  30785. getChildren(): Nullable<Material>[];
  30786. /**
  30787. * Instantiates a new Multi Material
  30788. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30789. * separate meshes. This can be use to improve performances.
  30790. * @see https://doc.babylonjs.com/how_to/multi_materials
  30791. * @param name Define the name in the scene
  30792. * @param scene Define the scene the material belongs to
  30793. */
  30794. constructor(name: string, scene: Scene);
  30795. private _hookArray;
  30796. /**
  30797. * Get one of the submaterial by its index in the submaterials array
  30798. * @param index The index to look the sub material at
  30799. * @returns The Material if the index has been defined
  30800. */
  30801. getSubMaterial(index: number): Nullable<Material>;
  30802. /**
  30803. * Get the list of active textures for the whole sub materials list.
  30804. * @returns All the textures that will be used during the rendering
  30805. */
  30806. getActiveTextures(): BaseTexture[];
  30807. /**
  30808. * Specifies if any sub-materials of this multi-material use a given texture.
  30809. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30810. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30811. */
  30812. hasTexture(texture: BaseTexture): boolean;
  30813. /**
  30814. * Gets the current class name of the material e.g. "MultiMaterial"
  30815. * Mainly use in serialization.
  30816. * @returns the class name
  30817. */
  30818. getClassName(): string;
  30819. /**
  30820. * Checks if the material is ready to render the requested sub mesh
  30821. * @param mesh Define the mesh the submesh belongs to
  30822. * @param subMesh Define the sub mesh to look readyness for
  30823. * @param useInstances Define whether or not the material is used with instances
  30824. * @returns true if ready, otherwise false
  30825. */
  30826. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30827. /**
  30828. * Clones the current material and its related sub materials
  30829. * @param name Define the name of the newly cloned material
  30830. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30831. * @returns the cloned material
  30832. */
  30833. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30834. /**
  30835. * Serializes the materials into a JSON representation.
  30836. * @returns the JSON representation
  30837. */
  30838. serialize(): any;
  30839. /**
  30840. * Dispose the material and release its associated resources
  30841. * @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)
  30842. * @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)
  30843. * @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)
  30844. */
  30845. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30846. /**
  30847. * Creates a MultiMaterial from parsed MultiMaterial data.
  30848. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30849. * @param scene defines the hosting scene
  30850. * @returns a new MultiMaterial
  30851. */
  30852. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30853. }
  30854. }
  30855. declare module BABYLON {
  30856. /** @hidden */
  30857. export interface ICustomEffect {
  30858. effect: Effect;
  30859. defines: string;
  30860. }
  30861. /**
  30862. * Defines a subdivision inside a mesh
  30863. */
  30864. export class SubMesh implements ICullable {
  30865. /** the material index to use */
  30866. materialIndex: number;
  30867. /** vertex index start */
  30868. verticesStart: number;
  30869. /** vertices count */
  30870. verticesCount: number;
  30871. /** index start */
  30872. indexStart: number;
  30873. /** indices count */
  30874. indexCount: number;
  30875. /** @hidden */
  30876. _materialDefines: Nullable<MaterialDefines>;
  30877. /** @hidden */
  30878. _materialEffect: Nullable<Effect>;
  30879. /** @hidden */
  30880. _effectOverride: Nullable<Effect>;
  30881. private _customEffects;
  30882. /**
  30883. * Gets material defines used by the effect associated to the sub mesh
  30884. */
  30885. get materialDefines(): Nullable<MaterialDefines>;
  30886. /**
  30887. * Sets material defines used by the effect associated to the sub mesh
  30888. */
  30889. set materialDefines(defines: Nullable<MaterialDefines>);
  30890. /** @hidden */
  30891. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  30892. /** @hidden */
  30893. _removeCustomEffect(name: string): void;
  30894. /**
  30895. * Gets associated effect
  30896. */
  30897. get effect(): Nullable<Effect>;
  30898. /**
  30899. * Sets associated effect (effect used to render this submesh)
  30900. * @param effect defines the effect to associate with
  30901. * @param defines defines the set of defines used to compile this effect
  30902. */
  30903. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30904. /** @hidden */
  30905. _linesIndexCount: number;
  30906. private _mesh;
  30907. private _renderingMesh;
  30908. private _boundingInfo;
  30909. private _linesIndexBuffer;
  30910. /** @hidden */
  30911. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30912. /** @hidden */
  30913. _trianglePlanes: Plane[];
  30914. /** @hidden */
  30915. _lastColliderTransformMatrix: Nullable<Matrix>;
  30916. /** @hidden */
  30917. _renderId: number;
  30918. /** @hidden */
  30919. _alphaIndex: number;
  30920. /** @hidden */
  30921. _distanceToCamera: number;
  30922. /** @hidden */
  30923. _id: number;
  30924. private _currentMaterial;
  30925. /**
  30926. * Add a new submesh to a mesh
  30927. * @param materialIndex defines the material index to use
  30928. * @param verticesStart defines vertex index start
  30929. * @param verticesCount defines vertices count
  30930. * @param indexStart defines index start
  30931. * @param indexCount defines indices count
  30932. * @param mesh defines the parent mesh
  30933. * @param renderingMesh defines an optional rendering mesh
  30934. * @param createBoundingBox defines if bounding box should be created for this submesh
  30935. * @returns the new submesh
  30936. */
  30937. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30938. /**
  30939. * Creates a new submesh
  30940. * @param materialIndex defines the material index to use
  30941. * @param verticesStart defines vertex index start
  30942. * @param verticesCount defines vertices count
  30943. * @param indexStart defines index start
  30944. * @param indexCount defines indices count
  30945. * @param mesh defines the parent mesh
  30946. * @param renderingMesh defines an optional rendering mesh
  30947. * @param createBoundingBox defines if bounding box should be created for this submesh
  30948. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30949. */
  30950. constructor(
  30951. /** the material index to use */
  30952. materialIndex: number,
  30953. /** vertex index start */
  30954. verticesStart: number,
  30955. /** vertices count */
  30956. verticesCount: number,
  30957. /** index start */
  30958. indexStart: number,
  30959. /** indices count */
  30960. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30961. /**
  30962. * Returns true if this submesh covers the entire parent mesh
  30963. * @ignorenaming
  30964. */
  30965. get IsGlobal(): boolean;
  30966. /**
  30967. * Returns the submesh BoudingInfo object
  30968. * @returns current bounding info (or mesh's one if the submesh is global)
  30969. */
  30970. getBoundingInfo(): BoundingInfo;
  30971. /**
  30972. * Sets the submesh BoundingInfo
  30973. * @param boundingInfo defines the new bounding info to use
  30974. * @returns the SubMesh
  30975. */
  30976. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30977. /**
  30978. * Returns the mesh of the current submesh
  30979. * @return the parent mesh
  30980. */
  30981. getMesh(): AbstractMesh;
  30982. /**
  30983. * Returns the rendering mesh of the submesh
  30984. * @returns the rendering mesh (could be different from parent mesh)
  30985. */
  30986. getRenderingMesh(): Mesh;
  30987. /**
  30988. * Returns the replacement mesh of the submesh
  30989. * @returns the replacement mesh (could be different from parent mesh)
  30990. */
  30991. getReplacementMesh(): Nullable<AbstractMesh>;
  30992. /**
  30993. * Returns the effective mesh of the submesh
  30994. * @returns the effective mesh (could be different from parent mesh)
  30995. */
  30996. getEffectiveMesh(): AbstractMesh;
  30997. /**
  30998. * Returns the submesh material
  30999. * @returns null or the current material
  31000. */
  31001. getMaterial(): Nullable<Material>;
  31002. private _IsMultiMaterial;
  31003. /**
  31004. * Sets a new updated BoundingInfo object to the submesh
  31005. * @param data defines an optional position array to use to determine the bounding info
  31006. * @returns the SubMesh
  31007. */
  31008. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31009. /** @hidden */
  31010. _checkCollision(collider: Collider): boolean;
  31011. /**
  31012. * Updates the submesh BoundingInfo
  31013. * @param world defines the world matrix to use to update the bounding info
  31014. * @returns the submesh
  31015. */
  31016. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31017. /**
  31018. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31019. * @param frustumPlanes defines the frustum planes
  31020. * @returns true if the submesh is intersecting with the frustum
  31021. */
  31022. isInFrustum(frustumPlanes: Plane[]): boolean;
  31023. /**
  31024. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31025. * @param frustumPlanes defines the frustum planes
  31026. * @returns true if the submesh is inside the frustum
  31027. */
  31028. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31029. /**
  31030. * Renders the submesh
  31031. * @param enableAlphaMode defines if alpha needs to be used
  31032. * @returns the submesh
  31033. */
  31034. render(enableAlphaMode: boolean): SubMesh;
  31035. /**
  31036. * @hidden
  31037. */
  31038. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31039. /**
  31040. * Checks if the submesh intersects with a ray
  31041. * @param ray defines the ray to test
  31042. * @returns true is the passed ray intersects the submesh bounding box
  31043. */
  31044. canIntersects(ray: Ray): boolean;
  31045. /**
  31046. * Intersects current submesh with a ray
  31047. * @param ray defines the ray to test
  31048. * @param positions defines mesh's positions array
  31049. * @param indices defines mesh's indices array
  31050. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31051. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31052. * @returns intersection info or null if no intersection
  31053. */
  31054. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31055. /** @hidden */
  31056. private _intersectLines;
  31057. /** @hidden */
  31058. private _intersectUnIndexedLines;
  31059. /** @hidden */
  31060. private _intersectTriangles;
  31061. /** @hidden */
  31062. private _intersectUnIndexedTriangles;
  31063. /** @hidden */
  31064. _rebuild(): void;
  31065. /**
  31066. * Creates a new submesh from the passed mesh
  31067. * @param newMesh defines the new hosting mesh
  31068. * @param newRenderingMesh defines an optional rendering mesh
  31069. * @returns the new submesh
  31070. */
  31071. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31072. /**
  31073. * Release associated resources
  31074. */
  31075. dispose(): void;
  31076. /**
  31077. * Gets the class name
  31078. * @returns the string "SubMesh".
  31079. */
  31080. getClassName(): string;
  31081. /**
  31082. * Creates a new submesh from indices data
  31083. * @param materialIndex the index of the main mesh material
  31084. * @param startIndex the index where to start the copy in the mesh indices array
  31085. * @param indexCount the number of indices to copy then from the startIndex
  31086. * @param mesh the main mesh to create the submesh from
  31087. * @param renderingMesh the optional rendering mesh
  31088. * @returns a new submesh
  31089. */
  31090. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31091. }
  31092. }
  31093. declare module BABYLON {
  31094. /**
  31095. * Class used to represent data loading progression
  31096. */
  31097. export class SceneLoaderFlags {
  31098. private static _ForceFullSceneLoadingForIncremental;
  31099. private static _ShowLoadingScreen;
  31100. private static _CleanBoneMatrixWeights;
  31101. private static _loggingLevel;
  31102. /**
  31103. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31104. */
  31105. static get ForceFullSceneLoadingForIncremental(): boolean;
  31106. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31107. /**
  31108. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31109. */
  31110. static get ShowLoadingScreen(): boolean;
  31111. static set ShowLoadingScreen(value: boolean);
  31112. /**
  31113. * Defines the current logging level (while loading the scene)
  31114. * @ignorenaming
  31115. */
  31116. static get loggingLevel(): number;
  31117. static set loggingLevel(value: number);
  31118. /**
  31119. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31120. */
  31121. static get CleanBoneMatrixWeights(): boolean;
  31122. static set CleanBoneMatrixWeights(value: boolean);
  31123. }
  31124. }
  31125. declare module BABYLON {
  31126. /**
  31127. * Class used to store geometry data (vertex buffers + index buffer)
  31128. */
  31129. export class Geometry implements IGetSetVerticesData {
  31130. /**
  31131. * Gets or sets the ID of the geometry
  31132. */
  31133. id: string;
  31134. /**
  31135. * Gets or sets the unique ID of the geometry
  31136. */
  31137. uniqueId: number;
  31138. /**
  31139. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31140. */
  31141. delayLoadState: number;
  31142. /**
  31143. * Gets the file containing the data to load when running in delay load state
  31144. */
  31145. delayLoadingFile: Nullable<string>;
  31146. /**
  31147. * Callback called when the geometry is updated
  31148. */
  31149. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31150. private _scene;
  31151. private _engine;
  31152. private _meshes;
  31153. private _totalVertices;
  31154. /** @hidden */
  31155. _indices: IndicesArray;
  31156. /** @hidden */
  31157. _vertexBuffers: {
  31158. [key: string]: VertexBuffer;
  31159. };
  31160. private _isDisposed;
  31161. private _extend;
  31162. private _boundingBias;
  31163. /** @hidden */
  31164. _delayInfo: Array<string>;
  31165. private _indexBuffer;
  31166. private _indexBufferIsUpdatable;
  31167. /** @hidden */
  31168. _boundingInfo: Nullable<BoundingInfo>;
  31169. /** @hidden */
  31170. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31171. /** @hidden */
  31172. _softwareSkinningFrameId: number;
  31173. private _vertexArrayObjects;
  31174. private _updatable;
  31175. /** @hidden */
  31176. _positions: Nullable<Vector3[]>;
  31177. private _positionsCache;
  31178. /**
  31179. * 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
  31180. */
  31181. get boundingBias(): Vector2;
  31182. /**
  31183. * 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
  31184. */
  31185. set boundingBias(value: Vector2);
  31186. /**
  31187. * Static function used to attach a new empty geometry to a mesh
  31188. * @param mesh defines the mesh to attach the geometry to
  31189. * @returns the new Geometry
  31190. */
  31191. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31192. /** Get the list of meshes using this geometry */
  31193. get meshes(): Mesh[];
  31194. /**
  31195. * 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
  31196. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31197. */
  31198. useBoundingInfoFromGeometry: boolean;
  31199. /**
  31200. * Creates a new geometry
  31201. * @param id defines the unique ID
  31202. * @param scene defines the hosting scene
  31203. * @param vertexData defines the VertexData used to get geometry data
  31204. * @param updatable defines if geometry must be updatable (false by default)
  31205. * @param mesh defines the mesh that will be associated with the geometry
  31206. */
  31207. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31208. /**
  31209. * Gets the current extend of the geometry
  31210. */
  31211. get extend(): {
  31212. minimum: Vector3;
  31213. maximum: Vector3;
  31214. };
  31215. /**
  31216. * Gets the hosting scene
  31217. * @returns the hosting Scene
  31218. */
  31219. getScene(): Scene;
  31220. /**
  31221. * Gets the hosting engine
  31222. * @returns the hosting Engine
  31223. */
  31224. getEngine(): Engine;
  31225. /**
  31226. * Defines if the geometry is ready to use
  31227. * @returns true if the geometry is ready to be used
  31228. */
  31229. isReady(): boolean;
  31230. /**
  31231. * Gets a value indicating that the geometry should not be serialized
  31232. */
  31233. get doNotSerialize(): boolean;
  31234. /** @hidden */
  31235. _rebuild(): void;
  31236. /**
  31237. * Affects all geometry data in one call
  31238. * @param vertexData defines the geometry data
  31239. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31240. */
  31241. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31242. /**
  31243. * Set specific vertex data
  31244. * @param kind defines the data kind (Position, normal, etc...)
  31245. * @param data defines the vertex data to use
  31246. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31247. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31248. */
  31249. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31250. /**
  31251. * Removes a specific vertex data
  31252. * @param kind defines the data kind (Position, normal, etc...)
  31253. */
  31254. removeVerticesData(kind: string): void;
  31255. /**
  31256. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31257. * @param buffer defines the vertex buffer to use
  31258. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31259. */
  31260. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31261. /**
  31262. * Update a specific vertex buffer
  31263. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31264. * It will do nothing if the buffer is not updatable
  31265. * @param kind defines the data kind (Position, normal, etc...)
  31266. * @param data defines the data to use
  31267. * @param offset defines the offset in the target buffer where to store the data
  31268. * @param useBytes set to true if the offset is in bytes
  31269. */
  31270. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31271. /**
  31272. * Update a specific vertex buffer
  31273. * This function will create a new buffer if the current one is not updatable
  31274. * @param kind defines the data kind (Position, normal, etc...)
  31275. * @param data defines the data to use
  31276. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31277. */
  31278. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31279. private _updateBoundingInfo;
  31280. /** @hidden */
  31281. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31282. [kind: string]: Nullable<VertexBuffer>;
  31283. }, overrideVertexArrayObjects?: {
  31284. [key: string]: WebGLVertexArrayObject;
  31285. }): void;
  31286. /**
  31287. * Gets total number of vertices
  31288. * @returns the total number of vertices
  31289. */
  31290. getTotalVertices(): number;
  31291. /**
  31292. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31293. * @param kind defines the data kind (Position, normal, etc...)
  31294. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31295. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31296. * @returns a float array containing vertex data
  31297. */
  31298. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31299. /**
  31300. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31301. * @param kind defines the data kind (Position, normal, etc...)
  31302. * @returns true if the vertex buffer with the specified kind is updatable
  31303. */
  31304. isVertexBufferUpdatable(kind: string): boolean;
  31305. /**
  31306. * Gets a specific vertex buffer
  31307. * @param kind defines the data kind (Position, normal, etc...)
  31308. * @returns a VertexBuffer
  31309. */
  31310. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31311. /**
  31312. * Returns all vertex buffers
  31313. * @return an object holding all vertex buffers indexed by kind
  31314. */
  31315. getVertexBuffers(): Nullable<{
  31316. [key: string]: VertexBuffer;
  31317. }>;
  31318. /**
  31319. * Gets a boolean indicating if specific vertex buffer is present
  31320. * @param kind defines the data kind (Position, normal, etc...)
  31321. * @returns true if data is present
  31322. */
  31323. isVerticesDataPresent(kind: string): boolean;
  31324. /**
  31325. * Gets a list of all attached data kinds (Position, normal, etc...)
  31326. * @returns a list of string containing all kinds
  31327. */
  31328. getVerticesDataKinds(): string[];
  31329. /**
  31330. * Update index buffer
  31331. * @param indices defines the indices to store in the index buffer
  31332. * @param offset defines the offset in the target buffer where to store the data
  31333. * @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)
  31334. */
  31335. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31336. /**
  31337. * Creates a new index buffer
  31338. * @param indices defines the indices to store in the index buffer
  31339. * @param totalVertices defines the total number of vertices (could be null)
  31340. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31341. */
  31342. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31343. /**
  31344. * Return the total number of indices
  31345. * @returns the total number of indices
  31346. */
  31347. getTotalIndices(): number;
  31348. /**
  31349. * Gets the index buffer array
  31350. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31351. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31352. * @returns the index buffer array
  31353. */
  31354. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31355. /**
  31356. * Gets the index buffer
  31357. * @return the index buffer
  31358. */
  31359. getIndexBuffer(): Nullable<DataBuffer>;
  31360. /** @hidden */
  31361. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31362. /**
  31363. * Release the associated resources for a specific mesh
  31364. * @param mesh defines the source mesh
  31365. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31366. */
  31367. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31368. /**
  31369. * Apply current geometry to a given mesh
  31370. * @param mesh defines the mesh to apply geometry to
  31371. */
  31372. applyToMesh(mesh: Mesh): void;
  31373. private _updateExtend;
  31374. private _applyToMesh;
  31375. private notifyUpdate;
  31376. /**
  31377. * Load the geometry if it was flagged as delay loaded
  31378. * @param scene defines the hosting scene
  31379. * @param onLoaded defines a callback called when the geometry is loaded
  31380. */
  31381. load(scene: Scene, onLoaded?: () => void): void;
  31382. private _queueLoad;
  31383. /**
  31384. * Invert the geometry to move from a right handed system to a left handed one.
  31385. */
  31386. toLeftHanded(): void;
  31387. /** @hidden */
  31388. _resetPointsArrayCache(): void;
  31389. /** @hidden */
  31390. _generatePointsArray(): boolean;
  31391. /**
  31392. * Gets a value indicating if the geometry is disposed
  31393. * @returns true if the geometry was disposed
  31394. */
  31395. isDisposed(): boolean;
  31396. private _disposeVertexArrayObjects;
  31397. /**
  31398. * Free all associated resources
  31399. */
  31400. dispose(): void;
  31401. /**
  31402. * Clone the current geometry into a new geometry
  31403. * @param id defines the unique ID of the new geometry
  31404. * @returns a new geometry object
  31405. */
  31406. copy(id: string): Geometry;
  31407. /**
  31408. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31409. * @return a JSON representation of the current geometry data (without the vertices data)
  31410. */
  31411. serialize(): any;
  31412. private toNumberArray;
  31413. /**
  31414. * Serialize all vertices data into a JSON oject
  31415. * @returns a JSON representation of the current geometry data
  31416. */
  31417. serializeVerticeData(): any;
  31418. /**
  31419. * Extracts a clone of a mesh geometry
  31420. * @param mesh defines the source mesh
  31421. * @param id defines the unique ID of the new geometry object
  31422. * @returns the new geometry object
  31423. */
  31424. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31425. /**
  31426. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31427. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31428. * Be aware Math.random() could cause collisions, but:
  31429. * "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"
  31430. * @returns a string containing a new GUID
  31431. */
  31432. static RandomId(): string;
  31433. /** @hidden */
  31434. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31435. private static _CleanMatricesWeights;
  31436. /**
  31437. * Create a new geometry from persisted data (Using .babylon file format)
  31438. * @param parsedVertexData defines the persisted data
  31439. * @param scene defines the hosting scene
  31440. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31441. * @returns the new geometry object
  31442. */
  31443. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31444. }
  31445. }
  31446. declare module BABYLON {
  31447. /**
  31448. * Defines a target to use with MorphTargetManager
  31449. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31450. */
  31451. export class MorphTarget implements IAnimatable {
  31452. /** defines the name of the target */
  31453. name: string;
  31454. /**
  31455. * Gets or sets the list of animations
  31456. */
  31457. animations: Animation[];
  31458. private _scene;
  31459. private _positions;
  31460. private _normals;
  31461. private _tangents;
  31462. private _uvs;
  31463. private _influence;
  31464. private _uniqueId;
  31465. /**
  31466. * Observable raised when the influence changes
  31467. */
  31468. onInfluenceChanged: Observable<boolean>;
  31469. /** @hidden */
  31470. _onDataLayoutChanged: Observable<void>;
  31471. /**
  31472. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31473. */
  31474. get influence(): number;
  31475. set influence(influence: number);
  31476. /**
  31477. * Gets or sets the id of the morph Target
  31478. */
  31479. id: string;
  31480. private _animationPropertiesOverride;
  31481. /**
  31482. * Gets or sets the animation properties override
  31483. */
  31484. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31485. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31486. /**
  31487. * Creates a new MorphTarget
  31488. * @param name defines the name of the target
  31489. * @param influence defines the influence to use
  31490. * @param scene defines the scene the morphtarget belongs to
  31491. */
  31492. constructor(
  31493. /** defines the name of the target */
  31494. name: string, influence?: number, scene?: Nullable<Scene>);
  31495. /**
  31496. * Gets the unique ID of this manager
  31497. */
  31498. get uniqueId(): number;
  31499. /**
  31500. * Gets a boolean defining if the target contains position data
  31501. */
  31502. get hasPositions(): boolean;
  31503. /**
  31504. * Gets a boolean defining if the target contains normal data
  31505. */
  31506. get hasNormals(): boolean;
  31507. /**
  31508. * Gets a boolean defining if the target contains tangent data
  31509. */
  31510. get hasTangents(): boolean;
  31511. /**
  31512. * Gets a boolean defining if the target contains texture coordinates data
  31513. */
  31514. get hasUVs(): boolean;
  31515. /**
  31516. * Affects position data to this target
  31517. * @param data defines the position data to use
  31518. */
  31519. setPositions(data: Nullable<FloatArray>): void;
  31520. /**
  31521. * Gets the position data stored in this target
  31522. * @returns a FloatArray containing the position data (or null if not present)
  31523. */
  31524. getPositions(): Nullable<FloatArray>;
  31525. /**
  31526. * Affects normal data to this target
  31527. * @param data defines the normal data to use
  31528. */
  31529. setNormals(data: Nullable<FloatArray>): void;
  31530. /**
  31531. * Gets the normal data stored in this target
  31532. * @returns a FloatArray containing the normal data (or null if not present)
  31533. */
  31534. getNormals(): Nullable<FloatArray>;
  31535. /**
  31536. * Affects tangent data to this target
  31537. * @param data defines the tangent data to use
  31538. */
  31539. setTangents(data: Nullable<FloatArray>): void;
  31540. /**
  31541. * Gets the tangent data stored in this target
  31542. * @returns a FloatArray containing the tangent data (or null if not present)
  31543. */
  31544. getTangents(): Nullable<FloatArray>;
  31545. /**
  31546. * Affects texture coordinates data to this target
  31547. * @param data defines the texture coordinates data to use
  31548. */
  31549. setUVs(data: Nullable<FloatArray>): void;
  31550. /**
  31551. * Gets the texture coordinates data stored in this target
  31552. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31553. */
  31554. getUVs(): Nullable<FloatArray>;
  31555. /**
  31556. * Clone the current target
  31557. * @returns a new MorphTarget
  31558. */
  31559. clone(): MorphTarget;
  31560. /**
  31561. * Serializes the current target into a Serialization object
  31562. * @returns the serialized object
  31563. */
  31564. serialize(): any;
  31565. /**
  31566. * Returns the string "MorphTarget"
  31567. * @returns "MorphTarget"
  31568. */
  31569. getClassName(): string;
  31570. /**
  31571. * Creates a new target from serialized data
  31572. * @param serializationObject defines the serialized data to use
  31573. * @returns a new MorphTarget
  31574. */
  31575. static Parse(serializationObject: any): MorphTarget;
  31576. /**
  31577. * Creates a MorphTarget from mesh data
  31578. * @param mesh defines the source mesh
  31579. * @param name defines the name to use for the new target
  31580. * @param influence defines the influence to attach to the target
  31581. * @returns a new MorphTarget
  31582. */
  31583. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31584. }
  31585. }
  31586. declare module BABYLON {
  31587. /**
  31588. * This class is used to deform meshes using morphing between different targets
  31589. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31590. */
  31591. export class MorphTargetManager {
  31592. private _targets;
  31593. private _targetInfluenceChangedObservers;
  31594. private _targetDataLayoutChangedObservers;
  31595. private _activeTargets;
  31596. private _scene;
  31597. private _influences;
  31598. private _supportsNormals;
  31599. private _supportsTangents;
  31600. private _supportsUVs;
  31601. private _vertexCount;
  31602. private _uniqueId;
  31603. private _tempInfluences;
  31604. /**
  31605. * Gets or sets a boolean indicating if normals must be morphed
  31606. */
  31607. enableNormalMorphing: boolean;
  31608. /**
  31609. * Gets or sets a boolean indicating if tangents must be morphed
  31610. */
  31611. enableTangentMorphing: boolean;
  31612. /**
  31613. * Gets or sets a boolean indicating if UV must be morphed
  31614. */
  31615. enableUVMorphing: boolean;
  31616. /**
  31617. * Creates a new MorphTargetManager
  31618. * @param scene defines the current scene
  31619. */
  31620. constructor(scene?: Nullable<Scene>);
  31621. /**
  31622. * Gets the unique ID of this manager
  31623. */
  31624. get uniqueId(): number;
  31625. /**
  31626. * Gets the number of vertices handled by this manager
  31627. */
  31628. get vertexCount(): number;
  31629. /**
  31630. * Gets a boolean indicating if this manager supports morphing of normals
  31631. */
  31632. get supportsNormals(): boolean;
  31633. /**
  31634. * Gets a boolean indicating if this manager supports morphing of tangents
  31635. */
  31636. get supportsTangents(): boolean;
  31637. /**
  31638. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31639. */
  31640. get supportsUVs(): boolean;
  31641. /**
  31642. * Gets the number of targets stored in this manager
  31643. */
  31644. get numTargets(): number;
  31645. /**
  31646. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31647. */
  31648. get numInfluencers(): number;
  31649. /**
  31650. * Gets the list of influences (one per target)
  31651. */
  31652. get influences(): Float32Array;
  31653. /**
  31654. * Gets the active target at specified index. An active target is a target with an influence > 0
  31655. * @param index defines the index to check
  31656. * @returns the requested target
  31657. */
  31658. getActiveTarget(index: number): MorphTarget;
  31659. /**
  31660. * Gets the target at specified index
  31661. * @param index defines the index to check
  31662. * @returns the requested target
  31663. */
  31664. getTarget(index: number): MorphTarget;
  31665. /**
  31666. * Add a new target to this manager
  31667. * @param target defines the target to add
  31668. */
  31669. addTarget(target: MorphTarget): void;
  31670. /**
  31671. * Removes a target from the manager
  31672. * @param target defines the target to remove
  31673. */
  31674. removeTarget(target: MorphTarget): void;
  31675. /**
  31676. * Clone the current manager
  31677. * @returns a new MorphTargetManager
  31678. */
  31679. clone(): MorphTargetManager;
  31680. /**
  31681. * Serializes the current manager into a Serialization object
  31682. * @returns the serialized object
  31683. */
  31684. serialize(): any;
  31685. private _syncActiveTargets;
  31686. /**
  31687. * Syncrhonize the targets with all the meshes using this morph target manager
  31688. */
  31689. synchronize(): void;
  31690. /**
  31691. * Creates a new MorphTargetManager from serialized data
  31692. * @param serializationObject defines the serialized data
  31693. * @param scene defines the hosting scene
  31694. * @returns the new MorphTargetManager
  31695. */
  31696. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31697. }
  31698. }
  31699. declare module BABYLON {
  31700. /**
  31701. * Class used to represent a specific level of detail of a mesh
  31702. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31703. */
  31704. export class MeshLODLevel {
  31705. /** Defines the distance where this level should start being displayed */
  31706. distance: number;
  31707. /** Defines the mesh to use to render this level */
  31708. mesh: Nullable<Mesh>;
  31709. /**
  31710. * Creates a new LOD level
  31711. * @param distance defines the distance where this level should star being displayed
  31712. * @param mesh defines the mesh to use to render this level
  31713. */
  31714. constructor(
  31715. /** Defines the distance where this level should start being displayed */
  31716. distance: number,
  31717. /** Defines the mesh to use to render this level */
  31718. mesh: Nullable<Mesh>);
  31719. }
  31720. }
  31721. declare module BABYLON {
  31722. /**
  31723. * Helper class used to generate a canvas to manipulate images
  31724. */
  31725. export class CanvasGenerator {
  31726. /**
  31727. * Create a new canvas (or offscreen canvas depending on the context)
  31728. * @param width defines the expected width
  31729. * @param height defines the expected height
  31730. * @return a new canvas or offscreen canvas
  31731. */
  31732. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31733. }
  31734. }
  31735. declare module BABYLON {
  31736. /**
  31737. * Mesh representing the gorund
  31738. */
  31739. export class GroundMesh extends Mesh {
  31740. /** If octree should be generated */
  31741. generateOctree: boolean;
  31742. private _heightQuads;
  31743. /** @hidden */
  31744. _subdivisionsX: number;
  31745. /** @hidden */
  31746. _subdivisionsY: number;
  31747. /** @hidden */
  31748. _width: number;
  31749. /** @hidden */
  31750. _height: number;
  31751. /** @hidden */
  31752. _minX: number;
  31753. /** @hidden */
  31754. _maxX: number;
  31755. /** @hidden */
  31756. _minZ: number;
  31757. /** @hidden */
  31758. _maxZ: number;
  31759. constructor(name: string, scene: Scene);
  31760. /**
  31761. * "GroundMesh"
  31762. * @returns "GroundMesh"
  31763. */
  31764. getClassName(): string;
  31765. /**
  31766. * The minimum of x and y subdivisions
  31767. */
  31768. get subdivisions(): number;
  31769. /**
  31770. * X subdivisions
  31771. */
  31772. get subdivisionsX(): number;
  31773. /**
  31774. * Y subdivisions
  31775. */
  31776. get subdivisionsY(): number;
  31777. /**
  31778. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31779. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31780. * @param chunksCount the number of subdivisions for x and y
  31781. * @param octreeBlocksSize (Default: 32)
  31782. */
  31783. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31784. /**
  31785. * Returns a height (y) value in the Worl system :
  31786. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31787. * @param x x coordinate
  31788. * @param z z coordinate
  31789. * @returns the ground y position if (x, z) are outside the ground surface.
  31790. */
  31791. getHeightAtCoordinates(x: number, z: number): number;
  31792. /**
  31793. * Returns a normalized vector (Vector3) orthogonal to the ground
  31794. * at the ground coordinates (x, z) expressed in the World system.
  31795. * @param x x coordinate
  31796. * @param z z coordinate
  31797. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31798. */
  31799. getNormalAtCoordinates(x: number, z: number): Vector3;
  31800. /**
  31801. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31802. * at the ground coordinates (x, z) expressed in the World system.
  31803. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31804. * @param x x coordinate
  31805. * @param z z coordinate
  31806. * @param ref vector to store the result
  31807. * @returns the GroundMesh.
  31808. */
  31809. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31810. /**
  31811. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31812. * if the ground has been updated.
  31813. * This can be used in the render loop.
  31814. * @returns the GroundMesh.
  31815. */
  31816. updateCoordinateHeights(): GroundMesh;
  31817. private _getFacetAt;
  31818. private _initHeightQuads;
  31819. private _computeHeightQuads;
  31820. /**
  31821. * Serializes this ground mesh
  31822. * @param serializationObject object to write serialization to
  31823. */
  31824. serialize(serializationObject: any): void;
  31825. /**
  31826. * Parses a serialized ground mesh
  31827. * @param parsedMesh the serialized mesh
  31828. * @param scene the scene to create the ground mesh in
  31829. * @returns the created ground mesh
  31830. */
  31831. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31832. }
  31833. }
  31834. declare module BABYLON {
  31835. /**
  31836. * Interface for Physics-Joint data
  31837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31838. */
  31839. export interface PhysicsJointData {
  31840. /**
  31841. * The main pivot of the joint
  31842. */
  31843. mainPivot?: Vector3;
  31844. /**
  31845. * The connected pivot of the joint
  31846. */
  31847. connectedPivot?: Vector3;
  31848. /**
  31849. * The main axis of the joint
  31850. */
  31851. mainAxis?: Vector3;
  31852. /**
  31853. * The connected axis of the joint
  31854. */
  31855. connectedAxis?: Vector3;
  31856. /**
  31857. * The collision of the joint
  31858. */
  31859. collision?: boolean;
  31860. /**
  31861. * Native Oimo/Cannon/Energy data
  31862. */
  31863. nativeParams?: any;
  31864. }
  31865. /**
  31866. * This is a holder class for the physics joint created by the physics plugin
  31867. * It holds a set of functions to control the underlying joint
  31868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31869. */
  31870. export class PhysicsJoint {
  31871. /**
  31872. * The type of the physics joint
  31873. */
  31874. type: number;
  31875. /**
  31876. * The data for the physics joint
  31877. */
  31878. jointData: PhysicsJointData;
  31879. private _physicsJoint;
  31880. protected _physicsPlugin: IPhysicsEnginePlugin;
  31881. /**
  31882. * Initializes the physics joint
  31883. * @param type The type of the physics joint
  31884. * @param jointData The data for the physics joint
  31885. */
  31886. constructor(
  31887. /**
  31888. * The type of the physics joint
  31889. */
  31890. type: number,
  31891. /**
  31892. * The data for the physics joint
  31893. */
  31894. jointData: PhysicsJointData);
  31895. /**
  31896. * Gets the physics joint
  31897. */
  31898. get physicsJoint(): any;
  31899. /**
  31900. * Sets the physics joint
  31901. */
  31902. set physicsJoint(newJoint: any);
  31903. /**
  31904. * Sets the physics plugin
  31905. */
  31906. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31907. /**
  31908. * Execute a function that is physics-plugin specific.
  31909. * @param {Function} func the function that will be executed.
  31910. * It accepts two parameters: the physics world and the physics joint
  31911. */
  31912. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31913. /**
  31914. * Distance-Joint type
  31915. */
  31916. static DistanceJoint: number;
  31917. /**
  31918. * Hinge-Joint type
  31919. */
  31920. static HingeJoint: number;
  31921. /**
  31922. * Ball-and-Socket joint type
  31923. */
  31924. static BallAndSocketJoint: number;
  31925. /**
  31926. * Wheel-Joint type
  31927. */
  31928. static WheelJoint: number;
  31929. /**
  31930. * Slider-Joint type
  31931. */
  31932. static SliderJoint: number;
  31933. /**
  31934. * Prismatic-Joint type
  31935. */
  31936. static PrismaticJoint: number;
  31937. /**
  31938. * Universal-Joint type
  31939. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31940. */
  31941. static UniversalJoint: number;
  31942. /**
  31943. * Hinge-Joint 2 type
  31944. */
  31945. static Hinge2Joint: number;
  31946. /**
  31947. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31948. */
  31949. static PointToPointJoint: number;
  31950. /**
  31951. * Spring-Joint type
  31952. */
  31953. static SpringJoint: number;
  31954. /**
  31955. * Lock-Joint type
  31956. */
  31957. static LockJoint: number;
  31958. }
  31959. /**
  31960. * A class representing a physics distance joint
  31961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31962. */
  31963. export class DistanceJoint extends PhysicsJoint {
  31964. /**
  31965. *
  31966. * @param jointData The data for the Distance-Joint
  31967. */
  31968. constructor(jointData: DistanceJointData);
  31969. /**
  31970. * Update the predefined distance.
  31971. * @param maxDistance The maximum preferred distance
  31972. * @param minDistance The minimum preferred distance
  31973. */
  31974. updateDistance(maxDistance: number, minDistance?: number): void;
  31975. }
  31976. /**
  31977. * Represents a Motor-Enabled Joint
  31978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31979. */
  31980. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31981. /**
  31982. * Initializes the Motor-Enabled Joint
  31983. * @param type The type of the joint
  31984. * @param jointData The physica joint data for the joint
  31985. */
  31986. constructor(type: number, jointData: PhysicsJointData);
  31987. /**
  31988. * Set the motor values.
  31989. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31990. * @param force the force to apply
  31991. * @param maxForce max force for this motor.
  31992. */
  31993. setMotor(force?: number, maxForce?: number): void;
  31994. /**
  31995. * Set the motor's limits.
  31996. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31997. * @param upperLimit The upper limit of the motor
  31998. * @param lowerLimit The lower limit of the motor
  31999. */
  32000. setLimit(upperLimit: number, lowerLimit?: number): void;
  32001. }
  32002. /**
  32003. * This class represents a single physics Hinge-Joint
  32004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32005. */
  32006. export class HingeJoint extends MotorEnabledJoint {
  32007. /**
  32008. * Initializes the Hinge-Joint
  32009. * @param jointData The joint data for the Hinge-Joint
  32010. */
  32011. constructor(jointData: PhysicsJointData);
  32012. /**
  32013. * Set the motor values.
  32014. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32015. * @param {number} force the force to apply
  32016. * @param {number} maxForce max force for this motor.
  32017. */
  32018. setMotor(force?: number, maxForce?: number): void;
  32019. /**
  32020. * Set the motor's limits.
  32021. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32022. * @param upperLimit The upper limit of the motor
  32023. * @param lowerLimit The lower limit of the motor
  32024. */
  32025. setLimit(upperLimit: number, lowerLimit?: number): void;
  32026. }
  32027. /**
  32028. * This class represents a dual hinge physics joint (same as wheel joint)
  32029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32030. */
  32031. export class Hinge2Joint extends MotorEnabledJoint {
  32032. /**
  32033. * Initializes the Hinge2-Joint
  32034. * @param jointData The joint data for the Hinge2-Joint
  32035. */
  32036. constructor(jointData: PhysicsJointData);
  32037. /**
  32038. * Set the motor values.
  32039. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32040. * @param {number} targetSpeed the speed the motor is to reach
  32041. * @param {number} maxForce max force for this motor.
  32042. * @param {motorIndex} the motor's index, 0 or 1.
  32043. */
  32044. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32045. /**
  32046. * Set the motor limits.
  32047. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32048. * @param {number} upperLimit the upper limit
  32049. * @param {number} lowerLimit lower limit
  32050. * @param {motorIndex} the motor's index, 0 or 1.
  32051. */
  32052. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32053. }
  32054. /**
  32055. * Interface for a motor enabled joint
  32056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32057. */
  32058. export interface IMotorEnabledJoint {
  32059. /**
  32060. * Physics joint
  32061. */
  32062. physicsJoint: any;
  32063. /**
  32064. * Sets the motor of the motor-enabled joint
  32065. * @param force The force of the motor
  32066. * @param maxForce The maximum force of the motor
  32067. * @param motorIndex The index of the motor
  32068. */
  32069. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32070. /**
  32071. * Sets the limit of the motor
  32072. * @param upperLimit The upper limit of the motor
  32073. * @param lowerLimit The lower limit of the motor
  32074. * @param motorIndex The index of the motor
  32075. */
  32076. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32077. }
  32078. /**
  32079. * Joint data for a Distance-Joint
  32080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32081. */
  32082. export interface DistanceJointData extends PhysicsJointData {
  32083. /**
  32084. * Max distance the 2 joint objects can be apart
  32085. */
  32086. maxDistance: number;
  32087. }
  32088. /**
  32089. * Joint data from a spring joint
  32090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32091. */
  32092. export interface SpringJointData extends PhysicsJointData {
  32093. /**
  32094. * Length of the spring
  32095. */
  32096. length: number;
  32097. /**
  32098. * Stiffness of the spring
  32099. */
  32100. stiffness: number;
  32101. /**
  32102. * Damping of the spring
  32103. */
  32104. damping: number;
  32105. /** this callback will be called when applying the force to the impostors. */
  32106. forceApplicationCallback: () => void;
  32107. }
  32108. }
  32109. declare module BABYLON {
  32110. /**
  32111. * Holds the data for the raycast result
  32112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32113. */
  32114. export class PhysicsRaycastResult {
  32115. private _hasHit;
  32116. private _hitDistance;
  32117. private _hitNormalWorld;
  32118. private _hitPointWorld;
  32119. private _rayFromWorld;
  32120. private _rayToWorld;
  32121. /**
  32122. * Gets if there was a hit
  32123. */
  32124. get hasHit(): boolean;
  32125. /**
  32126. * Gets the distance from the hit
  32127. */
  32128. get hitDistance(): number;
  32129. /**
  32130. * Gets the hit normal/direction in the world
  32131. */
  32132. get hitNormalWorld(): Vector3;
  32133. /**
  32134. * Gets the hit point in the world
  32135. */
  32136. get hitPointWorld(): Vector3;
  32137. /**
  32138. * Gets the ray "start point" of the ray in the world
  32139. */
  32140. get rayFromWorld(): Vector3;
  32141. /**
  32142. * Gets the ray "end point" of the ray in the world
  32143. */
  32144. get rayToWorld(): Vector3;
  32145. /**
  32146. * Sets the hit data (normal & point in world space)
  32147. * @param hitNormalWorld defines the normal in world space
  32148. * @param hitPointWorld defines the point in world space
  32149. */
  32150. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32151. /**
  32152. * Sets the distance from the start point to the hit point
  32153. * @param distance
  32154. */
  32155. setHitDistance(distance: number): void;
  32156. /**
  32157. * Calculates the distance manually
  32158. */
  32159. calculateHitDistance(): void;
  32160. /**
  32161. * Resets all the values to default
  32162. * @param from The from point on world space
  32163. * @param to The to point on world space
  32164. */
  32165. reset(from?: Vector3, to?: Vector3): void;
  32166. }
  32167. /**
  32168. * Interface for the size containing width and height
  32169. */
  32170. interface IXYZ {
  32171. /**
  32172. * X
  32173. */
  32174. x: number;
  32175. /**
  32176. * Y
  32177. */
  32178. y: number;
  32179. /**
  32180. * Z
  32181. */
  32182. z: number;
  32183. }
  32184. }
  32185. declare module BABYLON {
  32186. /**
  32187. * Interface used to describe a physics joint
  32188. */
  32189. export interface PhysicsImpostorJoint {
  32190. /** Defines the main impostor to which the joint is linked */
  32191. mainImpostor: PhysicsImpostor;
  32192. /** Defines the impostor that is connected to the main impostor using this joint */
  32193. connectedImpostor: PhysicsImpostor;
  32194. /** Defines the joint itself */
  32195. joint: PhysicsJoint;
  32196. }
  32197. /** @hidden */
  32198. export interface IPhysicsEnginePlugin {
  32199. world: any;
  32200. name: string;
  32201. setGravity(gravity: Vector3): void;
  32202. setTimeStep(timeStep: number): void;
  32203. getTimeStep(): number;
  32204. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32205. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32206. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32207. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32208. removePhysicsBody(impostor: PhysicsImpostor): void;
  32209. generateJoint(joint: PhysicsImpostorJoint): void;
  32210. removeJoint(joint: PhysicsImpostorJoint): void;
  32211. isSupported(): boolean;
  32212. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32213. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32214. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32215. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32216. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32217. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32218. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32219. getBodyMass(impostor: PhysicsImpostor): number;
  32220. getBodyFriction(impostor: PhysicsImpostor): number;
  32221. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32222. getBodyRestitution(impostor: PhysicsImpostor): number;
  32223. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32224. getBodyPressure?(impostor: PhysicsImpostor): number;
  32225. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32226. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32227. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32228. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32229. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32230. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32231. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32232. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32233. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32234. sleepBody(impostor: PhysicsImpostor): void;
  32235. wakeUpBody(impostor: PhysicsImpostor): void;
  32236. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32237. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32238. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32239. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32240. getRadius(impostor: PhysicsImpostor): number;
  32241. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32242. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32243. dispose(): void;
  32244. }
  32245. /**
  32246. * Interface used to define a physics engine
  32247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32248. */
  32249. export interface IPhysicsEngine {
  32250. /**
  32251. * Gets the gravity vector used by the simulation
  32252. */
  32253. gravity: Vector3;
  32254. /**
  32255. * Sets the gravity vector used by the simulation
  32256. * @param gravity defines the gravity vector to use
  32257. */
  32258. setGravity(gravity: Vector3): void;
  32259. /**
  32260. * Set the time step of the physics engine.
  32261. * Default is 1/60.
  32262. * To slow it down, enter 1/600 for example.
  32263. * To speed it up, 1/30
  32264. * @param newTimeStep the new timestep to apply to this world.
  32265. */
  32266. setTimeStep(newTimeStep: number): void;
  32267. /**
  32268. * Get the time step of the physics engine.
  32269. * @returns the current time step
  32270. */
  32271. getTimeStep(): number;
  32272. /**
  32273. * Set the sub time step of the physics engine.
  32274. * Default is 0 meaning there is no sub steps
  32275. * To increase physics resolution precision, set a small value (like 1 ms)
  32276. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32277. */
  32278. setSubTimeStep(subTimeStep: number): void;
  32279. /**
  32280. * Get the sub time step of the physics engine.
  32281. * @returns the current sub time step
  32282. */
  32283. getSubTimeStep(): number;
  32284. /**
  32285. * Release all resources
  32286. */
  32287. dispose(): void;
  32288. /**
  32289. * Gets the name of the current physics plugin
  32290. * @returns the name of the plugin
  32291. */
  32292. getPhysicsPluginName(): string;
  32293. /**
  32294. * Adding a new impostor for the impostor tracking.
  32295. * This will be done by the impostor itself.
  32296. * @param impostor the impostor to add
  32297. */
  32298. addImpostor(impostor: PhysicsImpostor): void;
  32299. /**
  32300. * Remove an impostor from the engine.
  32301. * This impostor and its mesh will not longer be updated by the physics engine.
  32302. * @param impostor the impostor to remove
  32303. */
  32304. removeImpostor(impostor: PhysicsImpostor): void;
  32305. /**
  32306. * Add a joint to the physics engine
  32307. * @param mainImpostor defines the main impostor to which the joint is added.
  32308. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32309. * @param joint defines the joint that will connect both impostors.
  32310. */
  32311. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32312. /**
  32313. * Removes a joint from the simulation
  32314. * @param mainImpostor defines the impostor used with the joint
  32315. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32316. * @param joint defines the joint to remove
  32317. */
  32318. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32319. /**
  32320. * Gets the current plugin used to run the simulation
  32321. * @returns current plugin
  32322. */
  32323. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32324. /**
  32325. * Gets the list of physic impostors
  32326. * @returns an array of PhysicsImpostor
  32327. */
  32328. getImpostors(): Array<PhysicsImpostor>;
  32329. /**
  32330. * Gets the impostor for a physics enabled object
  32331. * @param object defines the object impersonated by the impostor
  32332. * @returns the PhysicsImpostor or null if not found
  32333. */
  32334. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32335. /**
  32336. * Gets the impostor for a physics body object
  32337. * @param body defines physics body used by the impostor
  32338. * @returns the PhysicsImpostor or null if not found
  32339. */
  32340. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32341. /**
  32342. * Does a raycast in the physics world
  32343. * @param from when should the ray start?
  32344. * @param to when should the ray end?
  32345. * @returns PhysicsRaycastResult
  32346. */
  32347. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32348. /**
  32349. * Called by the scene. No need to call it.
  32350. * @param delta defines the timespam between frames
  32351. */
  32352. _step(delta: number): void;
  32353. }
  32354. }
  32355. declare module BABYLON {
  32356. /**
  32357. * The interface for the physics imposter parameters
  32358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32359. */
  32360. export interface PhysicsImpostorParameters {
  32361. /**
  32362. * The mass of the physics imposter
  32363. */
  32364. mass: number;
  32365. /**
  32366. * The friction of the physics imposter
  32367. */
  32368. friction?: number;
  32369. /**
  32370. * The coefficient of restitution of the physics imposter
  32371. */
  32372. restitution?: number;
  32373. /**
  32374. * The native options of the physics imposter
  32375. */
  32376. nativeOptions?: any;
  32377. /**
  32378. * Specifies if the parent should be ignored
  32379. */
  32380. ignoreParent?: boolean;
  32381. /**
  32382. * Specifies if bi-directional transformations should be disabled
  32383. */
  32384. disableBidirectionalTransformation?: boolean;
  32385. /**
  32386. * The pressure inside the physics imposter, soft object only
  32387. */
  32388. pressure?: number;
  32389. /**
  32390. * The stiffness the physics imposter, soft object only
  32391. */
  32392. stiffness?: number;
  32393. /**
  32394. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32395. */
  32396. velocityIterations?: number;
  32397. /**
  32398. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32399. */
  32400. positionIterations?: number;
  32401. /**
  32402. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32403. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32404. * Add to fix multiple points
  32405. */
  32406. fixedPoints?: number;
  32407. /**
  32408. * The collision margin around a soft object
  32409. */
  32410. margin?: number;
  32411. /**
  32412. * The collision margin around a soft object
  32413. */
  32414. damping?: number;
  32415. /**
  32416. * The path for a rope based on an extrusion
  32417. */
  32418. path?: any;
  32419. /**
  32420. * The shape of an extrusion used for a rope based on an extrusion
  32421. */
  32422. shape?: any;
  32423. }
  32424. /**
  32425. * Interface for a physics-enabled object
  32426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32427. */
  32428. export interface IPhysicsEnabledObject {
  32429. /**
  32430. * The position of the physics-enabled object
  32431. */
  32432. position: Vector3;
  32433. /**
  32434. * The rotation of the physics-enabled object
  32435. */
  32436. rotationQuaternion: Nullable<Quaternion>;
  32437. /**
  32438. * The scale of the physics-enabled object
  32439. */
  32440. scaling: Vector3;
  32441. /**
  32442. * The rotation of the physics-enabled object
  32443. */
  32444. rotation?: Vector3;
  32445. /**
  32446. * The parent of the physics-enabled object
  32447. */
  32448. parent?: any;
  32449. /**
  32450. * The bounding info of the physics-enabled object
  32451. * @returns The bounding info of the physics-enabled object
  32452. */
  32453. getBoundingInfo(): BoundingInfo;
  32454. /**
  32455. * Computes the world matrix
  32456. * @param force Specifies if the world matrix should be computed by force
  32457. * @returns A world matrix
  32458. */
  32459. computeWorldMatrix(force: boolean): Matrix;
  32460. /**
  32461. * Gets the world matrix
  32462. * @returns A world matrix
  32463. */
  32464. getWorldMatrix?(): Matrix;
  32465. /**
  32466. * Gets the child meshes
  32467. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32468. * @returns An array of abstract meshes
  32469. */
  32470. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32471. /**
  32472. * Gets the vertex data
  32473. * @param kind The type of vertex data
  32474. * @returns A nullable array of numbers, or a float32 array
  32475. */
  32476. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32477. /**
  32478. * Gets the indices from the mesh
  32479. * @returns A nullable array of index arrays
  32480. */
  32481. getIndices?(): Nullable<IndicesArray>;
  32482. /**
  32483. * Gets the scene from the mesh
  32484. * @returns the indices array or null
  32485. */
  32486. getScene?(): Scene;
  32487. /**
  32488. * Gets the absolute position from the mesh
  32489. * @returns the absolute position
  32490. */
  32491. getAbsolutePosition(): Vector3;
  32492. /**
  32493. * Gets the absolute pivot point from the mesh
  32494. * @returns the absolute pivot point
  32495. */
  32496. getAbsolutePivotPoint(): Vector3;
  32497. /**
  32498. * Rotates the mesh
  32499. * @param axis The axis of rotation
  32500. * @param amount The amount of rotation
  32501. * @param space The space of the rotation
  32502. * @returns The rotation transform node
  32503. */
  32504. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32505. /**
  32506. * Translates the mesh
  32507. * @param axis The axis of translation
  32508. * @param distance The distance of translation
  32509. * @param space The space of the translation
  32510. * @returns The transform node
  32511. */
  32512. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32513. /**
  32514. * Sets the absolute position of the mesh
  32515. * @param absolutePosition The absolute position of the mesh
  32516. * @returns The transform node
  32517. */
  32518. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32519. /**
  32520. * Gets the class name of the mesh
  32521. * @returns The class name
  32522. */
  32523. getClassName(): string;
  32524. }
  32525. /**
  32526. * Represents a physics imposter
  32527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32528. */
  32529. export class PhysicsImpostor {
  32530. /**
  32531. * The physics-enabled object used as the physics imposter
  32532. */
  32533. object: IPhysicsEnabledObject;
  32534. /**
  32535. * The type of the physics imposter
  32536. */
  32537. type: number;
  32538. private _options;
  32539. private _scene?;
  32540. /**
  32541. * The default object size of the imposter
  32542. */
  32543. static DEFAULT_OBJECT_SIZE: Vector3;
  32544. /**
  32545. * The identity quaternion of the imposter
  32546. */
  32547. static IDENTITY_QUATERNION: Quaternion;
  32548. /** @hidden */
  32549. _pluginData: any;
  32550. private _physicsEngine;
  32551. private _physicsBody;
  32552. private _bodyUpdateRequired;
  32553. private _onBeforePhysicsStepCallbacks;
  32554. private _onAfterPhysicsStepCallbacks;
  32555. /** @hidden */
  32556. _onPhysicsCollideCallbacks: Array<{
  32557. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32558. otherImpostors: Array<PhysicsImpostor>;
  32559. }>;
  32560. private _deltaPosition;
  32561. private _deltaRotation;
  32562. private _deltaRotationConjugated;
  32563. /** @hidden */
  32564. _isFromLine: boolean;
  32565. private _parent;
  32566. private _isDisposed;
  32567. private static _tmpVecs;
  32568. private static _tmpQuat;
  32569. /**
  32570. * Specifies if the physics imposter is disposed
  32571. */
  32572. get isDisposed(): boolean;
  32573. /**
  32574. * Gets the mass of the physics imposter
  32575. */
  32576. get mass(): number;
  32577. set mass(value: number);
  32578. /**
  32579. * Gets the coefficient of friction
  32580. */
  32581. get friction(): number;
  32582. /**
  32583. * Sets the coefficient of friction
  32584. */
  32585. set friction(value: number);
  32586. /**
  32587. * Gets the coefficient of restitution
  32588. */
  32589. get restitution(): number;
  32590. /**
  32591. * Sets the coefficient of restitution
  32592. */
  32593. set restitution(value: number);
  32594. /**
  32595. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32596. */
  32597. get pressure(): number;
  32598. /**
  32599. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32600. */
  32601. set pressure(value: number);
  32602. /**
  32603. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32604. */
  32605. get stiffness(): number;
  32606. /**
  32607. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32608. */
  32609. set stiffness(value: number);
  32610. /**
  32611. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32612. */
  32613. get velocityIterations(): number;
  32614. /**
  32615. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32616. */
  32617. set velocityIterations(value: number);
  32618. /**
  32619. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32620. */
  32621. get positionIterations(): number;
  32622. /**
  32623. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32624. */
  32625. set positionIterations(value: number);
  32626. /**
  32627. * The unique id of the physics imposter
  32628. * set by the physics engine when adding this impostor to the array
  32629. */
  32630. uniqueId: number;
  32631. /**
  32632. * @hidden
  32633. */
  32634. soft: boolean;
  32635. /**
  32636. * @hidden
  32637. */
  32638. segments: number;
  32639. private _joints;
  32640. /**
  32641. * Initializes the physics imposter
  32642. * @param object The physics-enabled object used as the physics imposter
  32643. * @param type The type of the physics imposter
  32644. * @param _options The options for the physics imposter
  32645. * @param _scene The Babylon scene
  32646. */
  32647. constructor(
  32648. /**
  32649. * The physics-enabled object used as the physics imposter
  32650. */
  32651. object: IPhysicsEnabledObject,
  32652. /**
  32653. * The type of the physics imposter
  32654. */
  32655. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32656. /**
  32657. * This function will completly initialize this impostor.
  32658. * It will create a new body - but only if this mesh has no parent.
  32659. * If it has, this impostor will not be used other than to define the impostor
  32660. * of the child mesh.
  32661. * @hidden
  32662. */
  32663. _init(): void;
  32664. private _getPhysicsParent;
  32665. /**
  32666. * Should a new body be generated.
  32667. * @returns boolean specifying if body initialization is required
  32668. */
  32669. isBodyInitRequired(): boolean;
  32670. /**
  32671. * Sets the updated scaling
  32672. * @param updated Specifies if the scaling is updated
  32673. */
  32674. setScalingUpdated(): void;
  32675. /**
  32676. * Force a regeneration of this or the parent's impostor's body.
  32677. * Use under cautious - This will remove all joints already implemented.
  32678. */
  32679. forceUpdate(): void;
  32680. /**
  32681. * Gets the body that holds this impostor. Either its own, or its parent.
  32682. */
  32683. get physicsBody(): any;
  32684. /**
  32685. * Get the parent of the physics imposter
  32686. * @returns Physics imposter or null
  32687. */
  32688. get parent(): Nullable<PhysicsImpostor>;
  32689. /**
  32690. * Sets the parent of the physics imposter
  32691. */
  32692. set parent(value: Nullable<PhysicsImpostor>);
  32693. /**
  32694. * Set the physics body. Used mainly by the physics engine/plugin
  32695. */
  32696. set physicsBody(physicsBody: any);
  32697. /**
  32698. * Resets the update flags
  32699. */
  32700. resetUpdateFlags(): void;
  32701. /**
  32702. * Gets the object extend size
  32703. * @returns the object extend size
  32704. */
  32705. getObjectExtendSize(): Vector3;
  32706. /**
  32707. * Gets the object center
  32708. * @returns The object center
  32709. */
  32710. getObjectCenter(): Vector3;
  32711. /**
  32712. * Get a specific parameter from the options parameters
  32713. * @param paramName The object parameter name
  32714. * @returns The object parameter
  32715. */
  32716. getParam(paramName: string): any;
  32717. /**
  32718. * Sets a specific parameter in the options given to the physics plugin
  32719. * @param paramName The parameter name
  32720. * @param value The value of the parameter
  32721. */
  32722. setParam(paramName: string, value: number): void;
  32723. /**
  32724. * Specifically change the body's mass option. Won't recreate the physics body object
  32725. * @param mass The mass of the physics imposter
  32726. */
  32727. setMass(mass: number): void;
  32728. /**
  32729. * Gets the linear velocity
  32730. * @returns linear velocity or null
  32731. */
  32732. getLinearVelocity(): Nullable<Vector3>;
  32733. /**
  32734. * Sets the linear velocity
  32735. * @param velocity linear velocity or null
  32736. */
  32737. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32738. /**
  32739. * Gets the angular velocity
  32740. * @returns angular velocity or null
  32741. */
  32742. getAngularVelocity(): Nullable<Vector3>;
  32743. /**
  32744. * Sets the angular velocity
  32745. * @param velocity The velocity or null
  32746. */
  32747. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32748. /**
  32749. * Execute a function with the physics plugin native code
  32750. * Provide a function the will have two variables - the world object and the physics body object
  32751. * @param func The function to execute with the physics plugin native code
  32752. */
  32753. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32754. /**
  32755. * Register a function that will be executed before the physics world is stepping forward
  32756. * @param func The function to execute before the physics world is stepped forward
  32757. */
  32758. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32759. /**
  32760. * Unregister a function that will be executed before the physics world is stepping forward
  32761. * @param func The function to execute before the physics world is stepped forward
  32762. */
  32763. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32764. /**
  32765. * Register a function that will be executed after the physics step
  32766. * @param func The function to execute after physics step
  32767. */
  32768. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32769. /**
  32770. * Unregisters a function that will be executed after the physics step
  32771. * @param func The function to execute after physics step
  32772. */
  32773. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32774. /**
  32775. * register a function that will be executed when this impostor collides against a different body
  32776. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32777. * @param func Callback that is executed on collision
  32778. */
  32779. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32780. /**
  32781. * Unregisters the physics imposter on contact
  32782. * @param collideAgainst The physics object to collide against
  32783. * @param func Callback to execute on collision
  32784. */
  32785. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32786. private _tmpQuat;
  32787. private _tmpQuat2;
  32788. /**
  32789. * Get the parent rotation
  32790. * @returns The parent rotation
  32791. */
  32792. getParentsRotation(): Quaternion;
  32793. /**
  32794. * this function is executed by the physics engine.
  32795. */
  32796. beforeStep: () => void;
  32797. /**
  32798. * this function is executed by the physics engine
  32799. */
  32800. afterStep: () => void;
  32801. /**
  32802. * Legacy collision detection event support
  32803. */
  32804. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32805. /**
  32806. * event and body object due to cannon's event-based architecture.
  32807. */
  32808. onCollide: (e: {
  32809. body: any;
  32810. point: Nullable<Vector3>;
  32811. }) => void;
  32812. /**
  32813. * Apply a force
  32814. * @param force The force to apply
  32815. * @param contactPoint The contact point for the force
  32816. * @returns The physics imposter
  32817. */
  32818. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32819. /**
  32820. * Apply an impulse
  32821. * @param force The impulse force
  32822. * @param contactPoint The contact point for the impulse force
  32823. * @returns The physics imposter
  32824. */
  32825. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32826. /**
  32827. * A help function to create a joint
  32828. * @param otherImpostor A physics imposter used to create a joint
  32829. * @param jointType The type of joint
  32830. * @param jointData The data for the joint
  32831. * @returns The physics imposter
  32832. */
  32833. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32834. /**
  32835. * Add a joint to this impostor with a different impostor
  32836. * @param otherImpostor A physics imposter used to add a joint
  32837. * @param joint The joint to add
  32838. * @returns The physics imposter
  32839. */
  32840. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32841. /**
  32842. * Add an anchor to a cloth impostor
  32843. * @param otherImpostor rigid impostor to anchor to
  32844. * @param width ratio across width from 0 to 1
  32845. * @param height ratio up height from 0 to 1
  32846. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32847. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32848. * @returns impostor the soft imposter
  32849. */
  32850. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32851. /**
  32852. * Add a hook to a rope impostor
  32853. * @param otherImpostor rigid impostor to anchor to
  32854. * @param length ratio across rope from 0 to 1
  32855. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32856. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32857. * @returns impostor the rope imposter
  32858. */
  32859. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32860. /**
  32861. * Will keep this body still, in a sleep mode.
  32862. * @returns the physics imposter
  32863. */
  32864. sleep(): PhysicsImpostor;
  32865. /**
  32866. * Wake the body up.
  32867. * @returns The physics imposter
  32868. */
  32869. wakeUp(): PhysicsImpostor;
  32870. /**
  32871. * Clones the physics imposter
  32872. * @param newObject The physics imposter clones to this physics-enabled object
  32873. * @returns A nullable physics imposter
  32874. */
  32875. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32876. /**
  32877. * Disposes the physics imposter
  32878. */
  32879. dispose(): void;
  32880. /**
  32881. * Sets the delta position
  32882. * @param position The delta position amount
  32883. */
  32884. setDeltaPosition(position: Vector3): void;
  32885. /**
  32886. * Sets the delta rotation
  32887. * @param rotation The delta rotation amount
  32888. */
  32889. setDeltaRotation(rotation: Quaternion): void;
  32890. /**
  32891. * Gets the box size of the physics imposter and stores the result in the input parameter
  32892. * @param result Stores the box size
  32893. * @returns The physics imposter
  32894. */
  32895. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32896. /**
  32897. * Gets the radius of the physics imposter
  32898. * @returns Radius of the physics imposter
  32899. */
  32900. getRadius(): number;
  32901. /**
  32902. * Sync a bone with this impostor
  32903. * @param bone The bone to sync to the impostor.
  32904. * @param boneMesh The mesh that the bone is influencing.
  32905. * @param jointPivot The pivot of the joint / bone in local space.
  32906. * @param distToJoint Optional distance from the impostor to the joint.
  32907. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32908. */
  32909. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32910. /**
  32911. * Sync impostor to a bone
  32912. * @param bone The bone that the impostor will be synced to.
  32913. * @param boneMesh The mesh that the bone is influencing.
  32914. * @param jointPivot The pivot of the joint / bone in local space.
  32915. * @param distToJoint Optional distance from the impostor to the joint.
  32916. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32917. * @param boneAxis Optional vector3 axis the bone is aligned with
  32918. */
  32919. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32920. /**
  32921. * No-Imposter type
  32922. */
  32923. static NoImpostor: number;
  32924. /**
  32925. * Sphere-Imposter type
  32926. */
  32927. static SphereImpostor: number;
  32928. /**
  32929. * Box-Imposter type
  32930. */
  32931. static BoxImpostor: number;
  32932. /**
  32933. * Plane-Imposter type
  32934. */
  32935. static PlaneImpostor: number;
  32936. /**
  32937. * Mesh-imposter type
  32938. */
  32939. static MeshImpostor: number;
  32940. /**
  32941. * Capsule-Impostor type (Ammo.js plugin only)
  32942. */
  32943. static CapsuleImpostor: number;
  32944. /**
  32945. * Cylinder-Imposter type
  32946. */
  32947. static CylinderImpostor: number;
  32948. /**
  32949. * Particle-Imposter type
  32950. */
  32951. static ParticleImpostor: number;
  32952. /**
  32953. * Heightmap-Imposter type
  32954. */
  32955. static HeightmapImpostor: number;
  32956. /**
  32957. * ConvexHull-Impostor type (Ammo.js plugin only)
  32958. */
  32959. static ConvexHullImpostor: number;
  32960. /**
  32961. * Custom-Imposter type (Ammo.js plugin only)
  32962. */
  32963. static CustomImpostor: number;
  32964. /**
  32965. * Rope-Imposter type
  32966. */
  32967. static RopeImpostor: number;
  32968. /**
  32969. * Cloth-Imposter type
  32970. */
  32971. static ClothImpostor: number;
  32972. /**
  32973. * Softbody-Imposter type
  32974. */
  32975. static SoftbodyImpostor: number;
  32976. }
  32977. }
  32978. declare module BABYLON {
  32979. /**
  32980. * @hidden
  32981. **/
  32982. export class _CreationDataStorage {
  32983. closePath?: boolean;
  32984. closeArray?: boolean;
  32985. idx: number[];
  32986. dashSize: number;
  32987. gapSize: number;
  32988. path3D: Path3D;
  32989. pathArray: Vector3[][];
  32990. arc: number;
  32991. radius: number;
  32992. cap: number;
  32993. tessellation: number;
  32994. }
  32995. /**
  32996. * @hidden
  32997. **/
  32998. class _InstanceDataStorage {
  32999. visibleInstances: any;
  33000. batchCache: _InstancesBatch;
  33001. instancesBufferSize: number;
  33002. instancesBuffer: Nullable<Buffer>;
  33003. instancesData: Float32Array;
  33004. overridenInstanceCount: number;
  33005. isFrozen: boolean;
  33006. previousBatch: Nullable<_InstancesBatch>;
  33007. hardwareInstancedRendering: boolean;
  33008. sideOrientation: number;
  33009. manualUpdate: boolean;
  33010. previousRenderId: number;
  33011. }
  33012. /**
  33013. * @hidden
  33014. **/
  33015. export class _InstancesBatch {
  33016. mustReturn: boolean;
  33017. visibleInstances: Nullable<InstancedMesh[]>[];
  33018. renderSelf: boolean[];
  33019. hardwareInstancedRendering: boolean[];
  33020. }
  33021. /**
  33022. * @hidden
  33023. **/
  33024. class _ThinInstanceDataStorage {
  33025. instancesCount: number;
  33026. matrixBuffer: Nullable<Buffer>;
  33027. matrixBufferSize: number;
  33028. matrixData: Nullable<Float32Array>;
  33029. boundingVectors: Array<Vector3>;
  33030. worldMatrices: Nullable<Matrix[]>;
  33031. }
  33032. /**
  33033. * Class used to represent renderable models
  33034. */
  33035. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33036. /**
  33037. * Mesh side orientation : usually the external or front surface
  33038. */
  33039. static readonly FRONTSIDE: number;
  33040. /**
  33041. * Mesh side orientation : usually the internal or back surface
  33042. */
  33043. static readonly BACKSIDE: number;
  33044. /**
  33045. * Mesh side orientation : both internal and external or front and back surfaces
  33046. */
  33047. static readonly DOUBLESIDE: number;
  33048. /**
  33049. * Mesh side orientation : by default, `FRONTSIDE`
  33050. */
  33051. static readonly DEFAULTSIDE: number;
  33052. /**
  33053. * Mesh cap setting : no cap
  33054. */
  33055. static readonly NO_CAP: number;
  33056. /**
  33057. * Mesh cap setting : one cap at the beginning of the mesh
  33058. */
  33059. static readonly CAP_START: number;
  33060. /**
  33061. * Mesh cap setting : one cap at the end of the mesh
  33062. */
  33063. static readonly CAP_END: number;
  33064. /**
  33065. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33066. */
  33067. static readonly CAP_ALL: number;
  33068. /**
  33069. * Mesh pattern setting : no flip or rotate
  33070. */
  33071. static readonly NO_FLIP: number;
  33072. /**
  33073. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33074. */
  33075. static readonly FLIP_TILE: number;
  33076. /**
  33077. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33078. */
  33079. static readonly ROTATE_TILE: number;
  33080. /**
  33081. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33082. */
  33083. static readonly FLIP_ROW: number;
  33084. /**
  33085. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33086. */
  33087. static readonly ROTATE_ROW: number;
  33088. /**
  33089. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33090. */
  33091. static readonly FLIP_N_ROTATE_TILE: number;
  33092. /**
  33093. * Mesh pattern setting : rotate pattern and rotate
  33094. */
  33095. static readonly FLIP_N_ROTATE_ROW: number;
  33096. /**
  33097. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33098. */
  33099. static readonly CENTER: number;
  33100. /**
  33101. * Mesh tile positioning : part tiles on left
  33102. */
  33103. static readonly LEFT: number;
  33104. /**
  33105. * Mesh tile positioning : part tiles on right
  33106. */
  33107. static readonly RIGHT: number;
  33108. /**
  33109. * Mesh tile positioning : part tiles on top
  33110. */
  33111. static readonly TOP: number;
  33112. /**
  33113. * Mesh tile positioning : part tiles on bottom
  33114. */
  33115. static readonly BOTTOM: number;
  33116. /**
  33117. * Gets the default side orientation.
  33118. * @param orientation the orientation to value to attempt to get
  33119. * @returns the default orientation
  33120. * @hidden
  33121. */
  33122. static _GetDefaultSideOrientation(orientation?: number): number;
  33123. private _internalMeshDataInfo;
  33124. get computeBonesUsingShaders(): boolean;
  33125. set computeBonesUsingShaders(value: boolean);
  33126. /**
  33127. * An event triggered before rendering the mesh
  33128. */
  33129. get onBeforeRenderObservable(): Observable<Mesh>;
  33130. /**
  33131. * An event triggered before binding the mesh
  33132. */
  33133. get onBeforeBindObservable(): Observable<Mesh>;
  33134. /**
  33135. * An event triggered after rendering the mesh
  33136. */
  33137. get onAfterRenderObservable(): Observable<Mesh>;
  33138. /**
  33139. * An event triggered before drawing the mesh
  33140. */
  33141. get onBeforeDrawObservable(): Observable<Mesh>;
  33142. private _onBeforeDrawObserver;
  33143. /**
  33144. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33145. */
  33146. set onBeforeDraw(callback: () => void);
  33147. get hasInstances(): boolean;
  33148. get hasThinInstances(): boolean;
  33149. /**
  33150. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33151. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33152. */
  33153. delayLoadState: number;
  33154. /**
  33155. * Gets the list of instances created from this mesh
  33156. * it is not supposed to be modified manually.
  33157. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33158. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33159. */
  33160. instances: InstancedMesh[];
  33161. /**
  33162. * Gets the file containing delay loading data for this mesh
  33163. */
  33164. delayLoadingFile: string;
  33165. /** @hidden */
  33166. _binaryInfo: any;
  33167. /**
  33168. * User defined function used to change how LOD level selection is done
  33169. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33170. */
  33171. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33172. /**
  33173. * Gets or sets the morph target manager
  33174. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33175. */
  33176. get morphTargetManager(): Nullable<MorphTargetManager>;
  33177. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33178. /** @hidden */
  33179. _creationDataStorage: Nullable<_CreationDataStorage>;
  33180. /** @hidden */
  33181. _geometry: Nullable<Geometry>;
  33182. /** @hidden */
  33183. _delayInfo: Array<string>;
  33184. /** @hidden */
  33185. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33186. /** @hidden */
  33187. _instanceDataStorage: _InstanceDataStorage;
  33188. /** @hidden */
  33189. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33190. private _effectiveMaterial;
  33191. /** @hidden */
  33192. _shouldGenerateFlatShading: boolean;
  33193. /** @hidden */
  33194. _originalBuilderSideOrientation: number;
  33195. /**
  33196. * Use this property to change the original side orientation defined at construction time
  33197. */
  33198. overrideMaterialSideOrientation: Nullable<number>;
  33199. /**
  33200. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33201. * Note this will reduce performance when set to true.
  33202. */
  33203. ignoreCameraMaxZ: boolean;
  33204. /**
  33205. * Gets the source mesh (the one used to clone this one from)
  33206. */
  33207. get source(): Nullable<Mesh>;
  33208. /**
  33209. * Gets the list of clones of this mesh
  33210. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33211. * Note that useClonedMeshMap=true is the default setting
  33212. */
  33213. get cloneMeshMap(): Nullable<{
  33214. [id: string]: Mesh | undefined;
  33215. }>;
  33216. /**
  33217. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33218. */
  33219. get isUnIndexed(): boolean;
  33220. set isUnIndexed(value: boolean);
  33221. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33222. get worldMatrixInstancedBuffer(): Float32Array;
  33223. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33224. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33225. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33226. /**
  33227. * @constructor
  33228. * @param name The value used by scene.getMeshByName() to do a lookup.
  33229. * @param scene The scene to add this mesh to.
  33230. * @param parent The parent of this mesh, if it has one
  33231. * @param source An optional Mesh from which geometry is shared, cloned.
  33232. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33233. * When false, achieved by calling a clone(), also passing False.
  33234. * This will make creation of children, recursive.
  33235. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33236. */
  33237. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33238. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33239. doNotInstantiate: boolean;
  33240. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33241. /**
  33242. * Gets the class name
  33243. * @returns the string "Mesh".
  33244. */
  33245. getClassName(): string;
  33246. /** @hidden */
  33247. get _isMesh(): boolean;
  33248. /**
  33249. * Returns a description of this mesh
  33250. * @param fullDetails define if full details about this mesh must be used
  33251. * @returns a descriptive string representing this mesh
  33252. */
  33253. toString(fullDetails?: boolean): string;
  33254. /** @hidden */
  33255. _unBindEffect(): void;
  33256. /**
  33257. * Gets a boolean indicating if this mesh has LOD
  33258. */
  33259. get hasLODLevels(): boolean;
  33260. /**
  33261. * Gets the list of MeshLODLevel associated with the current mesh
  33262. * @returns an array of MeshLODLevel
  33263. */
  33264. getLODLevels(): MeshLODLevel[];
  33265. private _sortLODLevels;
  33266. /**
  33267. * Add a mesh as LOD level triggered at the given distance.
  33268. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33269. * @param distance The distance from the center of the object to show this level
  33270. * @param mesh The mesh to be added as LOD level (can be null)
  33271. * @return This mesh (for chaining)
  33272. */
  33273. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33274. /**
  33275. * Returns the LOD level mesh at the passed distance or null if not found.
  33276. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33277. * @param distance The distance from the center of the object to show this level
  33278. * @returns a Mesh or `null`
  33279. */
  33280. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33281. /**
  33282. * Remove a mesh from the LOD array
  33283. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33284. * @param mesh defines the mesh to be removed
  33285. * @return This mesh (for chaining)
  33286. */
  33287. removeLODLevel(mesh: Mesh): Mesh;
  33288. /**
  33289. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33290. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33291. * @param camera defines the camera to use to compute distance
  33292. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33293. * @return This mesh (for chaining)
  33294. */
  33295. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33296. /**
  33297. * Gets the mesh internal Geometry object
  33298. */
  33299. get geometry(): Nullable<Geometry>;
  33300. /**
  33301. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33302. * @returns the total number of vertices
  33303. */
  33304. getTotalVertices(): number;
  33305. /**
  33306. * Returns the content of an associated vertex buffer
  33307. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33308. * - VertexBuffer.PositionKind
  33309. * - VertexBuffer.UVKind
  33310. * - VertexBuffer.UV2Kind
  33311. * - VertexBuffer.UV3Kind
  33312. * - VertexBuffer.UV4Kind
  33313. * - VertexBuffer.UV5Kind
  33314. * - VertexBuffer.UV6Kind
  33315. * - VertexBuffer.ColorKind
  33316. * - VertexBuffer.MatricesIndicesKind
  33317. * - VertexBuffer.MatricesIndicesExtraKind
  33318. * - VertexBuffer.MatricesWeightsKind
  33319. * - VertexBuffer.MatricesWeightsExtraKind
  33320. * @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
  33321. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33322. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33323. */
  33324. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33325. /**
  33326. * Returns the mesh VertexBuffer object from the requested `kind`
  33327. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33328. * - VertexBuffer.PositionKind
  33329. * - VertexBuffer.NormalKind
  33330. * - VertexBuffer.UVKind
  33331. * - VertexBuffer.UV2Kind
  33332. * - VertexBuffer.UV3Kind
  33333. * - VertexBuffer.UV4Kind
  33334. * - VertexBuffer.UV5Kind
  33335. * - VertexBuffer.UV6Kind
  33336. * - VertexBuffer.ColorKind
  33337. * - VertexBuffer.MatricesIndicesKind
  33338. * - VertexBuffer.MatricesIndicesExtraKind
  33339. * - VertexBuffer.MatricesWeightsKind
  33340. * - VertexBuffer.MatricesWeightsExtraKind
  33341. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33342. */
  33343. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33344. /**
  33345. * Tests if a specific vertex buffer is associated with this mesh
  33346. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33347. * - VertexBuffer.PositionKind
  33348. * - VertexBuffer.NormalKind
  33349. * - VertexBuffer.UVKind
  33350. * - VertexBuffer.UV2Kind
  33351. * - VertexBuffer.UV3Kind
  33352. * - VertexBuffer.UV4Kind
  33353. * - VertexBuffer.UV5Kind
  33354. * - VertexBuffer.UV6Kind
  33355. * - VertexBuffer.ColorKind
  33356. * - VertexBuffer.MatricesIndicesKind
  33357. * - VertexBuffer.MatricesIndicesExtraKind
  33358. * - VertexBuffer.MatricesWeightsKind
  33359. * - VertexBuffer.MatricesWeightsExtraKind
  33360. * @returns a boolean
  33361. */
  33362. isVerticesDataPresent(kind: string): boolean;
  33363. /**
  33364. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33365. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33366. * - VertexBuffer.PositionKind
  33367. * - VertexBuffer.UVKind
  33368. * - VertexBuffer.UV2Kind
  33369. * - VertexBuffer.UV3Kind
  33370. * - VertexBuffer.UV4Kind
  33371. * - VertexBuffer.UV5Kind
  33372. * - VertexBuffer.UV6Kind
  33373. * - VertexBuffer.ColorKind
  33374. * - VertexBuffer.MatricesIndicesKind
  33375. * - VertexBuffer.MatricesIndicesExtraKind
  33376. * - VertexBuffer.MatricesWeightsKind
  33377. * - VertexBuffer.MatricesWeightsExtraKind
  33378. * @returns a boolean
  33379. */
  33380. isVertexBufferUpdatable(kind: string): boolean;
  33381. /**
  33382. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33383. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33384. * - VertexBuffer.PositionKind
  33385. * - VertexBuffer.NormalKind
  33386. * - VertexBuffer.UVKind
  33387. * - VertexBuffer.UV2Kind
  33388. * - VertexBuffer.UV3Kind
  33389. * - VertexBuffer.UV4Kind
  33390. * - VertexBuffer.UV5Kind
  33391. * - VertexBuffer.UV6Kind
  33392. * - VertexBuffer.ColorKind
  33393. * - VertexBuffer.MatricesIndicesKind
  33394. * - VertexBuffer.MatricesIndicesExtraKind
  33395. * - VertexBuffer.MatricesWeightsKind
  33396. * - VertexBuffer.MatricesWeightsExtraKind
  33397. * @returns an array of strings
  33398. */
  33399. getVerticesDataKinds(): string[];
  33400. /**
  33401. * Returns a positive integer : the total number of indices in this mesh geometry.
  33402. * @returns the numner of indices or zero if the mesh has no geometry.
  33403. */
  33404. getTotalIndices(): number;
  33405. /**
  33406. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33407. * @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.
  33408. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33409. * @returns the indices array or an empty array if the mesh has no geometry
  33410. */
  33411. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33412. get isBlocked(): boolean;
  33413. /**
  33414. * Determine if the current mesh is ready to be rendered
  33415. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33416. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33417. * @returns true if all associated assets are ready (material, textures, shaders)
  33418. */
  33419. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33420. /**
  33421. * 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.
  33422. */
  33423. get areNormalsFrozen(): boolean;
  33424. /**
  33425. * 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.
  33426. * @returns the current mesh
  33427. */
  33428. freezeNormals(): Mesh;
  33429. /**
  33430. * 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
  33431. * @returns the current mesh
  33432. */
  33433. unfreezeNormals(): Mesh;
  33434. /**
  33435. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33436. */
  33437. set overridenInstanceCount(count: number);
  33438. /** @hidden */
  33439. _preActivate(): Mesh;
  33440. /** @hidden */
  33441. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33442. /** @hidden */
  33443. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33444. protected _afterComputeWorldMatrix(): void;
  33445. /** @hidden */
  33446. _postActivate(): void;
  33447. /**
  33448. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33449. * This means the mesh underlying bounding box and sphere are recomputed.
  33450. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33451. * @returns the current mesh
  33452. */
  33453. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33454. /** @hidden */
  33455. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33456. /**
  33457. * This function will subdivide the mesh into multiple submeshes
  33458. * @param count defines the expected number of submeshes
  33459. */
  33460. subdivide(count: number): void;
  33461. /**
  33462. * Copy a FloatArray into a specific associated vertex buffer
  33463. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33464. * - VertexBuffer.PositionKind
  33465. * - VertexBuffer.UVKind
  33466. * - VertexBuffer.UV2Kind
  33467. * - VertexBuffer.UV3Kind
  33468. * - VertexBuffer.UV4Kind
  33469. * - VertexBuffer.UV5Kind
  33470. * - VertexBuffer.UV6Kind
  33471. * - VertexBuffer.ColorKind
  33472. * - VertexBuffer.MatricesIndicesKind
  33473. * - VertexBuffer.MatricesIndicesExtraKind
  33474. * - VertexBuffer.MatricesWeightsKind
  33475. * - VertexBuffer.MatricesWeightsExtraKind
  33476. * @param data defines the data source
  33477. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33478. * @param stride defines the data stride size (can be null)
  33479. * @returns the current mesh
  33480. */
  33481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33482. /**
  33483. * Delete a vertex buffer associated with this mesh
  33484. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33485. * - VertexBuffer.PositionKind
  33486. * - VertexBuffer.UVKind
  33487. * - VertexBuffer.UV2Kind
  33488. * - VertexBuffer.UV3Kind
  33489. * - VertexBuffer.UV4Kind
  33490. * - VertexBuffer.UV5Kind
  33491. * - VertexBuffer.UV6Kind
  33492. * - VertexBuffer.ColorKind
  33493. * - VertexBuffer.MatricesIndicesKind
  33494. * - VertexBuffer.MatricesIndicesExtraKind
  33495. * - VertexBuffer.MatricesWeightsKind
  33496. * - VertexBuffer.MatricesWeightsExtraKind
  33497. */
  33498. removeVerticesData(kind: string): void;
  33499. /**
  33500. * Flags an associated vertex buffer as updatable
  33501. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33502. * - VertexBuffer.PositionKind
  33503. * - VertexBuffer.UVKind
  33504. * - VertexBuffer.UV2Kind
  33505. * - VertexBuffer.UV3Kind
  33506. * - VertexBuffer.UV4Kind
  33507. * - VertexBuffer.UV5Kind
  33508. * - VertexBuffer.UV6Kind
  33509. * - VertexBuffer.ColorKind
  33510. * - VertexBuffer.MatricesIndicesKind
  33511. * - VertexBuffer.MatricesIndicesExtraKind
  33512. * - VertexBuffer.MatricesWeightsKind
  33513. * - VertexBuffer.MatricesWeightsExtraKind
  33514. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33515. */
  33516. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33517. /**
  33518. * Sets the mesh global Vertex Buffer
  33519. * @param buffer defines the buffer to use
  33520. * @returns the current mesh
  33521. */
  33522. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33523. /**
  33524. * Update a specific associated vertex buffer
  33525. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33526. * - VertexBuffer.PositionKind
  33527. * - VertexBuffer.UVKind
  33528. * - VertexBuffer.UV2Kind
  33529. * - VertexBuffer.UV3Kind
  33530. * - VertexBuffer.UV4Kind
  33531. * - VertexBuffer.UV5Kind
  33532. * - VertexBuffer.UV6Kind
  33533. * - VertexBuffer.ColorKind
  33534. * - VertexBuffer.MatricesIndicesKind
  33535. * - VertexBuffer.MatricesIndicesExtraKind
  33536. * - VertexBuffer.MatricesWeightsKind
  33537. * - VertexBuffer.MatricesWeightsExtraKind
  33538. * @param data defines the data source
  33539. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33540. * @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)
  33541. * @returns the current mesh
  33542. */
  33543. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33544. /**
  33545. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33546. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33547. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33548. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33549. * @returns the current mesh
  33550. */
  33551. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33552. /**
  33553. * Creates a un-shared specific occurence of the geometry for the mesh.
  33554. * @returns the current mesh
  33555. */
  33556. makeGeometryUnique(): Mesh;
  33557. /**
  33558. * Set the index buffer of this mesh
  33559. * @param indices defines the source data
  33560. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33561. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33562. * @returns the current mesh
  33563. */
  33564. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33565. /**
  33566. * Update the current index buffer
  33567. * @param indices defines the source data
  33568. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33569. * @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)
  33570. * @returns the current mesh
  33571. */
  33572. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33573. /**
  33574. * Invert the geometry to move from a right handed system to a left handed one.
  33575. * @returns the current mesh
  33576. */
  33577. toLeftHanded(): Mesh;
  33578. /** @hidden */
  33579. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33580. /** @hidden */
  33581. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33582. /**
  33583. * Registers for this mesh a javascript function called just before the rendering process
  33584. * @param func defines the function to call before rendering this mesh
  33585. * @returns the current mesh
  33586. */
  33587. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33588. /**
  33589. * Disposes a previously registered javascript function called before the rendering
  33590. * @param func defines the function to remove
  33591. * @returns the current mesh
  33592. */
  33593. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33594. /**
  33595. * Registers for this mesh a javascript function called just after the rendering is complete
  33596. * @param func defines the function to call after rendering this mesh
  33597. * @returns the current mesh
  33598. */
  33599. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33600. /**
  33601. * Disposes a previously registered javascript function called after the rendering.
  33602. * @param func defines the function to remove
  33603. * @returns the current mesh
  33604. */
  33605. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33606. /** @hidden */
  33607. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33608. /** @hidden */
  33609. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33610. /** @hidden */
  33611. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33612. /** @hidden */
  33613. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33614. /** @hidden */
  33615. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33616. /** @hidden */
  33617. _rebuild(): void;
  33618. /** @hidden */
  33619. _freeze(): void;
  33620. /** @hidden */
  33621. _unFreeze(): void;
  33622. /**
  33623. * 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
  33624. * @param subMesh defines the subMesh to render
  33625. * @param enableAlphaMode defines if alpha mode can be changed
  33626. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33627. * @returns the current mesh
  33628. */
  33629. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33630. private _onBeforeDraw;
  33631. /**
  33632. * Renormalize the mesh and patch it up if there are no weights
  33633. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33634. * However in the case of zero weights then we set just a single influence to 1.
  33635. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33636. */
  33637. cleanMatrixWeights(): void;
  33638. private normalizeSkinFourWeights;
  33639. private normalizeSkinWeightsAndExtra;
  33640. /**
  33641. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33642. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33643. * the user know there was an issue with importing the mesh
  33644. * @returns a validation object with skinned, valid and report string
  33645. */
  33646. validateSkinning(): {
  33647. skinned: boolean;
  33648. valid: boolean;
  33649. report: string;
  33650. };
  33651. /** @hidden */
  33652. _checkDelayState(): Mesh;
  33653. private _queueLoad;
  33654. /**
  33655. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33656. * A mesh is in the frustum if its bounding box intersects the frustum
  33657. * @param frustumPlanes defines the frustum to test
  33658. * @returns true if the mesh is in the frustum planes
  33659. */
  33660. isInFrustum(frustumPlanes: Plane[]): boolean;
  33661. /**
  33662. * Sets the mesh material by the material or multiMaterial `id` property
  33663. * @param id is a string identifying the material or the multiMaterial
  33664. * @returns the current mesh
  33665. */
  33666. setMaterialByID(id: string): Mesh;
  33667. /**
  33668. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33669. * @returns an array of IAnimatable
  33670. */
  33671. getAnimatables(): IAnimatable[];
  33672. /**
  33673. * Modifies the mesh geometry according to the passed transformation matrix.
  33674. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33675. * The mesh normals are modified using the same transformation.
  33676. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33677. * @param transform defines the transform matrix to use
  33678. * @see https://doc.babylonjs.com/resources/baking_transformations
  33679. * @returns the current mesh
  33680. */
  33681. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33682. /**
  33683. * Modifies the mesh geometry according to its own current World Matrix.
  33684. * The mesh World Matrix is then reset.
  33685. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33686. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33687. * @see https://doc.babylonjs.com/resources/baking_transformations
  33688. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33689. * @returns the current mesh
  33690. */
  33691. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33692. /** @hidden */
  33693. get _positions(): Nullable<Vector3[]>;
  33694. /** @hidden */
  33695. _resetPointsArrayCache(): Mesh;
  33696. /** @hidden */
  33697. _generatePointsArray(): boolean;
  33698. /**
  33699. * Returns a new Mesh object generated from the current mesh properties.
  33700. * This method must not get confused with createInstance()
  33701. * @param name is a string, the name given to the new mesh
  33702. * @param newParent can be any Node object (default `null`)
  33703. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33704. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33705. * @returns a new mesh
  33706. */
  33707. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33708. /**
  33709. * Releases resources associated with this mesh.
  33710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33712. */
  33713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33714. /** @hidden */
  33715. _disposeInstanceSpecificData(): void;
  33716. /** @hidden */
  33717. _disposeThinInstanceSpecificData(): void;
  33718. /**
  33719. * Modifies the mesh geometry according to a displacement map.
  33720. * 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.
  33721. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33722. * @param url is a string, the URL from the image file is to be downloaded.
  33723. * @param minHeight is the lower limit of the displacement.
  33724. * @param maxHeight is the upper limit of the displacement.
  33725. * @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.
  33726. * @param uvOffset is an optional vector2 used to offset UV.
  33727. * @param uvScale is an optional vector2 used to scale UV.
  33728. * @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.
  33729. * @returns the Mesh.
  33730. */
  33731. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33732. /**
  33733. * Modifies the mesh geometry according to a displacementMap buffer.
  33734. * 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.
  33735. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33736. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33737. * @param heightMapWidth is the width of the buffer image.
  33738. * @param heightMapHeight is the height of the buffer image.
  33739. * @param minHeight is the lower limit of the displacement.
  33740. * @param maxHeight is the upper limit of the displacement.
  33741. * @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.
  33742. * @param uvOffset is an optional vector2 used to offset UV.
  33743. * @param uvScale is an optional vector2 used to scale UV.
  33744. * @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.
  33745. * @returns the Mesh.
  33746. */
  33747. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33748. /**
  33749. * Modify the mesh to get a flat shading rendering.
  33750. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33751. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33752. * @returns current mesh
  33753. */
  33754. convertToFlatShadedMesh(): Mesh;
  33755. /**
  33756. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33757. * In other words, more vertices, no more indices and a single bigger VBO.
  33758. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33759. * @returns current mesh
  33760. */
  33761. convertToUnIndexedMesh(): Mesh;
  33762. /**
  33763. * Inverses facet orientations.
  33764. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33765. * @param flipNormals will also inverts the normals
  33766. * @returns current mesh
  33767. */
  33768. flipFaces(flipNormals?: boolean): Mesh;
  33769. /**
  33770. * Increase the number of facets and hence vertices in a mesh
  33771. * Vertex normals are interpolated from existing vertex normals
  33772. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33773. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33774. */
  33775. increaseVertices(numberPerEdge: number): void;
  33776. /**
  33777. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33778. * This will undo any application of covertToFlatShadedMesh
  33779. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33780. */
  33781. forceSharedVertices(): void;
  33782. /** @hidden */
  33783. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33784. /** @hidden */
  33785. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33786. /**
  33787. * Creates a new InstancedMesh object from the mesh model.
  33788. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33789. * @param name defines the name of the new instance
  33790. * @returns a new InstancedMesh
  33791. */
  33792. createInstance(name: string): InstancedMesh;
  33793. /**
  33794. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33795. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33796. * @returns the current mesh
  33797. */
  33798. synchronizeInstances(): Mesh;
  33799. /**
  33800. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33801. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33802. * This should be used together with the simplification to avoid disappearing triangles.
  33803. * @param successCallback an optional success callback to be called after the optimization finished.
  33804. * @returns the current mesh
  33805. */
  33806. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33807. /**
  33808. * Serialize current mesh
  33809. * @param serializationObject defines the object which will receive the serialization data
  33810. */
  33811. serialize(serializationObject: any): void;
  33812. /** @hidden */
  33813. _syncGeometryWithMorphTargetManager(): void;
  33814. /** @hidden */
  33815. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33816. /**
  33817. * Returns a new Mesh object parsed from the source provided.
  33818. * @param parsedMesh is the source
  33819. * @param scene defines the hosting scene
  33820. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33821. * @returns a new Mesh
  33822. */
  33823. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33824. /**
  33825. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33826. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33827. * @param name defines the name of the mesh to create
  33828. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33829. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33830. * @param closePath creates a seam between the first and the last points of each path of the path array
  33831. * @param offset is taken in account only if the `pathArray` is containing a single path
  33832. * @param scene defines the hosting scene
  33833. * @param updatable defines if the mesh must be flagged as updatable
  33834. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33835. * @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)
  33836. * @returns a new Mesh
  33837. */
  33838. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33839. /**
  33840. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33841. * @param name defines the name of the mesh to create
  33842. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33843. * @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
  33844. * @param scene defines the hosting scene
  33845. * @param updatable defines if the mesh must be flagged as updatable
  33846. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33847. * @returns a new Mesh
  33848. */
  33849. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33850. /**
  33851. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33852. * @param name defines the name of the mesh to create
  33853. * @param size sets the size (float) of each box side (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 CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33860. /**
  33861. * Creates a sphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33864. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33865. * @param scene defines the hosting scene
  33866. * @param updatable defines if the mesh must be flagged as updatable
  33867. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33868. * @returns a new Mesh
  33869. */
  33870. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33871. /**
  33872. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33873. * @param name defines the name of the mesh to create
  33874. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33875. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33876. * @param scene defines the hosting scene
  33877. * @returns a new Mesh
  33878. */
  33879. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33880. /**
  33881. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33882. * @param name defines the name of the mesh to create
  33883. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33884. * @param diameterTop set the top cap diameter (floats, default 1)
  33885. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33886. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33887. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33888. * @param scene defines the hosting scene
  33889. * @param updatable defines if the mesh must be flagged as updatable
  33890. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33891. * @returns a new Mesh
  33892. */
  33893. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33894. /**
  33895. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33896. * @param name defines the name of the mesh to create
  33897. * @param diameter sets the diameter size (float) of the torus (default 1)
  33898. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33899. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33900. * @param scene defines the hosting scene
  33901. * @param updatable defines if the mesh must be flagged as updatable
  33902. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33903. * @returns a new Mesh
  33904. */
  33905. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33906. /**
  33907. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33908. * @param name defines the name of the mesh to create
  33909. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33910. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33911. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33912. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33913. * @param p the number of windings on X axis (positive integers, default 2)
  33914. * @param q the number of windings on Y axis (positive integers, default 3)
  33915. * @param scene defines the hosting scene
  33916. * @param updatable defines if the mesh must be flagged as updatable
  33917. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33918. * @returns a new Mesh
  33919. */
  33920. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33921. /**
  33922. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33923. * @param name defines the name of the mesh to create
  33924. * @param points is an array successive Vector3
  33925. * @param scene defines the hosting scene
  33926. * @param updatable defines if the mesh must be flagged as updatable
  33927. * @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).
  33928. * @returns a new Mesh
  33929. */
  33930. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33931. /**
  33932. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33933. * @param name defines the name of the mesh to create
  33934. * @param points is an array successive Vector3
  33935. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33936. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33937. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33938. * @param scene defines the hosting scene
  33939. * @param updatable defines if the mesh must be flagged as updatable
  33940. * @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)
  33941. * @returns a new Mesh
  33942. */
  33943. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33944. /**
  33945. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33946. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33947. * 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.
  33948. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33949. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33950. * Remember you can only change the shape positions, not their number when updating a polygon.
  33951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33952. * @param name defines the name of the mesh to create
  33953. * @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
  33954. * @param scene defines the hosting scene
  33955. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33956. * @param updatable defines if the mesh must be flagged as updatable
  33957. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33958. * @param earcutInjection can be used to inject your own earcut reference
  33959. * @returns a new Mesh
  33960. */
  33961. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33962. /**
  33963. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33965. * @param name defines the name of the mesh to create
  33966. * @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
  33967. * @param depth defines the height of extrusion
  33968. * @param scene defines the hosting scene
  33969. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33970. * @param updatable defines if the mesh must be flagged as updatable
  33971. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33972. * @param earcutInjection can be used to inject your own earcut reference
  33973. * @returns a new Mesh
  33974. */
  33975. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33976. /**
  33977. * Creates an extruded shape mesh.
  33978. * 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
  33979. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33981. * @param name defines the name of the mesh to create
  33982. * @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
  33983. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33984. * @param scale is the value to scale the shape
  33985. * @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
  33986. * @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
  33987. * @param scene defines the hosting scene
  33988. * @param updatable defines if the mesh must be flagged as updatable
  33989. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33990. * @param 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)
  33991. * @returns a new Mesh
  33992. */
  33993. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33994. /**
  33995. * Creates an custom extruded shape mesh.
  33996. * The custom extrusion is a parametric shape.
  33997. * It has no predefined shape. Its final shape will depend on the input parameters.
  33998. * Please consider using the same method from the MeshBuilder class instead
  33999. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34000. * @param name defines the name of the mesh to create
  34001. * @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
  34002. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34003. * @param scaleFunction is a custom Javascript function called on each path point
  34004. * @param rotationFunction is a custom Javascript function called on each path point
  34005. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34006. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34007. * @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
  34008. * @param scene defines the hosting scene
  34009. * @param updatable defines if the mesh must be flagged as updatable
  34010. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34011. * @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)
  34012. * @returns a new Mesh
  34013. */
  34014. 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;
  34015. /**
  34016. * Creates lathe mesh.
  34017. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34018. * Please consider using the same method from the MeshBuilder class instead
  34019. * @param name defines the name of the mesh to create
  34020. * @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
  34021. * @param radius is the radius value of the lathe
  34022. * @param tessellation is the side number of the lathe.
  34023. * @param scene defines the hosting scene
  34024. * @param updatable defines if the mesh must be flagged as updatable
  34025. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34026. * @returns a new Mesh
  34027. */
  34028. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34029. /**
  34030. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34031. * @param name defines the name of the mesh to create
  34032. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34033. * @param scene defines the hosting scene
  34034. * @param updatable defines if the mesh must be flagged as updatable
  34035. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34036. * @returns a new Mesh
  34037. */
  34038. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34039. /**
  34040. * Creates a ground mesh.
  34041. * Please consider using the same method from the MeshBuilder class instead
  34042. * @param name defines the name of the mesh to create
  34043. * @param width set the width of the ground
  34044. * @param height set the height of the ground
  34045. * @param subdivisions sets the number of subdivisions per side
  34046. * @param scene defines the hosting scene
  34047. * @param updatable defines if the mesh must be flagged as updatable
  34048. * @returns a new Mesh
  34049. */
  34050. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34051. /**
  34052. * Creates a tiled ground mesh.
  34053. * Please consider using the same method from the MeshBuilder class instead
  34054. * @param name defines the name of the mesh to create
  34055. * @param xmin set the ground minimum X coordinate
  34056. * @param zmin set the ground minimum Y coordinate
  34057. * @param xmax set the ground maximum X coordinate
  34058. * @param zmax set the ground maximum Z coordinate
  34059. * @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
  34060. * @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
  34061. * @param scene defines the hosting scene
  34062. * @param updatable defines if the mesh must be flagged as updatable
  34063. * @returns a new Mesh
  34064. */
  34065. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34066. w: number;
  34067. h: number;
  34068. }, precision: {
  34069. w: number;
  34070. h: number;
  34071. }, scene: Scene, updatable?: boolean): Mesh;
  34072. /**
  34073. * Creates a ground mesh from a height map.
  34074. * Please consider using the same method from the MeshBuilder class instead
  34075. * @see https://doc.babylonjs.com/babylon101/height_map
  34076. * @param name defines the name of the mesh to create
  34077. * @param url sets the URL of the height map image resource
  34078. * @param width set the ground width size
  34079. * @param height set the ground height size
  34080. * @param subdivisions sets the number of subdivision per side
  34081. * @param minHeight is the minimum altitude on the ground
  34082. * @param maxHeight is the maximum altitude on the ground
  34083. * @param scene defines the hosting scene
  34084. * @param updatable defines if the mesh must be flagged as updatable
  34085. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34086. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34087. * @returns a new Mesh
  34088. */
  34089. 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;
  34090. /**
  34091. * Creates a tube mesh.
  34092. * The tube is a parametric shape.
  34093. * It has no predefined shape. Its final shape will depend on the input parameters.
  34094. * Please consider using the same method from the MeshBuilder class instead
  34095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34096. * @param name defines the name of the mesh to create
  34097. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34098. * @param radius sets the tube radius size
  34099. * @param tessellation is the number of sides on the tubular surface
  34100. * @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
  34101. * @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
  34102. * @param scene defines the hosting scene
  34103. * @param updatable defines if the mesh must be flagged as updatable
  34104. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34105. * @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)
  34106. * @returns a new Mesh
  34107. */
  34108. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34109. (i: number, distance: number): number;
  34110. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34111. /**
  34112. * Creates a polyhedron mesh.
  34113. * Please consider using the same method from the MeshBuilder class instead.
  34114. * * 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
  34115. * * The parameter `size` (positive float, default 1) sets the polygon size
  34116. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34117. * * 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`
  34118. * * 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
  34119. * * 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)`)
  34120. * * 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
  34121. * * 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
  34122. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34123. * * 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
  34124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34125. * @param name defines the name of the mesh to create
  34126. * @param options defines the options used to create the mesh
  34127. * @param scene defines the hosting scene
  34128. * @returns a new Mesh
  34129. */
  34130. static CreatePolyhedron(name: string, options: {
  34131. type?: number;
  34132. size?: number;
  34133. sizeX?: number;
  34134. sizeY?: number;
  34135. sizeZ?: number;
  34136. custom?: any;
  34137. faceUV?: Vector4[];
  34138. faceColors?: Color4[];
  34139. updatable?: boolean;
  34140. sideOrientation?: number;
  34141. }, scene: Scene): Mesh;
  34142. /**
  34143. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34144. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34145. * * 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`)
  34146. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34147. * * 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
  34148. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34149. * * 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
  34150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34151. * @param name defines the name of the mesh
  34152. * @param options defines the options used to create the mesh
  34153. * @param scene defines the hosting scene
  34154. * @returns a new Mesh
  34155. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34156. */
  34157. static CreateIcoSphere(name: string, options: {
  34158. radius?: number;
  34159. flat?: boolean;
  34160. subdivisions?: number;
  34161. sideOrientation?: number;
  34162. updatable?: boolean;
  34163. }, scene: Scene): Mesh;
  34164. /**
  34165. * Creates a decal mesh.
  34166. * Please consider using the same method from the MeshBuilder class instead.
  34167. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34168. * @param name defines the name of the mesh
  34169. * @param sourceMesh defines the mesh receiving the decal
  34170. * @param position sets the position of the decal in world coordinates
  34171. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34172. * @param size sets the decal scaling
  34173. * @param angle sets the angle to rotate the decal
  34174. * @returns a new Mesh
  34175. */
  34176. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34177. /** Creates a Capsule Mesh
  34178. * @param name defines the name of the mesh.
  34179. * @param options the constructors options used to shape the mesh.
  34180. * @param scene defines the scene the mesh is scoped to.
  34181. * @returns the capsule mesh
  34182. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34183. */
  34184. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34185. /**
  34186. * Prepare internal position array for software CPU skinning
  34187. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34188. */
  34189. setPositionsForCPUSkinning(): Float32Array;
  34190. /**
  34191. * Prepare internal normal array for software CPU skinning
  34192. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34193. */
  34194. setNormalsForCPUSkinning(): Float32Array;
  34195. /**
  34196. * Updates the vertex buffer by applying transformation from the bones
  34197. * @param skeleton defines the skeleton to apply to current mesh
  34198. * @returns the current mesh
  34199. */
  34200. applySkeleton(skeleton: Skeleton): Mesh;
  34201. /**
  34202. * 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
  34203. * @param meshes defines the list of meshes to scan
  34204. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34205. */
  34206. static MinMax(meshes: AbstractMesh[]): {
  34207. min: Vector3;
  34208. max: Vector3;
  34209. };
  34210. /**
  34211. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34212. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34213. * @returns a vector3
  34214. */
  34215. static Center(meshesOrMinMaxVector: {
  34216. min: Vector3;
  34217. max: Vector3;
  34218. } | AbstractMesh[]): Vector3;
  34219. /**
  34220. * Merge the array of meshes into a single mesh for performance reasons.
  34221. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34222. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34223. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34224. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34225. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34226. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34227. * @returns a new mesh
  34228. */
  34229. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34230. /** @hidden */
  34231. addInstance(instance: InstancedMesh): void;
  34232. /** @hidden */
  34233. removeInstance(instance: InstancedMesh): void;
  34234. }
  34235. }
  34236. declare module BABYLON {
  34237. /**
  34238. * The options Interface for creating a Capsule Mesh
  34239. */
  34240. export interface ICreateCapsuleOptions {
  34241. /** The Orientation of the capsule. Default : Vector3.Up() */
  34242. orientation?: Vector3;
  34243. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34244. subdivisions: number;
  34245. /** Number of cylindrical segments on the capsule. */
  34246. tessellation: number;
  34247. /** Height or Length of the capsule. */
  34248. height: number;
  34249. /** Radius of the capsule. */
  34250. radius: number;
  34251. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34252. capSubdivisions: number;
  34253. /** Overwrite for the top radius. */
  34254. radiusTop?: number;
  34255. /** Overwrite for the bottom radius. */
  34256. radiusBottom?: number;
  34257. /** Overwrite for the top capSubdivisions. */
  34258. topCapSubdivisions?: number;
  34259. /** Overwrite for the bottom capSubdivisions. */
  34260. bottomCapSubdivisions?: number;
  34261. }
  34262. /**
  34263. * Class containing static functions to help procedurally build meshes
  34264. */
  34265. export class CapsuleBuilder {
  34266. /**
  34267. * Creates a capsule or a pill mesh
  34268. * @param name defines the name of the mesh
  34269. * @param options The constructors options.
  34270. * @param scene The scene the mesh is scoped to.
  34271. * @returns Capsule Mesh
  34272. */
  34273. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34274. }
  34275. }
  34276. declare module BABYLON {
  34277. /**
  34278. * Define an interface for all classes that will get and set the data on vertices
  34279. */
  34280. export interface IGetSetVerticesData {
  34281. /**
  34282. * Gets a boolean indicating if specific vertex data is present
  34283. * @param kind defines the vertex data kind to use
  34284. * @returns true is data kind is present
  34285. */
  34286. isVerticesDataPresent(kind: string): boolean;
  34287. /**
  34288. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34289. * @param kind defines the data kind (Position, normal, etc...)
  34290. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34291. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34292. * @returns a float array containing vertex data
  34293. */
  34294. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34295. /**
  34296. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34297. * @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.
  34298. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34299. * @returns the indices array or an empty array if the mesh has no geometry
  34300. */
  34301. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34302. /**
  34303. * Set specific vertex data
  34304. * @param kind defines the data kind (Position, normal, etc...)
  34305. * @param data defines the vertex data to use
  34306. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34307. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34308. */
  34309. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34310. /**
  34311. * Update a specific associated vertex buffer
  34312. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34313. * - VertexBuffer.PositionKind
  34314. * - VertexBuffer.UVKind
  34315. * - VertexBuffer.UV2Kind
  34316. * - VertexBuffer.UV3Kind
  34317. * - VertexBuffer.UV4Kind
  34318. * - VertexBuffer.UV5Kind
  34319. * - VertexBuffer.UV6Kind
  34320. * - VertexBuffer.ColorKind
  34321. * - VertexBuffer.MatricesIndicesKind
  34322. * - VertexBuffer.MatricesIndicesExtraKind
  34323. * - VertexBuffer.MatricesWeightsKind
  34324. * - VertexBuffer.MatricesWeightsExtraKind
  34325. * @param data defines the data source
  34326. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34327. * @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)
  34328. */
  34329. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34330. /**
  34331. * Creates a new index buffer
  34332. * @param indices defines the indices to store in the index buffer
  34333. * @param totalVertices defines the total number of vertices (could be null)
  34334. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34335. */
  34336. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34337. }
  34338. /**
  34339. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34340. */
  34341. export class VertexData {
  34342. /**
  34343. * Mesh side orientation : usually the external or front surface
  34344. */
  34345. static readonly FRONTSIDE: number;
  34346. /**
  34347. * Mesh side orientation : usually the internal or back surface
  34348. */
  34349. static readonly BACKSIDE: number;
  34350. /**
  34351. * Mesh side orientation : both internal and external or front and back surfaces
  34352. */
  34353. static readonly DOUBLESIDE: number;
  34354. /**
  34355. * Mesh side orientation : by default, `FRONTSIDE`
  34356. */
  34357. static readonly DEFAULTSIDE: number;
  34358. /**
  34359. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34360. */
  34361. positions: Nullable<FloatArray>;
  34362. /**
  34363. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34364. */
  34365. normals: Nullable<FloatArray>;
  34366. /**
  34367. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34368. */
  34369. tangents: Nullable<FloatArray>;
  34370. /**
  34371. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34372. */
  34373. uvs: Nullable<FloatArray>;
  34374. /**
  34375. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34376. */
  34377. uvs2: Nullable<FloatArray>;
  34378. /**
  34379. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34380. */
  34381. uvs3: Nullable<FloatArray>;
  34382. /**
  34383. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34384. */
  34385. uvs4: Nullable<FloatArray>;
  34386. /**
  34387. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34388. */
  34389. uvs5: Nullable<FloatArray>;
  34390. /**
  34391. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34392. */
  34393. uvs6: Nullable<FloatArray>;
  34394. /**
  34395. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34396. */
  34397. colors: Nullable<FloatArray>;
  34398. /**
  34399. * 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).
  34400. */
  34401. matricesIndices: Nullable<FloatArray>;
  34402. /**
  34403. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34404. */
  34405. matricesWeights: Nullable<FloatArray>;
  34406. /**
  34407. * An array extending the number of possible indices
  34408. */
  34409. matricesIndicesExtra: Nullable<FloatArray>;
  34410. /**
  34411. * An array extending the number of possible weights when the number of indices is extended
  34412. */
  34413. matricesWeightsExtra: Nullable<FloatArray>;
  34414. /**
  34415. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34416. */
  34417. indices: Nullable<IndicesArray>;
  34418. /**
  34419. * Uses the passed data array to set the set the values for the specified kind of data
  34420. * @param data a linear array of floating numbers
  34421. * @param kind the type of data that is being set, eg positions, colors etc
  34422. */
  34423. set(data: FloatArray, kind: string): void;
  34424. /**
  34425. * Associates the vertexData to the passed Mesh.
  34426. * Sets it as updatable or not (default `false`)
  34427. * @param mesh the mesh the vertexData is applied to
  34428. * @param updatable when used and having the value true allows new data to update the vertexData
  34429. * @returns the VertexData
  34430. */
  34431. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34432. /**
  34433. * Associates the vertexData to the passed Geometry.
  34434. * Sets it as updatable or not (default `false`)
  34435. * @param geometry the geometry the vertexData is applied to
  34436. * @param updatable when used and having the value true allows new data to update the vertexData
  34437. * @returns VertexData
  34438. */
  34439. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34440. /**
  34441. * Updates the associated mesh
  34442. * @param mesh the mesh to be updated
  34443. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34444. * @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
  34445. * @returns VertexData
  34446. */
  34447. updateMesh(mesh: Mesh): VertexData;
  34448. /**
  34449. * Updates the associated geometry
  34450. * @param geometry the geometry to be updated
  34451. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34452. * @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
  34453. * @returns VertexData.
  34454. */
  34455. updateGeometry(geometry: Geometry): VertexData;
  34456. private _applyTo;
  34457. private _update;
  34458. /**
  34459. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34460. * @param matrix the transforming matrix
  34461. * @returns the VertexData
  34462. */
  34463. transform(matrix: Matrix): VertexData;
  34464. /**
  34465. * Merges the passed VertexData into the current one
  34466. * @param other the VertexData to be merged into the current one
  34467. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34468. * @returns the modified VertexData
  34469. */
  34470. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34471. private _mergeElement;
  34472. private _validate;
  34473. /**
  34474. * Serializes the VertexData
  34475. * @returns a serialized object
  34476. */
  34477. serialize(): any;
  34478. /**
  34479. * Extracts the vertexData from a mesh
  34480. * @param mesh the mesh from which to extract the VertexData
  34481. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34482. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34483. * @returns the object VertexData associated to the passed mesh
  34484. */
  34485. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34486. /**
  34487. * Extracts the vertexData from the geometry
  34488. * @param geometry the geometry from which to extract the VertexData
  34489. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34490. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34491. * @returns the object VertexData associated to the passed mesh
  34492. */
  34493. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34494. private static _ExtractFrom;
  34495. /**
  34496. * Creates the VertexData for a Ribbon
  34497. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34498. * * pathArray array of paths, each of which an array of successive Vector3
  34499. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34500. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34501. * * 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
  34502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34503. * * 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)
  34504. * * 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)
  34505. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34506. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34507. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34508. * @returns the VertexData of the ribbon
  34509. */
  34510. static CreateRibbon(options: {
  34511. pathArray: Vector3[][];
  34512. closeArray?: boolean;
  34513. closePath?: boolean;
  34514. offset?: number;
  34515. sideOrientation?: number;
  34516. frontUVs?: Vector4;
  34517. backUVs?: Vector4;
  34518. invertUV?: boolean;
  34519. uvs?: Vector2[];
  34520. colors?: Color4[];
  34521. }): VertexData;
  34522. /**
  34523. * Creates the VertexData for a box
  34524. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34525. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34526. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34527. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34528. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34529. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34530. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34531. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34532. * * 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)
  34533. * * 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)
  34534. * @returns the VertexData of the box
  34535. */
  34536. static CreateBox(options: {
  34537. size?: number;
  34538. width?: number;
  34539. height?: number;
  34540. depth?: number;
  34541. faceUV?: Vector4[];
  34542. faceColors?: Color4[];
  34543. sideOrientation?: number;
  34544. frontUVs?: Vector4;
  34545. backUVs?: Vector4;
  34546. }): VertexData;
  34547. /**
  34548. * Creates the VertexData for a tiled box
  34549. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34550. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34551. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34552. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34553. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34554. * @returns the VertexData of the box
  34555. */
  34556. static CreateTiledBox(options: {
  34557. pattern?: number;
  34558. width?: number;
  34559. height?: number;
  34560. depth?: number;
  34561. tileSize?: number;
  34562. tileWidth?: number;
  34563. tileHeight?: number;
  34564. alignHorizontal?: number;
  34565. alignVertical?: number;
  34566. faceUV?: Vector4[];
  34567. faceColors?: Color4[];
  34568. sideOrientation?: number;
  34569. }): VertexData;
  34570. /**
  34571. * Creates the VertexData for a tiled plane
  34572. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34573. * * pattern a limited pattern arrangement depending on the number
  34574. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34575. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34576. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34578. * * 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)
  34579. * * 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)
  34580. * @returns the VertexData of the tiled plane
  34581. */
  34582. static CreateTiledPlane(options: {
  34583. pattern?: number;
  34584. tileSize?: number;
  34585. tileWidth?: number;
  34586. tileHeight?: number;
  34587. size?: number;
  34588. width?: number;
  34589. height?: number;
  34590. alignHorizontal?: number;
  34591. alignVertical?: number;
  34592. sideOrientation?: number;
  34593. frontUVs?: Vector4;
  34594. backUVs?: Vector4;
  34595. }): VertexData;
  34596. /**
  34597. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34598. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34599. * * segments sets the number of horizontal strips optional, default 32
  34600. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34601. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34602. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34603. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34604. * * 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
  34605. * * 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
  34606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34607. * * 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)
  34608. * * 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)
  34609. * @returns the VertexData of the ellipsoid
  34610. */
  34611. static CreateSphere(options: {
  34612. segments?: number;
  34613. diameter?: number;
  34614. diameterX?: number;
  34615. diameterY?: number;
  34616. diameterZ?: number;
  34617. arc?: number;
  34618. slice?: number;
  34619. sideOrientation?: number;
  34620. frontUVs?: Vector4;
  34621. backUVs?: Vector4;
  34622. }): VertexData;
  34623. /**
  34624. * Creates the VertexData for a cylinder, cone or prism
  34625. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34626. * * height sets the height (y direction) of the cylinder, optional, default 2
  34627. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34628. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34629. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34630. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34631. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34632. * * 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
  34633. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34634. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34635. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34636. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34637. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34638. * * 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)
  34639. * * 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)
  34640. * @returns the VertexData of the cylinder, cone or prism
  34641. */
  34642. static CreateCylinder(options: {
  34643. height?: number;
  34644. diameterTop?: number;
  34645. diameterBottom?: number;
  34646. diameter?: number;
  34647. tessellation?: number;
  34648. subdivisions?: number;
  34649. arc?: number;
  34650. faceColors?: Color4[];
  34651. faceUV?: Vector4[];
  34652. hasRings?: boolean;
  34653. enclose?: boolean;
  34654. sideOrientation?: number;
  34655. frontUVs?: Vector4;
  34656. backUVs?: Vector4;
  34657. }): VertexData;
  34658. /**
  34659. * Creates the VertexData for a torus
  34660. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34661. * * diameter the diameter of the torus, optional default 1
  34662. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34663. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34665. * * 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)
  34666. * * 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)
  34667. * @returns the VertexData of the torus
  34668. */
  34669. static CreateTorus(options: {
  34670. diameter?: number;
  34671. thickness?: number;
  34672. tessellation?: number;
  34673. sideOrientation?: number;
  34674. frontUVs?: Vector4;
  34675. backUVs?: Vector4;
  34676. }): VertexData;
  34677. /**
  34678. * Creates the VertexData of the LineSystem
  34679. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34680. * - lines an array of lines, each line being an array of successive Vector3
  34681. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34682. * @returns the VertexData of the LineSystem
  34683. */
  34684. static CreateLineSystem(options: {
  34685. lines: Vector3[][];
  34686. colors?: Nullable<Color4[][]>;
  34687. }): VertexData;
  34688. /**
  34689. * Create the VertexData for a DashedLines
  34690. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34691. * - points an array successive Vector3
  34692. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34693. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34694. * - dashNb the intended total number of dashes, optional, default 200
  34695. * @returns the VertexData for the DashedLines
  34696. */
  34697. static CreateDashedLines(options: {
  34698. points: Vector3[];
  34699. dashSize?: number;
  34700. gapSize?: number;
  34701. dashNb?: number;
  34702. }): VertexData;
  34703. /**
  34704. * Creates the VertexData for a Ground
  34705. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34706. * - width the width (x direction) of the ground, optional, default 1
  34707. * - height the height (z direction) of the ground, optional, default 1
  34708. * - subdivisions the number of subdivisions per side, optional, default 1
  34709. * @returns the VertexData of the Ground
  34710. */
  34711. static CreateGround(options: {
  34712. width?: number;
  34713. height?: number;
  34714. subdivisions?: number;
  34715. subdivisionsX?: number;
  34716. subdivisionsY?: number;
  34717. }): VertexData;
  34718. /**
  34719. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34720. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34721. * * xmin the ground minimum X coordinate, optional, default -1
  34722. * * zmin the ground minimum Z coordinate, optional, default -1
  34723. * * xmax the ground maximum X coordinate, optional, default 1
  34724. * * zmax the ground maximum Z coordinate, optional, default 1
  34725. * * 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}
  34726. * * 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}
  34727. * @returns the VertexData of the TiledGround
  34728. */
  34729. static CreateTiledGround(options: {
  34730. xmin: number;
  34731. zmin: number;
  34732. xmax: number;
  34733. zmax: number;
  34734. subdivisions?: {
  34735. w: number;
  34736. h: number;
  34737. };
  34738. precision?: {
  34739. w: number;
  34740. h: number;
  34741. };
  34742. }): VertexData;
  34743. /**
  34744. * Creates the VertexData of the Ground designed from a heightmap
  34745. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34746. * * width the width (x direction) of the ground
  34747. * * height the height (z direction) of the ground
  34748. * * subdivisions the number of subdivisions per side
  34749. * * minHeight the minimum altitude on the ground, optional, default 0
  34750. * * maxHeight the maximum altitude on the ground, optional default 1
  34751. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  34752. * * buffer the array holding the image color data
  34753. * * bufferWidth the width of image
  34754. * * bufferHeight the height of image
  34755. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  34756. * @returns the VertexData of the Ground designed from a heightmap
  34757. */
  34758. static CreateGroundFromHeightMap(options: {
  34759. width: number;
  34760. height: number;
  34761. subdivisions: number;
  34762. minHeight: number;
  34763. maxHeight: number;
  34764. colorFilter: Color3;
  34765. buffer: Uint8Array;
  34766. bufferWidth: number;
  34767. bufferHeight: number;
  34768. alphaFilter: number;
  34769. }): VertexData;
  34770. /**
  34771. * Creates the VertexData for a Plane
  34772. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  34773. * * size sets the width and height of the plane to the value of size, optional default 1
  34774. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  34775. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  34776. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34777. * * 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)
  34778. * * 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)
  34779. * @returns the VertexData of the box
  34780. */
  34781. static CreatePlane(options: {
  34782. size?: number;
  34783. width?: number;
  34784. height?: number;
  34785. sideOrientation?: number;
  34786. frontUVs?: Vector4;
  34787. backUVs?: Vector4;
  34788. }): VertexData;
  34789. /**
  34790. * Creates the VertexData of the Disc or regular Polygon
  34791. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34792. * * radius the radius of the disc, optional default 0.5
  34793. * * tessellation the number of polygon sides, optional, default 64
  34794. * * 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
  34795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34796. * * 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)
  34797. * * 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)
  34798. * @returns the VertexData of the box
  34799. */
  34800. static CreateDisc(options: {
  34801. radius?: number;
  34802. tessellation?: number;
  34803. arc?: number;
  34804. sideOrientation?: number;
  34805. frontUVs?: Vector4;
  34806. backUVs?: Vector4;
  34807. }): VertexData;
  34808. /**
  34809. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34810. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34811. * @param polygon a mesh built from polygonTriangulation.build()
  34812. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34813. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34814. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34815. * @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)
  34816. * @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)
  34817. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34818. * @returns the VertexData of the Polygon
  34819. */
  34820. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34821. /**
  34822. * Creates the VertexData of the IcoSphere
  34823. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34824. * * radius the radius of the IcoSphere, optional default 1
  34825. * * radiusX allows stretching in the x direction, optional, default radius
  34826. * * radiusY allows stretching in the y direction, optional, default radius
  34827. * * radiusZ allows stretching in the z direction, optional, default radius
  34828. * * flat when true creates a flat shaded mesh, optional, default true
  34829. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34830. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34831. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34832. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34833. * @returns the VertexData of the IcoSphere
  34834. */
  34835. static CreateIcoSphere(options: {
  34836. radius?: number;
  34837. radiusX?: number;
  34838. radiusY?: number;
  34839. radiusZ?: number;
  34840. flat?: boolean;
  34841. subdivisions?: number;
  34842. sideOrientation?: number;
  34843. frontUVs?: Vector4;
  34844. backUVs?: Vector4;
  34845. }): VertexData;
  34846. /**
  34847. * Creates the VertexData for a Polyhedron
  34848. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34849. * * type provided types are:
  34850. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34851. * * 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)
  34852. * * size the size of the IcoSphere, optional default 1
  34853. * * sizeX allows stretching in the x direction, optional, default size
  34854. * * sizeY allows stretching in the y direction, optional, default size
  34855. * * sizeZ allows stretching in the z direction, optional, default size
  34856. * * 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
  34857. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34858. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34859. * * flat when true creates a flat shaded mesh, optional, default true
  34860. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 Polyhedron
  34865. */
  34866. static CreatePolyhedron(options: {
  34867. type?: number;
  34868. size?: number;
  34869. sizeX?: number;
  34870. sizeY?: number;
  34871. sizeZ?: number;
  34872. custom?: any;
  34873. faceUV?: Vector4[];
  34874. faceColors?: Color4[];
  34875. flat?: boolean;
  34876. sideOrientation?: number;
  34877. frontUVs?: Vector4;
  34878. backUVs?: Vector4;
  34879. }): VertexData;
  34880. /**
  34881. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34882. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34883. * @returns the VertexData of the Capsule
  34884. */
  34885. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34886. /**
  34887. * Creates the VertexData for a TorusKnot
  34888. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34889. * * radius the radius of the torus knot, optional, default 2
  34890. * * tube the thickness of the tube, optional, default 0.5
  34891. * * radialSegments the number of sides on each tube segments, optional, default 32
  34892. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34893. * * p the number of windings around the z axis, optional, default 2
  34894. * * q the number of windings around the x axis, optional, default 3
  34895. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34896. * * 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)
  34897. * * 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)
  34898. * @returns the VertexData of the Torus Knot
  34899. */
  34900. static CreateTorusKnot(options: {
  34901. radius?: number;
  34902. tube?: number;
  34903. radialSegments?: number;
  34904. tubularSegments?: number;
  34905. p?: number;
  34906. q?: number;
  34907. sideOrientation?: number;
  34908. frontUVs?: Vector4;
  34909. backUVs?: Vector4;
  34910. }): VertexData;
  34911. /**
  34912. * Compute normals for given positions and indices
  34913. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34914. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34915. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34916. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34917. * * facetNormals : optional array of facet normals (vector3)
  34918. * * facetPositions : optional array of facet positions (vector3)
  34919. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34920. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34921. * * bInfo : optional bounding info, required for facetPartitioning computation
  34922. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34923. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34924. * * useRightHandedSystem: optional boolean to for right handed system computation
  34925. * * depthSort : optional boolean to enable the facet depth sort computation
  34926. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34927. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34928. */
  34929. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34930. facetNormals?: any;
  34931. facetPositions?: any;
  34932. facetPartitioning?: any;
  34933. ratio?: number;
  34934. bInfo?: any;
  34935. bbSize?: Vector3;
  34936. subDiv?: any;
  34937. useRightHandedSystem?: boolean;
  34938. depthSort?: boolean;
  34939. distanceTo?: Vector3;
  34940. depthSortedFacets?: any;
  34941. }): void;
  34942. /** @hidden */
  34943. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34944. /**
  34945. * Applies VertexData created from the imported parameters to the geometry
  34946. * @param parsedVertexData the parsed data from an imported file
  34947. * @param geometry the geometry to apply the VertexData to
  34948. */
  34949. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34950. }
  34951. }
  34952. declare module BABYLON {
  34953. /**
  34954. * Class containing static functions to help procedurally build meshes
  34955. */
  34956. export class DiscBuilder {
  34957. /**
  34958. * Creates a plane polygonal mesh. By default, this is a disc
  34959. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34960. * * 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
  34961. * * 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
  34962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34963. * * 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
  34964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34965. * @param name defines the name of the mesh
  34966. * @param options defines the options used to create the mesh
  34967. * @param scene defines the hosting scene
  34968. * @returns the plane polygonal mesh
  34969. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34970. */
  34971. static CreateDisc(name: string, options: {
  34972. radius?: number;
  34973. tessellation?: number;
  34974. arc?: number;
  34975. updatable?: boolean;
  34976. sideOrientation?: number;
  34977. frontUVs?: Vector4;
  34978. backUVs?: Vector4;
  34979. }, scene?: Nullable<Scene>): Mesh;
  34980. }
  34981. }
  34982. declare module BABYLON {
  34983. /**
  34984. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34985. *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.
  34986. * The SPS is also a particle system. It provides some methods to manage the particles.
  34987. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34988. *
  34989. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34990. */
  34991. export class SolidParticleSystem implements IDisposable {
  34992. /**
  34993. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34994. * Example : var p = SPS.particles[i];
  34995. */
  34996. particles: SolidParticle[];
  34997. /**
  34998. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34999. */
  35000. nbParticles: number;
  35001. /**
  35002. * If the particles must ever face the camera (default false). Useful for planar particles.
  35003. */
  35004. billboard: boolean;
  35005. /**
  35006. * Recompute normals when adding a shape
  35007. */
  35008. recomputeNormals: boolean;
  35009. /**
  35010. * This a counter ofr your own usage. It's not set by any SPS functions.
  35011. */
  35012. counter: number;
  35013. /**
  35014. * The SPS name. This name is also given to the underlying mesh.
  35015. */
  35016. name: string;
  35017. /**
  35018. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35019. */
  35020. mesh: Mesh;
  35021. /**
  35022. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35023. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35024. */
  35025. vars: any;
  35026. /**
  35027. * This array is populated when the SPS is set as 'pickable'.
  35028. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35029. * Each element of this array is an object `{idx: int, faceId: int}`.
  35030. * `idx` is the picked particle index in the `SPS.particles` array
  35031. * `faceId` is the picked face index counted within this particle.
  35032. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35033. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35034. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35035. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35036. */
  35037. pickedParticles: {
  35038. idx: number;
  35039. faceId: number;
  35040. }[];
  35041. /**
  35042. * This array is populated when the SPS is set as 'pickable'
  35043. * Each key of this array is a submesh index.
  35044. * Each element of this array is a second array defined like this :
  35045. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35046. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35047. * `idx` is the picked particle index in the `SPS.particles` array
  35048. * `faceId` is the picked face index counted within this particle.
  35049. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35050. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35051. */
  35052. pickedBySubMesh: {
  35053. idx: number;
  35054. faceId: number;
  35055. }[][];
  35056. /**
  35057. * This array is populated when `enableDepthSort` is set to true.
  35058. * Each element of this array is an instance of the class DepthSortedParticle.
  35059. */
  35060. depthSortedParticles: DepthSortedParticle[];
  35061. /**
  35062. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35063. * @hidden
  35064. */
  35065. _bSphereOnly: boolean;
  35066. /**
  35067. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35068. * @hidden
  35069. */
  35070. _bSphereRadiusFactor: number;
  35071. private _scene;
  35072. private _positions;
  35073. private _indices;
  35074. private _normals;
  35075. private _colors;
  35076. private _uvs;
  35077. private _indices32;
  35078. private _positions32;
  35079. private _normals32;
  35080. private _fixedNormal32;
  35081. private _colors32;
  35082. private _uvs32;
  35083. private _index;
  35084. private _updatable;
  35085. private _pickable;
  35086. private _isVisibilityBoxLocked;
  35087. private _alwaysVisible;
  35088. private _depthSort;
  35089. private _expandable;
  35090. private _shapeCounter;
  35091. private _copy;
  35092. private _color;
  35093. private _computeParticleColor;
  35094. private _computeParticleTexture;
  35095. private _computeParticleRotation;
  35096. private _computeParticleVertex;
  35097. private _computeBoundingBox;
  35098. private _depthSortParticles;
  35099. private _camera;
  35100. private _mustUnrotateFixedNormals;
  35101. private _particlesIntersect;
  35102. private _needs32Bits;
  35103. private _isNotBuilt;
  35104. private _lastParticleId;
  35105. private _idxOfId;
  35106. private _multimaterialEnabled;
  35107. private _useModelMaterial;
  35108. private _indicesByMaterial;
  35109. private _materialIndexes;
  35110. private _depthSortFunction;
  35111. private _materialSortFunction;
  35112. private _materials;
  35113. private _multimaterial;
  35114. private _materialIndexesById;
  35115. private _defaultMaterial;
  35116. private _autoUpdateSubMeshes;
  35117. private _tmpVertex;
  35118. /**
  35119. * Creates a SPS (Solid Particle System) object.
  35120. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35121. * @param scene (Scene) is the scene in which the SPS is added.
  35122. * @param options defines the options of the sps e.g.
  35123. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35124. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35125. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35126. * * 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.
  35127. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35128. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35129. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35130. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35131. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35132. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35133. */
  35134. constructor(name: string, scene: Scene, options?: {
  35135. updatable?: boolean;
  35136. isPickable?: boolean;
  35137. enableDepthSort?: boolean;
  35138. particleIntersection?: boolean;
  35139. boundingSphereOnly?: boolean;
  35140. bSphereRadiusFactor?: number;
  35141. expandable?: boolean;
  35142. useModelMaterial?: boolean;
  35143. enableMultiMaterial?: boolean;
  35144. });
  35145. /**
  35146. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35147. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35148. * @returns the created mesh
  35149. */
  35150. buildMesh(): Mesh;
  35151. /**
  35152. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35153. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35154. * Thus the particles generated from `digest()` have their property `position` set yet.
  35155. * @param mesh ( Mesh ) is the mesh to be digested
  35156. * @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
  35157. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35158. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35159. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35160. * @returns the current SPS
  35161. */
  35162. digest(mesh: Mesh, options?: {
  35163. facetNb?: number;
  35164. number?: number;
  35165. delta?: number;
  35166. storage?: [];
  35167. }): SolidParticleSystem;
  35168. /**
  35169. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35170. * @hidden
  35171. */
  35172. private _unrotateFixedNormals;
  35173. /**
  35174. * Resets the temporary working copy particle
  35175. * @hidden
  35176. */
  35177. private _resetCopy;
  35178. /**
  35179. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35180. * @param p the current index in the positions array to be updated
  35181. * @param ind the current index in the indices array
  35182. * @param shape a Vector3 array, the shape geometry
  35183. * @param positions the positions array to be updated
  35184. * @param meshInd the shape indices array
  35185. * @param indices the indices array to be updated
  35186. * @param meshUV the shape uv array
  35187. * @param uvs the uv array to be updated
  35188. * @param meshCol the shape color array
  35189. * @param colors the color array to be updated
  35190. * @param meshNor the shape normals array
  35191. * @param normals the normals array to be updated
  35192. * @param idx the particle index
  35193. * @param idxInShape the particle index in its shape
  35194. * @param options the addShape() method passed options
  35195. * @model the particle model
  35196. * @hidden
  35197. */
  35198. private _meshBuilder;
  35199. /**
  35200. * Returns a shape Vector3 array from positions float array
  35201. * @param positions float array
  35202. * @returns a vector3 array
  35203. * @hidden
  35204. */
  35205. private _posToShape;
  35206. /**
  35207. * Returns a shapeUV array from a float uvs (array deep copy)
  35208. * @param uvs as a float array
  35209. * @returns a shapeUV array
  35210. * @hidden
  35211. */
  35212. private _uvsToShapeUV;
  35213. /**
  35214. * Adds a new particle object in the particles array
  35215. * @param idx particle index in particles array
  35216. * @param id particle id
  35217. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35218. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35219. * @param model particle ModelShape object
  35220. * @param shapeId model shape identifier
  35221. * @param idxInShape index of the particle in the current model
  35222. * @param bInfo model bounding info object
  35223. * @param storage target storage array, if any
  35224. * @hidden
  35225. */
  35226. private _addParticle;
  35227. /**
  35228. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35229. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35230. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35231. * @param nb (positive integer) the number of particles to be created from this model
  35232. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35233. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35234. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35235. * @returns the number of shapes in the system
  35236. */
  35237. addShape(mesh: Mesh, nb: number, options?: {
  35238. positionFunction?: any;
  35239. vertexFunction?: any;
  35240. storage?: [];
  35241. }): number;
  35242. /**
  35243. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35244. * @hidden
  35245. */
  35246. private _rebuildParticle;
  35247. /**
  35248. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35249. * @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.
  35250. * @returns the SPS.
  35251. */
  35252. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35253. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35254. * Returns an array with the removed particles.
  35255. * 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.
  35256. * The SPS can't be empty so at least one particle needs to remain in place.
  35257. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35258. * @param start index of the first particle to remove
  35259. * @param end index of the last particle to remove (included)
  35260. * @returns an array populated with the removed particles
  35261. */
  35262. removeParticles(start: number, end: number): SolidParticle[];
  35263. /**
  35264. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35265. * @param solidParticleArray an array populated with Solid Particles objects
  35266. * @returns the SPS
  35267. */
  35268. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35269. /**
  35270. * Creates a new particle and modifies the SPS mesh geometry :
  35271. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35272. * - calls _addParticle() to populate the particle array
  35273. * factorized code from addShape() and insertParticlesFromArray()
  35274. * @param idx particle index in the particles array
  35275. * @param i particle index in its shape
  35276. * @param modelShape particle ModelShape object
  35277. * @param shape shape vertex array
  35278. * @param meshInd shape indices array
  35279. * @param meshUV shape uv array
  35280. * @param meshCol shape color array
  35281. * @param meshNor shape normals array
  35282. * @param bbInfo shape bounding info
  35283. * @param storage target particle storage
  35284. * @options addShape() passed options
  35285. * @hidden
  35286. */
  35287. private _insertNewParticle;
  35288. /**
  35289. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35290. * This method calls `updateParticle()` for each particle of the SPS.
  35291. * For an animated SPS, it is usually called within the render loop.
  35292. * 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.
  35293. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35294. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35295. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35296. * @returns the SPS.
  35297. */
  35298. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35299. /**
  35300. * Disposes the SPS.
  35301. */
  35302. dispose(): void;
  35303. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35304. * idx is the particle index in the SPS
  35305. * faceId is the picked face index counted within this particle.
  35306. * Returns null if the pickInfo can't identify a picked particle.
  35307. * @param pickingInfo (PickingInfo object)
  35308. * @returns {idx: number, faceId: number} or null
  35309. */
  35310. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35311. idx: number;
  35312. faceId: number;
  35313. }>;
  35314. /**
  35315. * Returns a SolidParticle object from its identifier : particle.id
  35316. * @param id (integer) the particle Id
  35317. * @returns the searched particle or null if not found in the SPS.
  35318. */
  35319. getParticleById(id: number): Nullable<SolidParticle>;
  35320. /**
  35321. * Returns a new array populated with the particles having the passed shapeId.
  35322. * @param shapeId (integer) the shape identifier
  35323. * @returns a new solid particle array
  35324. */
  35325. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35326. /**
  35327. * Populates the passed array "ref" with the particles having the passed shapeId.
  35328. * @param shapeId the shape identifier
  35329. * @returns the SPS
  35330. * @param ref
  35331. */
  35332. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35333. /**
  35334. * Computes the required SubMeshes according the materials assigned to the particles.
  35335. * @returns the solid particle system.
  35336. * Does nothing if called before the SPS mesh is built.
  35337. */
  35338. computeSubMeshes(): SolidParticleSystem;
  35339. /**
  35340. * Sorts the solid particles by material when MultiMaterial is enabled.
  35341. * Updates the indices32 array.
  35342. * Updates the indicesByMaterial array.
  35343. * Updates the mesh indices array.
  35344. * @returns the SPS
  35345. * @hidden
  35346. */
  35347. private _sortParticlesByMaterial;
  35348. /**
  35349. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35350. * @hidden
  35351. */
  35352. private _setMaterialIndexesById;
  35353. /**
  35354. * Returns an array with unique values of Materials from the passed array
  35355. * @param array the material array to be checked and filtered
  35356. * @hidden
  35357. */
  35358. private _filterUniqueMaterialId;
  35359. /**
  35360. * Sets a new Standard Material as _defaultMaterial if not already set.
  35361. * @hidden
  35362. */
  35363. private _setDefaultMaterial;
  35364. /**
  35365. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35366. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35367. * @returns the SPS.
  35368. */
  35369. refreshVisibleSize(): SolidParticleSystem;
  35370. /**
  35371. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35372. * @param size the size (float) of the visibility box
  35373. * note : this doesn't lock the SPS mesh bounding box.
  35374. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35375. */
  35376. setVisibilityBox(size: number): void;
  35377. /**
  35378. * Gets whether the SPS as always visible or not
  35379. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35380. */
  35381. get isAlwaysVisible(): boolean;
  35382. /**
  35383. * Sets the SPS as always visible or not
  35384. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35385. */
  35386. set isAlwaysVisible(val: boolean);
  35387. /**
  35388. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35389. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35390. */
  35391. set isVisibilityBoxLocked(val: boolean);
  35392. /**
  35393. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35394. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35395. */
  35396. get isVisibilityBoxLocked(): boolean;
  35397. /**
  35398. * Tells to `setParticles()` to compute the particle rotations or not.
  35399. * Default value : true. The SPS is faster when it's set to false.
  35400. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35401. */
  35402. set computeParticleRotation(val: boolean);
  35403. /**
  35404. * Tells to `setParticles()` to compute the particle colors or not.
  35405. * Default value : true. The SPS is faster when it's set to false.
  35406. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35407. */
  35408. set computeParticleColor(val: boolean);
  35409. set computeParticleTexture(val: boolean);
  35410. /**
  35411. * Tells to `setParticles()` to call 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. set computeParticleVertex(val: boolean);
  35416. /**
  35417. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35418. */
  35419. set computeBoundingBox(val: boolean);
  35420. /**
  35421. * Tells to `setParticles()` to sort 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. set depthSortParticles(val: boolean);
  35426. /**
  35427. * Gets if `setParticles()` computes the particle rotations or not.
  35428. * Default value : true. The SPS is faster when it's set to false.
  35429. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35430. */
  35431. get computeParticleRotation(): boolean;
  35432. /**
  35433. * Gets if `setParticles()` computes the particle colors or not.
  35434. * Default value : true. The SPS is faster when it's set to false.
  35435. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35436. */
  35437. get computeParticleColor(): boolean;
  35438. /**
  35439. * Gets if `setParticles()` computes the particle textures or not.
  35440. * Default value : true. The SPS is faster when it's set to false.
  35441. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35442. */
  35443. get computeParticleTexture(): boolean;
  35444. /**
  35445. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35446. * Default value : false. The SPS is faster when it's set to false.
  35447. * Note : the particle custom vertex positions aren't stored values.
  35448. */
  35449. get computeParticleVertex(): boolean;
  35450. /**
  35451. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35452. */
  35453. get computeBoundingBox(): boolean;
  35454. /**
  35455. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35456. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35457. * Default : `true`
  35458. */
  35459. get depthSortParticles(): boolean;
  35460. /**
  35461. * Gets if the SPS is created as expandable at construction time.
  35462. * Default : `false`
  35463. */
  35464. get expandable(): boolean;
  35465. /**
  35466. * Gets if the SPS supports the Multi Materials
  35467. */
  35468. get multimaterialEnabled(): boolean;
  35469. /**
  35470. * Gets if the SPS uses the model materials for its own multimaterial.
  35471. */
  35472. get useModelMaterial(): boolean;
  35473. /**
  35474. * The SPS used material array.
  35475. */
  35476. get materials(): Material[];
  35477. /**
  35478. * Sets the SPS MultiMaterial from the passed materials.
  35479. * Note : the passed array is internally copied and not used then by reference.
  35480. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35481. */
  35482. setMultiMaterial(materials: Material[]): void;
  35483. /**
  35484. * The SPS computed multimaterial object
  35485. */
  35486. get multimaterial(): MultiMaterial;
  35487. set multimaterial(mm: MultiMaterial);
  35488. /**
  35489. * If the subMeshes must be updated on the next call to setParticles()
  35490. */
  35491. get autoUpdateSubMeshes(): boolean;
  35492. set autoUpdateSubMeshes(val: boolean);
  35493. /**
  35494. * This function does nothing. It may be overwritten to set all the particle first values.
  35495. * The SPS doesn't call this function, you may have to call it by your own.
  35496. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35497. */
  35498. initParticles(): void;
  35499. /**
  35500. * This function does nothing. It may be overwritten to recycle a particle.
  35501. * The SPS doesn't call this function, you may have to call it by your own.
  35502. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35503. * @param particle The particle to recycle
  35504. * @returns the recycled particle
  35505. */
  35506. recycleParticle(particle: SolidParticle): SolidParticle;
  35507. /**
  35508. * Updates a particle : this function should be overwritten by the user.
  35509. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35510. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35511. * @example : just set a particle position or velocity and recycle conditions
  35512. * @param particle The particle to update
  35513. * @returns the updated particle
  35514. */
  35515. updateParticle(particle: SolidParticle): SolidParticle;
  35516. /**
  35517. * Updates a vertex of a particle : it can be overwritten by the user.
  35518. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35519. * @param particle the current particle
  35520. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35521. * @param pt the index of the current vertex in the particle shape
  35522. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35523. * @example : just set a vertex particle position or color
  35524. * @returns the sps
  35525. */
  35526. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35527. /**
  35528. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35529. * This does nothing and may be overwritten by the user.
  35530. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35531. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35532. * @param update the boolean update value actually passed to setParticles()
  35533. */
  35534. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35535. /**
  35536. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35537. * This will be passed three parameters.
  35538. * This does nothing and may be overwritten by the user.
  35539. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35540. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35541. * @param update the boolean update value actually passed to setParticles()
  35542. */
  35543. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35544. }
  35545. }
  35546. declare module BABYLON {
  35547. /**
  35548. * Represents one particle of a solid particle system.
  35549. */
  35550. export class SolidParticle {
  35551. /**
  35552. * particle global index
  35553. */
  35554. idx: number;
  35555. /**
  35556. * particle identifier
  35557. */
  35558. id: number;
  35559. /**
  35560. * The color of the particle
  35561. */
  35562. color: Nullable<Color4>;
  35563. /**
  35564. * The world space position of the particle.
  35565. */
  35566. position: Vector3;
  35567. /**
  35568. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35569. */
  35570. rotation: Vector3;
  35571. /**
  35572. * The world space rotation quaternion of the particle.
  35573. */
  35574. rotationQuaternion: Nullable<Quaternion>;
  35575. /**
  35576. * The scaling of the particle.
  35577. */
  35578. scaling: Vector3;
  35579. /**
  35580. * The uvs of the particle.
  35581. */
  35582. uvs: Vector4;
  35583. /**
  35584. * The current speed of the particle.
  35585. */
  35586. velocity: Vector3;
  35587. /**
  35588. * The pivot point in the particle local space.
  35589. */
  35590. pivot: Vector3;
  35591. /**
  35592. * Must the particle be translated from its pivot point in its local space ?
  35593. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35594. * Default : false
  35595. */
  35596. translateFromPivot: boolean;
  35597. /**
  35598. * Is the particle active or not ?
  35599. */
  35600. alive: boolean;
  35601. /**
  35602. * Is the particle visible or not ?
  35603. */
  35604. isVisible: boolean;
  35605. /**
  35606. * Index of this particle in the global "positions" array (Internal use)
  35607. * @hidden
  35608. */
  35609. _pos: number;
  35610. /**
  35611. * @hidden Index of this particle in the global "indices" array (Internal use)
  35612. */
  35613. _ind: number;
  35614. /**
  35615. * @hidden ModelShape of this particle (Internal use)
  35616. */
  35617. _model: ModelShape;
  35618. /**
  35619. * ModelShape id of this particle
  35620. */
  35621. shapeId: number;
  35622. /**
  35623. * Index of the particle in its shape id
  35624. */
  35625. idxInShape: number;
  35626. /**
  35627. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35628. */
  35629. _modelBoundingInfo: BoundingInfo;
  35630. /**
  35631. * @hidden Particle BoundingInfo object (Internal use)
  35632. */
  35633. _boundingInfo: BoundingInfo;
  35634. /**
  35635. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35636. */
  35637. _sps: SolidParticleSystem;
  35638. /**
  35639. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35640. */
  35641. _stillInvisible: boolean;
  35642. /**
  35643. * @hidden Last computed particle rotation matrix
  35644. */
  35645. _rotationMatrix: number[];
  35646. /**
  35647. * Parent particle Id, if any.
  35648. * Default null.
  35649. */
  35650. parentId: Nullable<number>;
  35651. /**
  35652. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35653. */
  35654. materialIndex: Nullable<number>;
  35655. /**
  35656. * Custom object or properties.
  35657. */
  35658. props: Nullable<any>;
  35659. /**
  35660. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35661. * The possible values are :
  35662. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35663. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35664. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35665. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35666. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35667. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35668. * */
  35669. cullingStrategy: number;
  35670. /**
  35671. * @hidden Internal global position in the SPS.
  35672. */
  35673. _globalPosition: Vector3;
  35674. /**
  35675. * Creates a Solid Particle object.
  35676. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35677. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35678. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35679. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35680. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35681. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35682. * @param shapeId (integer) is the model shape identifier in the SPS.
  35683. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35684. * @param sps defines the sps it is associated to
  35685. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35686. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35687. */
  35688. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35689. /**
  35690. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35691. * @param target the particle target
  35692. * @returns the current particle
  35693. */
  35694. copyToRef(target: SolidParticle): SolidParticle;
  35695. /**
  35696. * Legacy support, changed scale to scaling
  35697. */
  35698. get scale(): Vector3;
  35699. /**
  35700. * Legacy support, changed scale to scaling
  35701. */
  35702. set scale(scale: Vector3);
  35703. /**
  35704. * Legacy support, changed quaternion to rotationQuaternion
  35705. */
  35706. get quaternion(): Nullable<Quaternion>;
  35707. /**
  35708. * Legacy support, changed quaternion to rotationQuaternion
  35709. */
  35710. set quaternion(q: Nullable<Quaternion>);
  35711. /**
  35712. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35713. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35714. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35715. * @returns true if it intersects
  35716. */
  35717. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35718. /**
  35719. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35720. * A particle is in the frustum if its bounding box intersects the frustum
  35721. * @param frustumPlanes defines the frustum to test
  35722. * @returns true if the particle is in the frustum planes
  35723. */
  35724. isInFrustum(frustumPlanes: Plane[]): boolean;
  35725. /**
  35726. * get the rotation matrix of the particle
  35727. * @hidden
  35728. */
  35729. getRotationMatrix(m: Matrix): void;
  35730. }
  35731. /**
  35732. * Represents the shape of the model used by one particle of a solid particle system.
  35733. * SPS internal tool, don't use it manually.
  35734. */
  35735. export class ModelShape {
  35736. /**
  35737. * The shape id
  35738. * @hidden
  35739. */
  35740. shapeID: number;
  35741. /**
  35742. * flat array of model positions (internal use)
  35743. * @hidden
  35744. */
  35745. _shape: Vector3[];
  35746. /**
  35747. * flat array of model UVs (internal use)
  35748. * @hidden
  35749. */
  35750. _shapeUV: number[];
  35751. /**
  35752. * color array of the model
  35753. * @hidden
  35754. */
  35755. _shapeColors: number[];
  35756. /**
  35757. * indices array of the model
  35758. * @hidden
  35759. */
  35760. _indices: number[];
  35761. /**
  35762. * normals array of the model
  35763. * @hidden
  35764. */
  35765. _normals: number[];
  35766. /**
  35767. * length of the shape in the model indices array (internal use)
  35768. * @hidden
  35769. */
  35770. _indicesLength: number;
  35771. /**
  35772. * Custom position function (internal use)
  35773. * @hidden
  35774. */
  35775. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35776. /**
  35777. * Custom vertex function (internal use)
  35778. * @hidden
  35779. */
  35780. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35781. /**
  35782. * Model material (internal use)
  35783. * @hidden
  35784. */
  35785. _material: Nullable<Material>;
  35786. /**
  35787. * 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.
  35788. * SPS internal tool, don't use it manually.
  35789. * @hidden
  35790. */
  35791. 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>);
  35792. }
  35793. /**
  35794. * Represents a Depth Sorted Particle in the solid particle system.
  35795. * @hidden
  35796. */
  35797. export class DepthSortedParticle {
  35798. /**
  35799. * Particle index
  35800. */
  35801. idx: number;
  35802. /**
  35803. * Index of the particle in the "indices" array
  35804. */
  35805. ind: number;
  35806. /**
  35807. * Length of the particle shape in the "indices" array
  35808. */
  35809. indicesLength: number;
  35810. /**
  35811. * Squared distance from the particle to the camera
  35812. */
  35813. sqDistance: number;
  35814. /**
  35815. * Material index when used with MultiMaterials
  35816. */
  35817. materialIndex: number;
  35818. /**
  35819. * Creates a new sorted particle
  35820. * @param materialIndex
  35821. */
  35822. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35823. }
  35824. /**
  35825. * Represents a solid particle vertex
  35826. */
  35827. export class SolidParticleVertex {
  35828. /**
  35829. * Vertex position
  35830. */
  35831. position: Vector3;
  35832. /**
  35833. * Vertex color
  35834. */
  35835. color: Color4;
  35836. /**
  35837. * Vertex UV
  35838. */
  35839. uv: Vector2;
  35840. /**
  35841. * Creates a new solid particle vertex
  35842. */
  35843. constructor();
  35844. /** Vertex x coordinate */
  35845. get x(): number;
  35846. set x(val: number);
  35847. /** Vertex y coordinate */
  35848. get y(): number;
  35849. set y(val: number);
  35850. /** Vertex z coordinate */
  35851. get z(): number;
  35852. set z(val: number);
  35853. }
  35854. }
  35855. declare module BABYLON {
  35856. /**
  35857. * @hidden
  35858. */
  35859. export class _MeshCollisionData {
  35860. _checkCollisions: boolean;
  35861. _collisionMask: number;
  35862. _collisionGroup: number;
  35863. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35864. _collider: Nullable<Collider>;
  35865. _oldPositionForCollisions: Vector3;
  35866. _diffPositionForCollisions: Vector3;
  35867. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35868. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35869. _collisionResponse: boolean;
  35870. }
  35871. }
  35872. declare module BABYLON {
  35873. /** @hidden */
  35874. class _FacetDataStorage {
  35875. facetPositions: Vector3[];
  35876. facetNormals: Vector3[];
  35877. facetPartitioning: number[][];
  35878. facetNb: number;
  35879. partitioningSubdivisions: number;
  35880. partitioningBBoxRatio: number;
  35881. facetDataEnabled: boolean;
  35882. facetParameters: any;
  35883. bbSize: Vector3;
  35884. subDiv: {
  35885. max: number;
  35886. X: number;
  35887. Y: number;
  35888. Z: number;
  35889. };
  35890. facetDepthSort: boolean;
  35891. facetDepthSortEnabled: boolean;
  35892. depthSortedIndices: IndicesArray;
  35893. depthSortedFacets: {
  35894. ind: number;
  35895. sqDistance: number;
  35896. }[];
  35897. facetDepthSortFunction: (f1: {
  35898. ind: number;
  35899. sqDistance: number;
  35900. }, f2: {
  35901. ind: number;
  35902. sqDistance: number;
  35903. }) => number;
  35904. facetDepthSortFrom: Vector3;
  35905. facetDepthSortOrigin: Vector3;
  35906. invertedMatrix: Matrix;
  35907. }
  35908. /**
  35909. * @hidden
  35910. **/
  35911. class _InternalAbstractMeshDataInfo {
  35912. _hasVertexAlpha: boolean;
  35913. _useVertexColors: boolean;
  35914. _numBoneInfluencers: number;
  35915. _applyFog: boolean;
  35916. _receiveShadows: boolean;
  35917. _facetData: _FacetDataStorage;
  35918. _visibility: number;
  35919. _skeleton: Nullable<Skeleton>;
  35920. _layerMask: number;
  35921. _computeBonesUsingShaders: boolean;
  35922. _isActive: boolean;
  35923. _onlyForInstances: boolean;
  35924. _isActiveIntermediate: boolean;
  35925. _onlyForInstancesIntermediate: boolean;
  35926. _actAsRegularMesh: boolean;
  35927. _currentLOD: Nullable<AbstractMesh>;
  35928. _currentLODIsUpToDate: boolean;
  35929. }
  35930. /**
  35931. * Class used to store all common mesh properties
  35932. */
  35933. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35934. /** No occlusion */
  35935. static OCCLUSION_TYPE_NONE: number;
  35936. /** Occlusion set to optimisitic */
  35937. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35938. /** Occlusion set to strict */
  35939. static OCCLUSION_TYPE_STRICT: number;
  35940. /** Use an accurante occlusion algorithm */
  35941. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35942. /** Use a conservative occlusion algorithm */
  35943. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35944. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35945. * Test order :
  35946. * Is the bounding sphere outside the frustum ?
  35947. * If not, are the bounding box vertices outside the frustum ?
  35948. * It not, then the cullable object is in the frustum.
  35949. */
  35950. static readonly CULLINGSTRATEGY_STANDARD: number;
  35951. /** Culling strategy : Bounding Sphere Only.
  35952. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35953. * It's also less accurate than the standard because some not visible objects can still be selected.
  35954. * Test : is the bounding sphere outside the frustum ?
  35955. * If not, then the cullable object is in the frustum.
  35956. */
  35957. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35958. /** Culling strategy : Optimistic Inclusion.
  35959. * This in an inclusion test first, then the standard exclusion test.
  35960. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35961. * 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.
  35962. * Anyway, it's as accurate as the standard strategy.
  35963. * Test :
  35964. * Is the cullable object bounding sphere center in the frustum ?
  35965. * If not, apply the default culling strategy.
  35966. */
  35967. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35968. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35969. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35970. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35971. * 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.
  35972. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35973. * Test :
  35974. * Is the cullable object bounding sphere center in the frustum ?
  35975. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35976. */
  35977. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35978. /**
  35979. * No billboard
  35980. */
  35981. static get BILLBOARDMODE_NONE(): number;
  35982. /** Billboard on X axis */
  35983. static get BILLBOARDMODE_X(): number;
  35984. /** Billboard on Y axis */
  35985. static get BILLBOARDMODE_Y(): number;
  35986. /** Billboard on Z axis */
  35987. static get BILLBOARDMODE_Z(): number;
  35988. /** Billboard on all axes */
  35989. static get BILLBOARDMODE_ALL(): number;
  35990. /** Billboard on using position instead of orientation */
  35991. static get BILLBOARDMODE_USE_POSITION(): number;
  35992. /** @hidden */
  35993. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35994. /**
  35995. * The culling strategy to use to check whether the mesh must be rendered or not.
  35996. * This value can be changed at any time and will be used on the next render mesh selection.
  35997. * The possible values are :
  35998. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35999. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36000. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36001. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36002. * Please read each static variable documentation to get details about the culling process.
  36003. * */
  36004. cullingStrategy: number;
  36005. /**
  36006. * Gets the number of facets in the mesh
  36007. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36008. */
  36009. get facetNb(): number;
  36010. /**
  36011. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36012. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36013. */
  36014. get partitioningSubdivisions(): number;
  36015. set partitioningSubdivisions(nb: number);
  36016. /**
  36017. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36018. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36019. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36020. */
  36021. get partitioningBBoxRatio(): number;
  36022. set partitioningBBoxRatio(ratio: number);
  36023. /**
  36024. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36025. * Works only for updatable meshes.
  36026. * Doesn't work with multi-materials
  36027. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36028. */
  36029. get mustDepthSortFacets(): boolean;
  36030. set mustDepthSortFacets(sort: boolean);
  36031. /**
  36032. * The location (Vector3) where the facet depth sort must be computed from.
  36033. * By default, the active camera position.
  36034. * Used only when facet depth sort is enabled
  36035. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36036. */
  36037. get facetDepthSortFrom(): Vector3;
  36038. set facetDepthSortFrom(location: Vector3);
  36039. /**
  36040. * gets a boolean indicating if facetData is enabled
  36041. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36042. */
  36043. get isFacetDataEnabled(): boolean;
  36044. /** @hidden */
  36045. _updateNonUniformScalingState(value: boolean): boolean;
  36046. /**
  36047. * An event triggered when this mesh collides with another one
  36048. */
  36049. onCollideObservable: Observable<AbstractMesh>;
  36050. /** Set a function to call when this mesh collides with another one */
  36051. set onCollide(callback: () => void);
  36052. /**
  36053. * An event triggered when the collision's position changes
  36054. */
  36055. onCollisionPositionChangeObservable: Observable<Vector3>;
  36056. /** Set a function to call when the collision's position changes */
  36057. set onCollisionPositionChange(callback: () => void);
  36058. /**
  36059. * An event triggered when material is changed
  36060. */
  36061. onMaterialChangedObservable: Observable<AbstractMesh>;
  36062. /**
  36063. * Gets or sets the orientation for POV movement & rotation
  36064. */
  36065. definedFacingForward: boolean;
  36066. /** @hidden */
  36067. _occlusionQuery: Nullable<WebGLQuery>;
  36068. /** @hidden */
  36069. _renderingGroup: Nullable<RenderingGroup>;
  36070. /**
  36071. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36072. */
  36073. get visibility(): number;
  36074. /**
  36075. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36076. */
  36077. set visibility(value: number);
  36078. /** Gets or sets the alpha index used to sort transparent meshes
  36079. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36080. */
  36081. alphaIndex: number;
  36082. /**
  36083. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36084. */
  36085. isVisible: boolean;
  36086. /**
  36087. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36088. */
  36089. isPickable: boolean;
  36090. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36091. showSubMeshesBoundingBox: boolean;
  36092. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36093. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36094. */
  36095. isBlocker: boolean;
  36096. /**
  36097. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36098. */
  36099. enablePointerMoveEvents: boolean;
  36100. private _renderingGroupId;
  36101. /**
  36102. * Specifies the rendering group id for this mesh (0 by default)
  36103. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36104. */
  36105. get renderingGroupId(): number;
  36106. set renderingGroupId(value: number);
  36107. private _material;
  36108. /** Gets or sets current material */
  36109. get material(): Nullable<Material>;
  36110. set material(value: Nullable<Material>);
  36111. /**
  36112. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36113. * @see https://doc.babylonjs.com/babylon101/shadows
  36114. */
  36115. get receiveShadows(): boolean;
  36116. set receiveShadows(value: boolean);
  36117. /** Defines color to use when rendering outline */
  36118. outlineColor: Color3;
  36119. /** Define width to use when rendering outline */
  36120. outlineWidth: number;
  36121. /** Defines color to use when rendering overlay */
  36122. overlayColor: Color3;
  36123. /** Defines alpha to use when rendering overlay */
  36124. overlayAlpha: number;
  36125. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36126. get hasVertexAlpha(): boolean;
  36127. set hasVertexAlpha(value: boolean);
  36128. /** 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) */
  36129. get useVertexColors(): boolean;
  36130. set useVertexColors(value: boolean);
  36131. /**
  36132. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36133. */
  36134. get computeBonesUsingShaders(): boolean;
  36135. set computeBonesUsingShaders(value: boolean);
  36136. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36137. get numBoneInfluencers(): number;
  36138. set numBoneInfluencers(value: number);
  36139. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36140. get applyFog(): boolean;
  36141. set applyFog(value: boolean);
  36142. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36143. useOctreeForRenderingSelection: boolean;
  36144. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36145. useOctreeForPicking: boolean;
  36146. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36147. useOctreeForCollisions: boolean;
  36148. /**
  36149. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36150. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36151. */
  36152. get layerMask(): number;
  36153. set layerMask(value: number);
  36154. /**
  36155. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36156. */
  36157. alwaysSelectAsActiveMesh: boolean;
  36158. /**
  36159. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36160. */
  36161. doNotSyncBoundingInfo: boolean;
  36162. /**
  36163. * Gets or sets the current action manager
  36164. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36165. */
  36166. actionManager: Nullable<AbstractActionManager>;
  36167. private _meshCollisionData;
  36168. /**
  36169. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36170. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36171. */
  36172. ellipsoid: Vector3;
  36173. /**
  36174. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36175. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36176. */
  36177. ellipsoidOffset: Vector3;
  36178. /**
  36179. * Gets or sets a collision mask used to mask collisions (default is -1).
  36180. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36181. */
  36182. get collisionMask(): number;
  36183. set collisionMask(mask: number);
  36184. /**
  36185. * Gets or sets a collision response flag (default is true).
  36186. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36187. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36188. * to respond to the collision.
  36189. */
  36190. get collisionResponse(): boolean;
  36191. set collisionResponse(response: boolean);
  36192. /**
  36193. * Gets or sets the current collision group mask (-1 by default).
  36194. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36195. */
  36196. get collisionGroup(): number;
  36197. set collisionGroup(mask: number);
  36198. /**
  36199. * Gets or sets current surrounding meshes (null by default).
  36200. *
  36201. * By default collision detection is tested against every mesh in the scene.
  36202. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36203. * meshes will be tested for the collision.
  36204. *
  36205. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36206. */
  36207. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36208. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36209. /**
  36210. * Defines edge width used when edgesRenderer is enabled
  36211. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36212. */
  36213. edgesWidth: number;
  36214. /**
  36215. * Defines edge color used when edgesRenderer is enabled
  36216. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36217. */
  36218. edgesColor: Color4;
  36219. /** @hidden */
  36220. _edgesRenderer: Nullable<IEdgesRenderer>;
  36221. /** @hidden */
  36222. _masterMesh: Nullable<AbstractMesh>;
  36223. /** @hidden */
  36224. _boundingInfo: Nullable<BoundingInfo>;
  36225. /** @hidden */
  36226. _renderId: number;
  36227. /**
  36228. * Gets or sets the list of subMeshes
  36229. * @see https://doc.babylonjs.com/how_to/multi_materials
  36230. */
  36231. subMeshes: SubMesh[];
  36232. /** @hidden */
  36233. _intersectionsInProgress: AbstractMesh[];
  36234. /** @hidden */
  36235. _unIndexed: boolean;
  36236. /** @hidden */
  36237. _lightSources: Light[];
  36238. /** Gets the list of lights affecting that mesh */
  36239. get lightSources(): Light[];
  36240. /** @hidden */
  36241. get _positions(): Nullable<Vector3[]>;
  36242. /** @hidden */
  36243. _waitingData: {
  36244. lods: Nullable<any>;
  36245. actions: Nullable<any>;
  36246. freezeWorldMatrix: Nullable<boolean>;
  36247. };
  36248. /** @hidden */
  36249. _bonesTransformMatrices: Nullable<Float32Array>;
  36250. /** @hidden */
  36251. _transformMatrixTexture: Nullable<RawTexture>;
  36252. /**
  36253. * Gets or sets a skeleton to apply skining transformations
  36254. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36255. */
  36256. set skeleton(value: Nullable<Skeleton>);
  36257. get skeleton(): Nullable<Skeleton>;
  36258. /**
  36259. * An event triggered when the mesh is rebuilt.
  36260. */
  36261. onRebuildObservable: Observable<AbstractMesh>;
  36262. /**
  36263. * The current mesh unifom buffer.
  36264. * @hidden Internal use only.
  36265. */
  36266. _uniformBuffer: UniformBuffer;
  36267. /**
  36268. * Creates a new AbstractMesh
  36269. * @param name defines the name of the mesh
  36270. * @param scene defines the hosting scene
  36271. */
  36272. constructor(name: string, scene?: Nullable<Scene>);
  36273. protected _buildUniformLayout(): void;
  36274. /**
  36275. * Transfer the mesh values to its UBO.
  36276. * @param world The world matrix associated with the mesh
  36277. */
  36278. transferToEffect(world: Matrix): void;
  36279. /**
  36280. * Gets the mesh uniform buffer.
  36281. * @return the uniform buffer of the mesh.
  36282. */
  36283. getMeshUniformBuffer(): UniformBuffer;
  36284. /**
  36285. * Returns the string "AbstractMesh"
  36286. * @returns "AbstractMesh"
  36287. */
  36288. getClassName(): string;
  36289. /**
  36290. * Gets a string representation of the current mesh
  36291. * @param fullDetails defines a boolean indicating if full details must be included
  36292. * @returns a string representation of the current mesh
  36293. */
  36294. toString(fullDetails?: boolean): string;
  36295. /**
  36296. * @hidden
  36297. */
  36298. protected _getEffectiveParent(): Nullable<Node>;
  36299. /** @hidden */
  36300. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36301. /** @hidden */
  36302. _rebuild(): void;
  36303. /** @hidden */
  36304. _resyncLightSources(): void;
  36305. /** @hidden */
  36306. _resyncLightSource(light: Light): void;
  36307. /** @hidden */
  36308. _unBindEffect(): void;
  36309. /** @hidden */
  36310. _removeLightSource(light: Light, dispose: boolean): void;
  36311. private _markSubMeshesAsDirty;
  36312. /** @hidden */
  36313. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36314. /** @hidden */
  36315. _markSubMeshesAsAttributesDirty(): void;
  36316. /** @hidden */
  36317. _markSubMeshesAsMiscDirty(): void;
  36318. /**
  36319. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36320. */
  36321. get scaling(): Vector3;
  36322. set scaling(newScaling: Vector3);
  36323. /**
  36324. * Returns true if the mesh is blocked. Implemented by child classes
  36325. */
  36326. get isBlocked(): boolean;
  36327. /**
  36328. * Returns the mesh itself by default. Implemented by child classes
  36329. * @param camera defines the camera to use to pick the right LOD level
  36330. * @returns the currentAbstractMesh
  36331. */
  36332. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36333. /**
  36334. * Returns 0 by default. Implemented by child classes
  36335. * @returns an integer
  36336. */
  36337. getTotalVertices(): number;
  36338. /**
  36339. * Returns a positive integer : the total number of indices in this mesh geometry.
  36340. * @returns the numner of indices or zero if the mesh has no geometry.
  36341. */
  36342. getTotalIndices(): number;
  36343. /**
  36344. * Returns null by default. Implemented by child classes
  36345. * @returns null
  36346. */
  36347. getIndices(): Nullable<IndicesArray>;
  36348. /**
  36349. * Returns the array of the requested vertex data kind. Implemented by child classes
  36350. * @param kind defines the vertex data kind to use
  36351. * @returns null
  36352. */
  36353. getVerticesData(kind: string): Nullable<FloatArray>;
  36354. /**
  36355. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36356. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36357. * Note that a new underlying VertexBuffer object is created each call.
  36358. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36359. * @param kind defines vertex data kind:
  36360. * * VertexBuffer.PositionKind
  36361. * * VertexBuffer.UVKind
  36362. * * VertexBuffer.UV2Kind
  36363. * * VertexBuffer.UV3Kind
  36364. * * VertexBuffer.UV4Kind
  36365. * * VertexBuffer.UV5Kind
  36366. * * VertexBuffer.UV6Kind
  36367. * * VertexBuffer.ColorKind
  36368. * * VertexBuffer.MatricesIndicesKind
  36369. * * VertexBuffer.MatricesIndicesExtraKind
  36370. * * VertexBuffer.MatricesWeightsKind
  36371. * * VertexBuffer.MatricesWeightsExtraKind
  36372. * @param data defines the data source
  36373. * @param updatable defines if the data must be flagged as updatable (or static)
  36374. * @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
  36375. * @returns the current mesh
  36376. */
  36377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36378. /**
  36379. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36380. * If the mesh has no geometry, it is simply returned as it is.
  36381. * @param kind defines vertex data kind:
  36382. * * VertexBuffer.PositionKind
  36383. * * VertexBuffer.UVKind
  36384. * * VertexBuffer.UV2Kind
  36385. * * VertexBuffer.UV3Kind
  36386. * * VertexBuffer.UV4Kind
  36387. * * VertexBuffer.UV5Kind
  36388. * * VertexBuffer.UV6Kind
  36389. * * VertexBuffer.ColorKind
  36390. * * VertexBuffer.MatricesIndicesKind
  36391. * * VertexBuffer.MatricesIndicesExtraKind
  36392. * * VertexBuffer.MatricesWeightsKind
  36393. * * VertexBuffer.MatricesWeightsExtraKind
  36394. * @param data defines the data source
  36395. * @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
  36396. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36397. * @returns the current mesh
  36398. */
  36399. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36400. /**
  36401. * Sets the mesh indices,
  36402. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36403. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36404. * @param totalVertices Defines the total number of vertices
  36405. * @returns the current mesh
  36406. */
  36407. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36408. /**
  36409. * Gets a boolean indicating if specific vertex data is present
  36410. * @param kind defines the vertex data kind to use
  36411. * @returns true is data kind is present
  36412. */
  36413. isVerticesDataPresent(kind: string): boolean;
  36414. /**
  36415. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36416. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36417. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36418. * @returns a BoundingInfo
  36419. */
  36420. getBoundingInfo(): BoundingInfo;
  36421. /**
  36422. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36423. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36424. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36425. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36426. * @returns the current mesh
  36427. */
  36428. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36429. /**
  36430. * Overwrite the current bounding info
  36431. * @param boundingInfo defines the new bounding info
  36432. * @returns the current mesh
  36433. */
  36434. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36435. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36436. get useBones(): boolean;
  36437. /** @hidden */
  36438. _preActivate(): void;
  36439. /** @hidden */
  36440. _preActivateForIntermediateRendering(renderId: number): void;
  36441. /** @hidden */
  36442. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36443. /** @hidden */
  36444. _postActivate(): void;
  36445. /** @hidden */
  36446. _freeze(): void;
  36447. /** @hidden */
  36448. _unFreeze(): void;
  36449. /**
  36450. * Gets the current world matrix
  36451. * @returns a Matrix
  36452. */
  36453. getWorldMatrix(): Matrix;
  36454. /** @hidden */
  36455. _getWorldMatrixDeterminant(): number;
  36456. /**
  36457. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36458. */
  36459. get isAnInstance(): boolean;
  36460. /**
  36461. * Gets a boolean indicating if this mesh has instances
  36462. */
  36463. get hasInstances(): boolean;
  36464. /**
  36465. * Gets a boolean indicating if this mesh has thin instances
  36466. */
  36467. get hasThinInstances(): boolean;
  36468. /**
  36469. * Perform relative position change from the point of view of behind the front of the mesh.
  36470. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36471. * Supports definition of mesh facing forward or backward
  36472. * @param amountRight defines the distance on the right axis
  36473. * @param amountUp defines the distance on the up axis
  36474. * @param amountForward defines the distance on the forward axis
  36475. * @returns the current mesh
  36476. */
  36477. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36478. /**
  36479. * Calculate relative position change from the point of view of behind the front of the mesh.
  36480. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36481. * Supports definition of mesh facing forward or backward
  36482. * @param amountRight defines the distance on the right axis
  36483. * @param amountUp defines the distance on the up axis
  36484. * @param amountForward defines the distance on the forward axis
  36485. * @returns the new displacement vector
  36486. */
  36487. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36488. /**
  36489. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36490. * Supports definition of mesh facing forward or backward
  36491. * @param flipBack defines the flip
  36492. * @param twirlClockwise defines the twirl
  36493. * @param tiltRight defines the tilt
  36494. * @returns the current mesh
  36495. */
  36496. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36497. /**
  36498. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36499. * Supports definition of mesh facing forward or backward.
  36500. * @param flipBack defines the flip
  36501. * @param twirlClockwise defines the twirl
  36502. * @param tiltRight defines the tilt
  36503. * @returns the new rotation vector
  36504. */
  36505. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36506. /**
  36507. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36508. * This means the mesh underlying bounding box and sphere are recomputed.
  36509. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36510. * @returns the current mesh
  36511. */
  36512. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36513. /** @hidden */
  36514. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36515. /** @hidden */
  36516. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36517. /** @hidden */
  36518. _updateBoundingInfo(): AbstractMesh;
  36519. /** @hidden */
  36520. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36521. /** @hidden */
  36522. protected _afterComputeWorldMatrix(): void;
  36523. /** @hidden */
  36524. get _effectiveMesh(): AbstractMesh;
  36525. /**
  36526. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36527. * A mesh is in the frustum if its bounding box intersects the frustum
  36528. * @param frustumPlanes defines the frustum to test
  36529. * @returns true if the mesh is in the frustum planes
  36530. */
  36531. isInFrustum(frustumPlanes: Plane[]): boolean;
  36532. /**
  36533. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36534. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36535. * @param frustumPlanes defines the frustum to test
  36536. * @returns true if the mesh is completely in the frustum planes
  36537. */
  36538. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36539. /**
  36540. * True if the mesh intersects another mesh or a SolidParticle object
  36541. * @param mesh defines a target mesh or SolidParticle to test
  36542. * @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)
  36543. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36544. * @returns true if there is an intersection
  36545. */
  36546. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36547. /**
  36548. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36549. * @param point defines the point to test
  36550. * @returns true if there is an intersection
  36551. */
  36552. intersectsPoint(point: Vector3): boolean;
  36553. /**
  36554. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36555. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36556. */
  36557. get checkCollisions(): boolean;
  36558. set checkCollisions(collisionEnabled: boolean);
  36559. /**
  36560. * Gets Collider object used to compute collisions (not physics)
  36561. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36562. */
  36563. get collider(): Nullable<Collider>;
  36564. /**
  36565. * Move the mesh using collision engine
  36566. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36567. * @param displacement defines the requested displacement vector
  36568. * @returns the current mesh
  36569. */
  36570. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36571. private _onCollisionPositionChange;
  36572. /** @hidden */
  36573. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36574. /** @hidden */
  36575. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36576. /** @hidden */
  36577. _checkCollision(collider: Collider): AbstractMesh;
  36578. /** @hidden */
  36579. _generatePointsArray(): boolean;
  36580. /**
  36581. * Checks if the passed Ray intersects with the mesh
  36582. * @param ray defines the ray to use
  36583. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36584. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36585. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36586. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36587. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36588. * @returns the picking info
  36589. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36590. */
  36591. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36592. /**
  36593. * Clones the current mesh
  36594. * @param name defines the mesh name
  36595. * @param newParent defines the new mesh parent
  36596. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36597. * @returns the new mesh
  36598. */
  36599. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36600. /**
  36601. * Disposes all the submeshes of the current meshnp
  36602. * @returns the current mesh
  36603. */
  36604. releaseSubMeshes(): AbstractMesh;
  36605. /**
  36606. * Releases resources associated with this abstract mesh.
  36607. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36608. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36609. */
  36610. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36611. /**
  36612. * Adds the passed mesh as a child to the current mesh
  36613. * @param mesh defines the child mesh
  36614. * @returns the current mesh
  36615. */
  36616. addChild(mesh: AbstractMesh): AbstractMesh;
  36617. /**
  36618. * Removes the passed mesh from the current mesh children list
  36619. * @param mesh defines the child mesh
  36620. * @returns the current mesh
  36621. */
  36622. removeChild(mesh: AbstractMesh): AbstractMesh;
  36623. /** @hidden */
  36624. private _initFacetData;
  36625. /**
  36626. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36627. * This method can be called within the render loop.
  36628. * 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
  36629. * @returns the current mesh
  36630. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36631. */
  36632. updateFacetData(): AbstractMesh;
  36633. /**
  36634. * Returns the facetLocalNormals array.
  36635. * The normals are expressed in the mesh local spac
  36636. * @returns an array of Vector3
  36637. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36638. */
  36639. getFacetLocalNormals(): Vector3[];
  36640. /**
  36641. * Returns the facetLocalPositions array.
  36642. * The facet positions are expressed in the mesh local space
  36643. * @returns an array of Vector3
  36644. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36645. */
  36646. getFacetLocalPositions(): Vector3[];
  36647. /**
  36648. * Returns the facetLocalPartioning array
  36649. * @returns an array of array of numbers
  36650. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36651. */
  36652. getFacetLocalPartitioning(): number[][];
  36653. /**
  36654. * Returns the i-th facet position in the world system.
  36655. * This method allocates a new Vector3 per call
  36656. * @param i defines the facet index
  36657. * @returns a new Vector3
  36658. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36659. */
  36660. getFacetPosition(i: number): Vector3;
  36661. /**
  36662. * Sets the reference Vector3 with the i-th facet position in the world system
  36663. * @param i defines the facet index
  36664. * @param ref defines the target vector
  36665. * @returns the current mesh
  36666. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36667. */
  36668. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36669. /**
  36670. * Returns the i-th facet normal in the world system.
  36671. * This method allocates a new Vector3 per call
  36672. * @param i defines the facet index
  36673. * @returns a new Vector3
  36674. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36675. */
  36676. getFacetNormal(i: number): Vector3;
  36677. /**
  36678. * Sets the reference Vector3 with the i-th facet normal in the world system
  36679. * @param i defines the facet index
  36680. * @param ref defines the target vector
  36681. * @returns the current mesh
  36682. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36683. */
  36684. getFacetNormalToRef(i: number, ref: Vector3): this;
  36685. /**
  36686. * 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)
  36687. * @param x defines x coordinate
  36688. * @param y defines y coordinate
  36689. * @param z defines z coordinate
  36690. * @returns the array of facet indexes
  36691. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36692. */
  36693. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36694. /**
  36695. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36696. * @param projected sets as the (x,y,z) world projection on the facet
  36697. * @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
  36698. * @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
  36699. * @param x defines x coordinate
  36700. * @param y defines y coordinate
  36701. * @param z defines z coordinate
  36702. * @returns the face index if found (or null instead)
  36703. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36704. */
  36705. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36706. /**
  36707. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36708. * @param projected sets as the (x,y,z) local projection on the facet
  36709. * @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
  36710. * @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
  36711. * @param x defines x coordinate
  36712. * @param y defines y coordinate
  36713. * @param z defines z coordinate
  36714. * @returns the face index if found (or null instead)
  36715. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36716. */
  36717. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36718. /**
  36719. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36720. * @returns the parameters
  36721. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36722. */
  36723. getFacetDataParameters(): any;
  36724. /**
  36725. * Disables the feature FacetData and frees the related memory
  36726. * @returns the current mesh
  36727. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36728. */
  36729. disableFacetData(): AbstractMesh;
  36730. /**
  36731. * Updates the AbstractMesh indices array
  36732. * @param indices defines the data source
  36733. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36734. * @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)
  36735. * @returns the current mesh
  36736. */
  36737. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36738. /**
  36739. * Creates new normals data for the mesh
  36740. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36741. * @returns the current mesh
  36742. */
  36743. createNormals(updatable: boolean): AbstractMesh;
  36744. /**
  36745. * Align the mesh with a normal
  36746. * @param normal defines the normal to use
  36747. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36748. * @returns the current mesh
  36749. */
  36750. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36751. /** @hidden */
  36752. _checkOcclusionQuery(): boolean;
  36753. /**
  36754. * Disables the mesh edge rendering mode
  36755. * @returns the currentAbstractMesh
  36756. */
  36757. disableEdgesRendering(): AbstractMesh;
  36758. /**
  36759. * Enables the edge rendering mode on the mesh.
  36760. * This mode makes the mesh edges visible
  36761. * @param epsilon defines the maximal distance between two angles to detect a face
  36762. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36763. * @param options options to the edge renderer
  36764. * @returns the currentAbstractMesh
  36765. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36766. */
  36767. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  36768. /**
  36769. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36770. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36771. */
  36772. getConnectedParticleSystems(): IParticleSystem[];
  36773. }
  36774. }
  36775. declare module BABYLON {
  36776. /**
  36777. * Interface used to define ActionEvent
  36778. */
  36779. export interface IActionEvent {
  36780. /** The mesh or sprite that triggered the action */
  36781. source: any;
  36782. /** The X mouse cursor position at the time of the event */
  36783. pointerX: number;
  36784. /** The Y mouse cursor position at the time of the event */
  36785. pointerY: number;
  36786. /** The mesh that is currently pointed at (can be null) */
  36787. meshUnderPointer: Nullable<AbstractMesh>;
  36788. /** the original (browser) event that triggered the ActionEvent */
  36789. sourceEvent?: any;
  36790. /** additional data for the event */
  36791. additionalData?: any;
  36792. }
  36793. /**
  36794. * ActionEvent is the event being sent when an action is triggered.
  36795. */
  36796. export class ActionEvent implements IActionEvent {
  36797. /** The mesh or sprite that triggered the action */
  36798. source: any;
  36799. /** The X mouse cursor position at the time of the event */
  36800. pointerX: number;
  36801. /** The Y mouse cursor position at the time of the event */
  36802. pointerY: number;
  36803. /** The mesh that is currently pointed at (can be null) */
  36804. meshUnderPointer: Nullable<AbstractMesh>;
  36805. /** the original (browser) event that triggered the ActionEvent */
  36806. sourceEvent?: any;
  36807. /** additional data for the event */
  36808. additionalData?: any;
  36809. /**
  36810. * Creates a new ActionEvent
  36811. * @param source The mesh or sprite that triggered the action
  36812. * @param pointerX The X mouse cursor position at the time of the event
  36813. * @param pointerY The Y mouse cursor position at the time of the event
  36814. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36815. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36816. * @param additionalData additional data for the event
  36817. */
  36818. constructor(
  36819. /** The mesh or sprite that triggered the action */
  36820. source: any,
  36821. /** The X mouse cursor position at the time of the event */
  36822. pointerX: number,
  36823. /** The Y mouse cursor position at the time of the event */
  36824. pointerY: number,
  36825. /** The mesh that is currently pointed at (can be null) */
  36826. meshUnderPointer: Nullable<AbstractMesh>,
  36827. /** the original (browser) event that triggered the ActionEvent */
  36828. sourceEvent?: any,
  36829. /** additional data for the event */
  36830. additionalData?: any);
  36831. /**
  36832. * Helper function to auto-create an ActionEvent from a source mesh.
  36833. * @param source The source mesh that triggered the event
  36834. * @param evt The original (browser) event
  36835. * @param additionalData additional data for the event
  36836. * @returns the new ActionEvent
  36837. */
  36838. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36839. /**
  36840. * Helper function to auto-create an ActionEvent from a source sprite
  36841. * @param source The source sprite that triggered the event
  36842. * @param scene Scene associated with the sprite
  36843. * @param evt The original (browser) event
  36844. * @param additionalData additional data for the event
  36845. * @returns the new ActionEvent
  36846. */
  36847. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36848. /**
  36849. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36850. * @param scene the scene where the event occurred
  36851. * @param evt The original (browser) event
  36852. * @returns the new ActionEvent
  36853. */
  36854. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36855. /**
  36856. * Helper function to auto-create an ActionEvent from a primitive
  36857. * @param prim defines the target primitive
  36858. * @param pointerPos defines the pointer position
  36859. * @param evt The original (browser) event
  36860. * @param additionalData additional data for the event
  36861. * @returns the new ActionEvent
  36862. */
  36863. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36864. }
  36865. }
  36866. declare module BABYLON {
  36867. /**
  36868. * Abstract class used to decouple action Manager from scene and meshes.
  36869. * Do not instantiate.
  36870. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36871. */
  36872. export abstract class AbstractActionManager implements IDisposable {
  36873. /** Gets the list of active triggers */
  36874. static Triggers: {
  36875. [key: string]: number;
  36876. };
  36877. /** Gets the cursor to use when hovering items */
  36878. hoverCursor: string;
  36879. /** Gets the list of actions */
  36880. actions: IAction[];
  36881. /**
  36882. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36883. */
  36884. isRecursive: boolean;
  36885. /**
  36886. * Releases all associated resources
  36887. */
  36888. abstract dispose(): void;
  36889. /**
  36890. * Does this action manager has pointer triggers
  36891. */
  36892. abstract get hasPointerTriggers(): boolean;
  36893. /**
  36894. * Does this action manager has pick triggers
  36895. */
  36896. abstract get hasPickTriggers(): boolean;
  36897. /**
  36898. * Process a specific trigger
  36899. * @param trigger defines the trigger to process
  36900. * @param evt defines the event details to be processed
  36901. */
  36902. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36903. /**
  36904. * Does this action manager handles actions of any of the given triggers
  36905. * @param triggers defines the triggers to be tested
  36906. * @return a boolean indicating whether one (or more) of the triggers is handled
  36907. */
  36908. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36909. /**
  36910. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36911. * speed.
  36912. * @param triggerA defines the trigger to be tested
  36913. * @param triggerB defines the trigger to be tested
  36914. * @return a boolean indicating whether one (or more) of the triggers is handled
  36915. */
  36916. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36917. /**
  36918. * Does this action manager handles actions of a given trigger
  36919. * @param trigger defines the trigger to be tested
  36920. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36921. * @return whether the trigger is handled
  36922. */
  36923. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36924. /**
  36925. * Serialize this manager to a JSON object
  36926. * @param name defines the property name to store this manager
  36927. * @returns a JSON representation of this manager
  36928. */
  36929. abstract serialize(name: string): any;
  36930. /**
  36931. * Registers an action to this action manager
  36932. * @param action defines the action to be registered
  36933. * @return the action amended (prepared) after registration
  36934. */
  36935. abstract registerAction(action: IAction): Nullable<IAction>;
  36936. /**
  36937. * Unregisters an action to this action manager
  36938. * @param action defines the action to be unregistered
  36939. * @return a boolean indicating whether the action has been unregistered
  36940. */
  36941. abstract unregisterAction(action: IAction): Boolean;
  36942. /**
  36943. * Does exist one action manager with at least one trigger
  36944. **/
  36945. static get HasTriggers(): boolean;
  36946. /**
  36947. * Does exist one action manager with at least one pick trigger
  36948. **/
  36949. static get HasPickTriggers(): boolean;
  36950. /**
  36951. * Does exist one action manager that handles actions of a given trigger
  36952. * @param trigger defines the trigger to be tested
  36953. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36954. **/
  36955. static HasSpecificTrigger(trigger: number): boolean;
  36956. }
  36957. }
  36958. declare module BABYLON {
  36959. /**
  36960. * Defines how a node can be built from a string name.
  36961. */
  36962. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36963. /**
  36964. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36965. */
  36966. export class Node implements IBehaviorAware<Node> {
  36967. /** @hidden */
  36968. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36969. private static _NodeConstructors;
  36970. /**
  36971. * Add a new node constructor
  36972. * @param type defines the type name of the node to construct
  36973. * @param constructorFunc defines the constructor function
  36974. */
  36975. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36976. /**
  36977. * Returns a node constructor based on type name
  36978. * @param type defines the type name
  36979. * @param name defines the new node name
  36980. * @param scene defines the hosting scene
  36981. * @param options defines optional options to transmit to constructors
  36982. * @returns the new constructor or null
  36983. */
  36984. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36985. /**
  36986. * Gets or sets the name of the node
  36987. */
  36988. name: string;
  36989. /**
  36990. * Gets or sets the id of the node
  36991. */
  36992. id: string;
  36993. /**
  36994. * Gets or sets the unique id of the node
  36995. */
  36996. uniqueId: number;
  36997. /**
  36998. * Gets or sets a string used to store user defined state for the node
  36999. */
  37000. state: string;
  37001. /**
  37002. * Gets or sets an object used to store user defined information for the node
  37003. */
  37004. metadata: any;
  37005. /**
  37006. * For internal use only. Please do not use.
  37007. */
  37008. reservedDataStore: any;
  37009. /**
  37010. * List of inspectable custom properties (used by the Inspector)
  37011. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37012. */
  37013. inspectableCustomProperties: IInspectable[];
  37014. private _doNotSerialize;
  37015. /**
  37016. * Gets or sets a boolean used to define if the node must be serialized
  37017. */
  37018. get doNotSerialize(): boolean;
  37019. set doNotSerialize(value: boolean);
  37020. /** @hidden */
  37021. _isDisposed: boolean;
  37022. /**
  37023. * Gets a list of Animations associated with the node
  37024. */
  37025. animations: Animation[];
  37026. protected _ranges: {
  37027. [name: string]: Nullable<AnimationRange>;
  37028. };
  37029. /**
  37030. * Callback raised when the node is ready to be used
  37031. */
  37032. onReady: Nullable<(node: Node) => void>;
  37033. private _isEnabled;
  37034. private _isParentEnabled;
  37035. private _isReady;
  37036. /** @hidden */
  37037. _currentRenderId: number;
  37038. private _parentUpdateId;
  37039. /** @hidden */
  37040. _childUpdateId: number;
  37041. /** @hidden */
  37042. _waitingParentId: Nullable<string>;
  37043. /** @hidden */
  37044. _scene: Scene;
  37045. /** @hidden */
  37046. _cache: any;
  37047. private _parentNode;
  37048. private _children;
  37049. /** @hidden */
  37050. _worldMatrix: Matrix;
  37051. /** @hidden */
  37052. _worldMatrixDeterminant: number;
  37053. /** @hidden */
  37054. _worldMatrixDeterminantIsDirty: boolean;
  37055. /** @hidden */
  37056. private _sceneRootNodesIndex;
  37057. /**
  37058. * Gets a boolean indicating if the node has been disposed
  37059. * @returns true if the node was disposed
  37060. */
  37061. isDisposed(): boolean;
  37062. /**
  37063. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37064. * @see https://doc.babylonjs.com/how_to/parenting
  37065. */
  37066. set parent(parent: Nullable<Node>);
  37067. get parent(): Nullable<Node>;
  37068. /** @hidden */
  37069. _addToSceneRootNodes(): void;
  37070. /** @hidden */
  37071. _removeFromSceneRootNodes(): void;
  37072. private _animationPropertiesOverride;
  37073. /**
  37074. * Gets or sets the animation properties override
  37075. */
  37076. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37077. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37078. /**
  37079. * Gets a string identifying the name of the class
  37080. * @returns "Node" string
  37081. */
  37082. getClassName(): string;
  37083. /** @hidden */
  37084. readonly _isNode: boolean;
  37085. /**
  37086. * An event triggered when the mesh is disposed
  37087. */
  37088. onDisposeObservable: Observable<Node>;
  37089. private _onDisposeObserver;
  37090. /**
  37091. * Sets a callback that will be raised when the node will be disposed
  37092. */
  37093. set onDispose(callback: () => void);
  37094. /**
  37095. * Creates a new Node
  37096. * @param name the name and id to be given to this node
  37097. * @param scene the scene this node will be added to
  37098. */
  37099. constructor(name: string, scene?: Nullable<Scene>);
  37100. /**
  37101. * Gets the scene of the node
  37102. * @returns a scene
  37103. */
  37104. getScene(): Scene;
  37105. /**
  37106. * Gets the engine of the node
  37107. * @returns a Engine
  37108. */
  37109. getEngine(): Engine;
  37110. private _behaviors;
  37111. /**
  37112. * Attach a behavior to the node
  37113. * @see https://doc.babylonjs.com/features/behaviour
  37114. * @param behavior defines the behavior to attach
  37115. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37116. * @returns the current Node
  37117. */
  37118. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37119. /**
  37120. * Remove an attached behavior
  37121. * @see https://doc.babylonjs.com/features/behaviour
  37122. * @param behavior defines the behavior to attach
  37123. * @returns the current Node
  37124. */
  37125. removeBehavior(behavior: Behavior<Node>): Node;
  37126. /**
  37127. * Gets the list of attached behaviors
  37128. * @see https://doc.babylonjs.com/features/behaviour
  37129. */
  37130. get behaviors(): Behavior<Node>[];
  37131. /**
  37132. * Gets an attached behavior by name
  37133. * @param name defines the name of the behavior to look for
  37134. * @see https://doc.babylonjs.com/features/behaviour
  37135. * @returns null if behavior was not found else the requested behavior
  37136. */
  37137. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37138. /**
  37139. * Returns the latest update of the World matrix
  37140. * @returns a Matrix
  37141. */
  37142. getWorldMatrix(): Matrix;
  37143. /** @hidden */
  37144. _getWorldMatrixDeterminant(): number;
  37145. /**
  37146. * Returns directly the latest state of the mesh World matrix.
  37147. * A Matrix is returned.
  37148. */
  37149. get worldMatrixFromCache(): Matrix;
  37150. /** @hidden */
  37151. _initCache(): void;
  37152. /** @hidden */
  37153. updateCache(force?: boolean): void;
  37154. /** @hidden */
  37155. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37156. /** @hidden */
  37157. _updateCache(ignoreParentClass?: boolean): void;
  37158. /** @hidden */
  37159. _isSynchronized(): boolean;
  37160. /** @hidden */
  37161. _markSyncedWithParent(): void;
  37162. /** @hidden */
  37163. isSynchronizedWithParent(): boolean;
  37164. /** @hidden */
  37165. isSynchronized(): boolean;
  37166. /**
  37167. * Is this node ready to be used/rendered
  37168. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37169. * @return true if the node is ready
  37170. */
  37171. isReady(completeCheck?: boolean): boolean;
  37172. /**
  37173. * Is this node enabled?
  37174. * 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
  37175. * @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
  37176. * @return whether this node (and its parent) is enabled
  37177. */
  37178. isEnabled(checkAncestors?: boolean): boolean;
  37179. /** @hidden */
  37180. protected _syncParentEnabledState(): void;
  37181. /**
  37182. * Set the enabled state of this node
  37183. * @param value defines the new enabled state
  37184. */
  37185. setEnabled(value: boolean): void;
  37186. /**
  37187. * Is this node a descendant of the given node?
  37188. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37189. * @param ancestor defines the parent node to inspect
  37190. * @returns a boolean indicating if this node is a descendant of the given node
  37191. */
  37192. isDescendantOf(ancestor: Node): boolean;
  37193. /** @hidden */
  37194. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37195. /**
  37196. * Will return all nodes that have this node as ascendant
  37197. * @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
  37198. * @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
  37199. * @return all children nodes of all types
  37200. */
  37201. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37202. /**
  37203. * Get all child-meshes of this node
  37204. * @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)
  37205. * @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
  37206. * @returns an array of AbstractMesh
  37207. */
  37208. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37209. /**
  37210. * Get all direct children of this node
  37211. * @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
  37212. * @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)
  37213. * @returns an array of Node
  37214. */
  37215. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37216. /** @hidden */
  37217. _setReady(state: boolean): void;
  37218. /**
  37219. * Get an animation by name
  37220. * @param name defines the name of the animation to look for
  37221. * @returns null if not found else the requested animation
  37222. */
  37223. getAnimationByName(name: string): Nullable<Animation>;
  37224. /**
  37225. * Creates an animation range for this node
  37226. * @param name defines the name of the range
  37227. * @param from defines the starting key
  37228. * @param to defines the end key
  37229. */
  37230. createAnimationRange(name: string, from: number, to: number): void;
  37231. /**
  37232. * Delete a specific animation range
  37233. * @param name defines the name of the range to delete
  37234. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37235. */
  37236. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37237. /**
  37238. * Get an animation range by name
  37239. * @param name defines the name of the animation range to look for
  37240. * @returns null if not found else the requested animation range
  37241. */
  37242. getAnimationRange(name: string): Nullable<AnimationRange>;
  37243. /**
  37244. * Gets the list of all animation ranges defined on this node
  37245. * @returns an array
  37246. */
  37247. getAnimationRanges(): Nullable<AnimationRange>[];
  37248. /**
  37249. * Will start the animation sequence
  37250. * @param name defines the range frames for animation sequence
  37251. * @param loop defines if the animation should loop (false by default)
  37252. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37253. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37254. * @returns the object created for this animation. If range does not exist, it will return null
  37255. */
  37256. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37257. /**
  37258. * Serialize animation ranges into a JSON compatible object
  37259. * @returns serialization object
  37260. */
  37261. serializeAnimationRanges(): any;
  37262. /**
  37263. * Computes the world matrix of the node
  37264. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37265. * @returns the world matrix
  37266. */
  37267. computeWorldMatrix(force?: boolean): Matrix;
  37268. /**
  37269. * Releases resources associated with this node.
  37270. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37271. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37272. */
  37273. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37274. /**
  37275. * Parse animation range data from a serialization object and store them into a given node
  37276. * @param node defines where to store the animation ranges
  37277. * @param parsedNode defines the serialization object to read data from
  37278. * @param scene defines the hosting scene
  37279. */
  37280. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37281. /**
  37282. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37283. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37284. * @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
  37285. * @returns the new bounding vectors
  37286. */
  37287. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37288. min: Vector3;
  37289. max: Vector3;
  37290. };
  37291. }
  37292. }
  37293. declare module BABYLON {
  37294. /**
  37295. * @hidden
  37296. */
  37297. export class _IAnimationState {
  37298. key: number;
  37299. repeatCount: number;
  37300. workValue?: any;
  37301. loopMode?: number;
  37302. offsetValue?: any;
  37303. highLimitValue?: any;
  37304. }
  37305. /**
  37306. * Class used to store any kind of animation
  37307. */
  37308. export class Animation {
  37309. /**Name of the animation */
  37310. name: string;
  37311. /**Property to animate */
  37312. targetProperty: string;
  37313. /**The frames per second of the animation */
  37314. framePerSecond: number;
  37315. /**The data type of the animation */
  37316. dataType: number;
  37317. /**The loop mode of the animation */
  37318. loopMode?: number | undefined;
  37319. /**Specifies if blending should be enabled */
  37320. enableBlending?: boolean | undefined;
  37321. /**
  37322. * Use matrix interpolation instead of using direct key value when animating matrices
  37323. */
  37324. static AllowMatricesInterpolation: boolean;
  37325. /**
  37326. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37327. */
  37328. static AllowMatrixDecomposeForInterpolation: boolean;
  37329. /** Define the Url to load snippets */
  37330. static SnippetUrl: string;
  37331. /** Snippet ID if the animation was created from the snippet server */
  37332. snippetId: string;
  37333. /**
  37334. * Stores the key frames of the animation
  37335. */
  37336. private _keys;
  37337. /**
  37338. * Stores the easing function of the animation
  37339. */
  37340. private _easingFunction;
  37341. /**
  37342. * @hidden Internal use only
  37343. */
  37344. _runtimeAnimations: RuntimeAnimation[];
  37345. /**
  37346. * The set of event that will be linked to this animation
  37347. */
  37348. private _events;
  37349. /**
  37350. * Stores an array of target property paths
  37351. */
  37352. targetPropertyPath: string[];
  37353. /**
  37354. * Stores the blending speed of the animation
  37355. */
  37356. blendingSpeed: number;
  37357. /**
  37358. * Stores the animation ranges for the animation
  37359. */
  37360. private _ranges;
  37361. /**
  37362. * @hidden Internal use
  37363. */
  37364. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37365. /**
  37366. * Sets up an animation
  37367. * @param property The property to animate
  37368. * @param animationType The animation type to apply
  37369. * @param framePerSecond The frames per second of the animation
  37370. * @param easingFunction The easing function used in the animation
  37371. * @returns The created animation
  37372. */
  37373. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37374. /**
  37375. * Create and start an animation on a node
  37376. * @param name defines the name of the global animation that will be run on all nodes
  37377. * @param node defines the root node where the animation will take place
  37378. * @param targetProperty defines property to animate
  37379. * @param framePerSecond defines the number of frame per second yo use
  37380. * @param totalFrame defines the number of frames in total
  37381. * @param from defines the initial value
  37382. * @param to defines the final value
  37383. * @param loopMode defines which loop mode you want to use (off by default)
  37384. * @param easingFunction defines the easing function to use (linear by default)
  37385. * @param onAnimationEnd defines the callback to call when animation end
  37386. * @returns the animatable created for this animation
  37387. */
  37388. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37389. /**
  37390. * Create and start an animation on a node and its descendants
  37391. * @param name defines the name of the global animation that will be run on all nodes
  37392. * @param node defines the root node where the animation will take place
  37393. * @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
  37394. * @param targetProperty defines property to animate
  37395. * @param framePerSecond defines the number of frame per second to use
  37396. * @param totalFrame defines the number of frames in total
  37397. * @param from defines the initial value
  37398. * @param to defines the final value
  37399. * @param loopMode defines which loop mode you want to use (off by default)
  37400. * @param easingFunction defines the easing function to use (linear by default)
  37401. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37402. * @returns the list of animatables created for all nodes
  37403. * @example https://www.babylonjs-playground.com/#MH0VLI
  37404. */
  37405. 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[]>;
  37406. /**
  37407. * Creates a new animation, merges it with the existing animations and starts it
  37408. * @param name Name of the animation
  37409. * @param node Node which contains the scene that begins the animations
  37410. * @param targetProperty Specifies which property to animate
  37411. * @param framePerSecond The frames per second of the animation
  37412. * @param totalFrame The total number of frames
  37413. * @param from The frame at the beginning of the animation
  37414. * @param to The frame at the end of the animation
  37415. * @param loopMode Specifies the loop mode of the animation
  37416. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37417. * @param onAnimationEnd Callback to run once the animation is complete
  37418. * @returns Nullable animation
  37419. */
  37420. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37421. /**
  37422. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37423. * @param sourceAnimation defines the Animation containing keyframes to convert
  37424. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37425. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37426. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37427. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37428. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37429. */
  37430. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37431. /**
  37432. * Transition property of an host to the target Value
  37433. * @param property The property to transition
  37434. * @param targetValue The target Value of the property
  37435. * @param host The object where the property to animate belongs
  37436. * @param scene Scene used to run the animation
  37437. * @param frameRate Framerate (in frame/s) to use
  37438. * @param transition The transition type we want to use
  37439. * @param duration The duration of the animation, in milliseconds
  37440. * @param onAnimationEnd Callback trigger at the end of the animation
  37441. * @returns Nullable animation
  37442. */
  37443. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37444. /**
  37445. * Return the array of runtime animations currently using this animation
  37446. */
  37447. get runtimeAnimations(): RuntimeAnimation[];
  37448. /**
  37449. * Specifies if any of the runtime animations are currently running
  37450. */
  37451. get hasRunningRuntimeAnimations(): boolean;
  37452. /**
  37453. * Initializes the animation
  37454. * @param name Name of the animation
  37455. * @param targetProperty Property to animate
  37456. * @param framePerSecond The frames per second of the animation
  37457. * @param dataType The data type of the animation
  37458. * @param loopMode The loop mode of the animation
  37459. * @param enableBlending Specifies if blending should be enabled
  37460. */
  37461. constructor(
  37462. /**Name of the animation */
  37463. name: string,
  37464. /**Property to animate */
  37465. targetProperty: string,
  37466. /**The frames per second of the animation */
  37467. framePerSecond: number,
  37468. /**The data type of the animation */
  37469. dataType: number,
  37470. /**The loop mode of the animation */
  37471. loopMode?: number | undefined,
  37472. /**Specifies if blending should be enabled */
  37473. enableBlending?: boolean | undefined);
  37474. /**
  37475. * Converts the animation to a string
  37476. * @param fullDetails support for multiple levels of logging within scene loading
  37477. * @returns String form of the animation
  37478. */
  37479. toString(fullDetails?: boolean): string;
  37480. /**
  37481. * Add an event to this animation
  37482. * @param event Event to add
  37483. */
  37484. addEvent(event: AnimationEvent): void;
  37485. /**
  37486. * Remove all events found at the given frame
  37487. * @param frame The frame to remove events from
  37488. */
  37489. removeEvents(frame: number): void;
  37490. /**
  37491. * Retrieves all the events from the animation
  37492. * @returns Events from the animation
  37493. */
  37494. getEvents(): AnimationEvent[];
  37495. /**
  37496. * Creates an animation range
  37497. * @param name Name of the animation range
  37498. * @param from Starting frame of the animation range
  37499. * @param to Ending frame of the animation
  37500. */
  37501. createRange(name: string, from: number, to: number): void;
  37502. /**
  37503. * Deletes an animation range by name
  37504. * @param name Name of the animation range to delete
  37505. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37506. */
  37507. deleteRange(name: string, deleteFrames?: boolean): void;
  37508. /**
  37509. * Gets the animation range by name, or null if not defined
  37510. * @param name Name of the animation range
  37511. * @returns Nullable animation range
  37512. */
  37513. getRange(name: string): Nullable<AnimationRange>;
  37514. /**
  37515. * Gets the key frames from the animation
  37516. * @returns The key frames of the animation
  37517. */
  37518. getKeys(): Array<IAnimationKey>;
  37519. /**
  37520. * Gets the highest frame rate of the animation
  37521. * @returns Highest frame rate of the animation
  37522. */
  37523. getHighestFrame(): number;
  37524. /**
  37525. * Gets the easing function of the animation
  37526. * @returns Easing function of the animation
  37527. */
  37528. getEasingFunction(): IEasingFunction;
  37529. /**
  37530. * Sets the easing function of the animation
  37531. * @param easingFunction A custom mathematical formula for animation
  37532. */
  37533. setEasingFunction(easingFunction: EasingFunction): void;
  37534. /**
  37535. * Interpolates a scalar linearly
  37536. * @param startValue Start value of the animation curve
  37537. * @param endValue End value of the animation curve
  37538. * @param gradient Scalar amount to interpolate
  37539. * @returns Interpolated scalar value
  37540. */
  37541. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37542. /**
  37543. * Interpolates a scalar cubically
  37544. * @param startValue Start value of the animation curve
  37545. * @param outTangent End tangent of the animation
  37546. * @param endValue End value of the animation curve
  37547. * @param inTangent Start tangent of the animation curve
  37548. * @param gradient Scalar amount to interpolate
  37549. * @returns Interpolated scalar value
  37550. */
  37551. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37552. /**
  37553. * Interpolates a quaternion using a spherical linear interpolation
  37554. * @param startValue Start value of the animation curve
  37555. * @param endValue End value of the animation curve
  37556. * @param gradient Scalar amount to interpolate
  37557. * @returns Interpolated quaternion value
  37558. */
  37559. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37560. /**
  37561. * Interpolates a quaternion cubically
  37562. * @param startValue Start value of the animation curve
  37563. * @param outTangent End tangent of the animation curve
  37564. * @param endValue End value of the animation curve
  37565. * @param inTangent Start tangent of the animation curve
  37566. * @param gradient Scalar amount to interpolate
  37567. * @returns Interpolated quaternion value
  37568. */
  37569. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37570. /**
  37571. * Interpolates a Vector3 linearl
  37572. * @param startValue Start value of the animation curve
  37573. * @param endValue End value of the animation curve
  37574. * @param gradient Scalar amount to interpolate
  37575. * @returns Interpolated scalar value
  37576. */
  37577. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37578. /**
  37579. * Interpolates a Vector3 cubically
  37580. * @param startValue Start value of the animation curve
  37581. * @param outTangent End tangent of the animation
  37582. * @param endValue End value of the animation curve
  37583. * @param inTangent Start tangent of the animation curve
  37584. * @param gradient Scalar amount to interpolate
  37585. * @returns InterpolatedVector3 value
  37586. */
  37587. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37588. /**
  37589. * Interpolates a Vector2 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 Vector2 value
  37594. */
  37595. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37596. /**
  37597. * Interpolates a Vector2 cubically
  37598. * @param startValue Start value of the animation curve
  37599. * @param outTangent End tangent of the animation
  37600. * @param endValue End value of the animation curve
  37601. * @param inTangent Start tangent of the animation curve
  37602. * @param gradient Scalar amount to interpolate
  37603. * @returns Interpolated Vector2 value
  37604. */
  37605. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37606. /**
  37607. * Interpolates a size linearly
  37608. * @param startValue Start value of the animation curve
  37609. * @param endValue End value of the animation curve
  37610. * @param gradient Scalar amount to interpolate
  37611. * @returns Interpolated Size value
  37612. */
  37613. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37614. /**
  37615. * Interpolates a Color3 linearly
  37616. * @param startValue Start value of the animation curve
  37617. * @param endValue End value of the animation curve
  37618. * @param gradient Scalar amount to interpolate
  37619. * @returns Interpolated Color3 value
  37620. */
  37621. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37622. /**
  37623. * Interpolates a Color4 linearly
  37624. * @param startValue Start value of the animation curve
  37625. * @param endValue End value of the animation curve
  37626. * @param gradient Scalar amount to interpolate
  37627. * @returns Interpolated Color3 value
  37628. */
  37629. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37630. /**
  37631. * @hidden Internal use only
  37632. */
  37633. _getKeyValue(value: any): any;
  37634. /**
  37635. * @hidden Internal use only
  37636. */
  37637. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37638. /**
  37639. * Defines the function to use to interpolate matrices
  37640. * @param startValue defines the start matrix
  37641. * @param endValue defines the end matrix
  37642. * @param gradient defines the gradient between both matrices
  37643. * @param result defines an optional target matrix where to store the interpolation
  37644. * @returns the interpolated matrix
  37645. */
  37646. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37647. /**
  37648. * Makes a copy of the animation
  37649. * @returns Cloned animation
  37650. */
  37651. clone(): Animation;
  37652. /**
  37653. * Sets the key frames of the animation
  37654. * @param values The animation key frames to set
  37655. */
  37656. setKeys(values: Array<IAnimationKey>): void;
  37657. /**
  37658. * Serializes the animation to an object
  37659. * @returns Serialized object
  37660. */
  37661. serialize(): any;
  37662. /**
  37663. * Float animation type
  37664. */
  37665. static readonly ANIMATIONTYPE_FLOAT: number;
  37666. /**
  37667. * Vector3 animation type
  37668. */
  37669. static readonly ANIMATIONTYPE_VECTOR3: number;
  37670. /**
  37671. * Quaternion animation type
  37672. */
  37673. static readonly ANIMATIONTYPE_QUATERNION: number;
  37674. /**
  37675. * Matrix animation type
  37676. */
  37677. static readonly ANIMATIONTYPE_MATRIX: number;
  37678. /**
  37679. * Color3 animation type
  37680. */
  37681. static readonly ANIMATIONTYPE_COLOR3: number;
  37682. /**
  37683. * Color3 animation type
  37684. */
  37685. static readonly ANIMATIONTYPE_COLOR4: number;
  37686. /**
  37687. * Vector2 animation type
  37688. */
  37689. static readonly ANIMATIONTYPE_VECTOR2: number;
  37690. /**
  37691. * Size animation type
  37692. */
  37693. static readonly ANIMATIONTYPE_SIZE: number;
  37694. /**
  37695. * Relative Loop Mode
  37696. */
  37697. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37698. /**
  37699. * Cycle Loop Mode
  37700. */
  37701. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37702. /**
  37703. * Constant Loop Mode
  37704. */
  37705. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37706. /** @hidden */
  37707. static _UniversalLerp(left: any, right: any, amount: number): any;
  37708. /**
  37709. * Parses an animation object and creates an animation
  37710. * @param parsedAnimation Parsed animation object
  37711. * @returns Animation object
  37712. */
  37713. static Parse(parsedAnimation: any): Animation;
  37714. /**
  37715. * Appends the serialized animations from the source animations
  37716. * @param source Source containing the animations
  37717. * @param destination Target to store the animations
  37718. */
  37719. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37720. /**
  37721. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37722. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37723. * @param url defines the url to load from
  37724. * @returns a promise that will resolve to the new animation or an array of animations
  37725. */
  37726. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37727. /**
  37728. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37729. * @param snippetId defines the snippet to load
  37730. * @returns a promise that will resolve to the new animation or a new array of animations
  37731. */
  37732. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37733. }
  37734. }
  37735. declare module BABYLON {
  37736. /**
  37737. * Interface containing an array of animations
  37738. */
  37739. export interface IAnimatable {
  37740. /**
  37741. * Array of animations
  37742. */
  37743. animations: Nullable<Array<Animation>>;
  37744. }
  37745. }
  37746. declare module BABYLON {
  37747. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37748. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37749. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37750. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37751. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37752. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37753. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37754. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37755. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37756. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37757. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37758. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37759. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37760. /**
  37761. * Decorator used to define property that can be serialized as reference to a camera
  37762. * @param sourceName defines the name of the property to decorate
  37763. */
  37764. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37765. /**
  37766. * Class used to help serialization objects
  37767. */
  37768. export class SerializationHelper {
  37769. /** @hidden */
  37770. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37771. /** @hidden */
  37772. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37773. /** @hidden */
  37774. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37775. /** @hidden */
  37776. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37777. /**
  37778. * Appends the serialized animations from the source animations
  37779. * @param source Source containing the animations
  37780. * @param destination Target to store the animations
  37781. */
  37782. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37783. /**
  37784. * Static function used to serialized a specific entity
  37785. * @param entity defines the entity to serialize
  37786. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37787. * @returns a JSON compatible object representing the serialization of the entity
  37788. */
  37789. static Serialize<T>(entity: T, serializationObject?: any): any;
  37790. /**
  37791. * Creates a new entity from a serialization data object
  37792. * @param creationFunction defines a function used to instanciated the new entity
  37793. * @param source defines the source serialization data
  37794. * @param scene defines the hosting scene
  37795. * @param rootUrl defines the root url for resources
  37796. * @returns a new entity
  37797. */
  37798. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37799. /**
  37800. * Clones an object
  37801. * @param creationFunction defines the function used to instanciate the new object
  37802. * @param source defines the source object
  37803. * @returns the cloned object
  37804. */
  37805. static Clone<T>(creationFunction: () => T, source: T): T;
  37806. /**
  37807. * Instanciates a new object based on a source one (some data will be shared between both object)
  37808. * @param creationFunction defines the function used to instanciate the new object
  37809. * @param source defines the source object
  37810. * @returns the new object
  37811. */
  37812. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37813. }
  37814. }
  37815. declare module BABYLON {
  37816. /**
  37817. * This is the base class of all the camera used in the application.
  37818. * @see https://doc.babylonjs.com/features/cameras
  37819. */
  37820. export class Camera extends Node {
  37821. /** @hidden */
  37822. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37823. /**
  37824. * This is the default projection mode used by the cameras.
  37825. * It helps recreating a feeling of perspective and better appreciate depth.
  37826. * This is the best way to simulate real life cameras.
  37827. */
  37828. static readonly PERSPECTIVE_CAMERA: number;
  37829. /**
  37830. * This helps creating camera with an orthographic mode.
  37831. * 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.
  37832. */
  37833. static readonly ORTHOGRAPHIC_CAMERA: number;
  37834. /**
  37835. * This is the default FOV mode for perspective cameras.
  37836. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37837. */
  37838. static readonly FOVMODE_VERTICAL_FIXED: number;
  37839. /**
  37840. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37841. */
  37842. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37843. /**
  37844. * This specifies ther is no need for a camera rig.
  37845. * Basically only one eye is rendered corresponding to the camera.
  37846. */
  37847. static readonly RIG_MODE_NONE: number;
  37848. /**
  37849. * Simulates a camera Rig with one blue eye and one red eye.
  37850. * This can be use with 3d blue and red glasses.
  37851. */
  37852. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37853. /**
  37854. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37855. */
  37856. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37857. /**
  37858. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37859. */
  37860. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37861. /**
  37862. * Defines that both eyes of the camera will be rendered over under each other.
  37863. */
  37864. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37865. /**
  37866. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37867. */
  37868. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37869. /**
  37870. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37871. */
  37872. static readonly RIG_MODE_VR: number;
  37873. /**
  37874. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37875. */
  37876. static readonly RIG_MODE_WEBVR: number;
  37877. /**
  37878. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37879. */
  37880. static readonly RIG_MODE_CUSTOM: number;
  37881. /**
  37882. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37883. */
  37884. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37885. /**
  37886. * Define the input manager associated with the camera.
  37887. */
  37888. inputs: CameraInputsManager<Camera>;
  37889. /** @hidden */
  37890. _position: Vector3;
  37891. /**
  37892. * Define the current local position of the camera in the scene
  37893. */
  37894. get position(): Vector3;
  37895. set position(newPosition: Vector3);
  37896. protected _upVector: Vector3;
  37897. /**
  37898. * The vector the camera should consider as up.
  37899. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37900. */
  37901. set upVector(vec: Vector3);
  37902. get upVector(): Vector3;
  37903. /**
  37904. * Define the current limit on the left side for an orthographic camera
  37905. * In scene unit
  37906. */
  37907. orthoLeft: Nullable<number>;
  37908. /**
  37909. * Define the current limit on the right side for an orthographic camera
  37910. * In scene unit
  37911. */
  37912. orthoRight: Nullable<number>;
  37913. /**
  37914. * Define the current limit on the bottom side for an orthographic camera
  37915. * In scene unit
  37916. */
  37917. orthoBottom: Nullable<number>;
  37918. /**
  37919. * Define the current limit on the top side for an orthographic camera
  37920. * In scene unit
  37921. */
  37922. orthoTop: Nullable<number>;
  37923. /**
  37924. * Field Of View is set in Radians. (default is 0.8)
  37925. */
  37926. fov: number;
  37927. /**
  37928. * Define the minimum distance the camera can see from.
  37929. * This is important to note that the depth buffer are not infinite and the closer it starts
  37930. * the more your scene might encounter depth fighting issue.
  37931. */
  37932. minZ: number;
  37933. /**
  37934. * Define the maximum distance the camera can see to.
  37935. * This is important to note that the depth buffer are not infinite and the further it end
  37936. * the more your scene might encounter depth fighting issue.
  37937. */
  37938. maxZ: number;
  37939. /**
  37940. * Define the default inertia of the camera.
  37941. * This helps giving a smooth feeling to the camera movement.
  37942. */
  37943. inertia: number;
  37944. /**
  37945. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37946. */
  37947. mode: number;
  37948. /**
  37949. * Define whether the camera is intermediate.
  37950. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37951. */
  37952. isIntermediate: boolean;
  37953. /**
  37954. * Define the viewport of the camera.
  37955. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37956. */
  37957. viewport: Viewport;
  37958. /**
  37959. * Restricts the camera to viewing objects with the same layerMask.
  37960. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37961. */
  37962. layerMask: number;
  37963. /**
  37964. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37965. */
  37966. fovMode: number;
  37967. /**
  37968. * Rig mode of the camera.
  37969. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37970. * This is normally controlled byt the camera themselves as internal use.
  37971. */
  37972. cameraRigMode: number;
  37973. /**
  37974. * Defines the distance between both "eyes" in case of a RIG
  37975. */
  37976. interaxialDistance: number;
  37977. /**
  37978. * Defines if stereoscopic rendering is done side by side or over under.
  37979. */
  37980. isStereoscopicSideBySide: boolean;
  37981. /**
  37982. * 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
  37983. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37984. * else in the scene. (Eg. security camera)
  37985. *
  37986. * 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)
  37987. */
  37988. customRenderTargets: RenderTargetTexture[];
  37989. /**
  37990. * When set, the camera will render to this render target instead of the default canvas
  37991. *
  37992. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37993. */
  37994. outputRenderTarget: Nullable<RenderTargetTexture>;
  37995. /**
  37996. * Observable triggered when the camera view matrix has changed.
  37997. */
  37998. onViewMatrixChangedObservable: Observable<Camera>;
  37999. /**
  38000. * Observable triggered when the camera Projection matrix has changed.
  38001. */
  38002. onProjectionMatrixChangedObservable: Observable<Camera>;
  38003. /**
  38004. * Observable triggered when the inputs have been processed.
  38005. */
  38006. onAfterCheckInputsObservable: Observable<Camera>;
  38007. /**
  38008. * Observable triggered when reset has been called and applied to the camera.
  38009. */
  38010. onRestoreStateObservable: Observable<Camera>;
  38011. /**
  38012. * Is this camera a part of a rig system?
  38013. */
  38014. isRigCamera: boolean;
  38015. /**
  38016. * If isRigCamera set to true this will be set with the parent camera.
  38017. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38018. */
  38019. rigParent?: Camera;
  38020. /** @hidden */
  38021. _cameraRigParams: any;
  38022. /** @hidden */
  38023. _rigCameras: Camera[];
  38024. /** @hidden */
  38025. _rigPostProcess: Nullable<PostProcess>;
  38026. protected _webvrViewMatrix: Matrix;
  38027. /** @hidden */
  38028. _skipRendering: boolean;
  38029. /** @hidden */
  38030. _projectionMatrix: Matrix;
  38031. /** @hidden */
  38032. _postProcesses: Nullable<PostProcess>[];
  38033. /** @hidden */
  38034. _activeMeshes: SmartArray<AbstractMesh>;
  38035. protected _globalPosition: Vector3;
  38036. /** @hidden */
  38037. _computedViewMatrix: Matrix;
  38038. private _doNotComputeProjectionMatrix;
  38039. private _transformMatrix;
  38040. private _frustumPlanes;
  38041. private _refreshFrustumPlanes;
  38042. private _storedFov;
  38043. private _stateStored;
  38044. /**
  38045. * Instantiates a new camera object.
  38046. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38047. * @see https://doc.babylonjs.com/features/cameras
  38048. * @param name Defines the name of the camera in the scene
  38049. * @param position Defines the position of the camera
  38050. * @param scene Defines the scene the camera belongs too
  38051. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38052. */
  38053. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38054. /**
  38055. * Store current camera state (fov, position, etc..)
  38056. * @returns the camera
  38057. */
  38058. storeState(): Camera;
  38059. /**
  38060. * Restores the camera state values if it has been stored. You must call storeState() first
  38061. */
  38062. protected _restoreStateValues(): boolean;
  38063. /**
  38064. * Restored camera state. You must call storeState() first.
  38065. * @returns true if restored and false otherwise
  38066. */
  38067. restoreState(): boolean;
  38068. /**
  38069. * Gets the class name of the camera.
  38070. * @returns the class name
  38071. */
  38072. getClassName(): string;
  38073. /** @hidden */
  38074. readonly _isCamera: boolean;
  38075. /**
  38076. * Gets a string representation of the camera useful for debug purpose.
  38077. * @param fullDetails Defines that a more verboe level of logging is required
  38078. * @returns the string representation
  38079. */
  38080. toString(fullDetails?: boolean): string;
  38081. /**
  38082. * Gets the current world space position of the camera.
  38083. */
  38084. get globalPosition(): Vector3;
  38085. /**
  38086. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38087. * @returns the active meshe list
  38088. */
  38089. getActiveMeshes(): SmartArray<AbstractMesh>;
  38090. /**
  38091. * Check whether a mesh is part of the current active mesh list of the camera
  38092. * @param mesh Defines the mesh to check
  38093. * @returns true if active, false otherwise
  38094. */
  38095. isActiveMesh(mesh: Mesh): boolean;
  38096. /**
  38097. * Is this camera ready to be used/rendered
  38098. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38099. * @return true if the camera is ready
  38100. */
  38101. isReady(completeCheck?: boolean): boolean;
  38102. /** @hidden */
  38103. _initCache(): void;
  38104. /** @hidden */
  38105. _updateCache(ignoreParentClass?: boolean): void;
  38106. /** @hidden */
  38107. _isSynchronized(): boolean;
  38108. /** @hidden */
  38109. _isSynchronizedViewMatrix(): boolean;
  38110. /** @hidden */
  38111. _isSynchronizedProjectionMatrix(): boolean;
  38112. /**
  38113. * Attach the input controls to a specific dom element to get the input from.
  38114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38115. */
  38116. attachControl(noPreventDefault?: boolean): void;
  38117. /**
  38118. * Attach the input controls to a specific dom element to get the input from.
  38119. * @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
  38120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38121. * BACK COMPAT SIGNATURE ONLY.
  38122. */
  38123. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38124. /**
  38125. * Detach the current controls from the specified dom element.
  38126. */
  38127. detachControl(): void;
  38128. /**
  38129. * Detach the current controls from the specified dom element.
  38130. * @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
  38131. */
  38132. detachControl(ignored: any): void;
  38133. /**
  38134. * Update the camera state according to the different inputs gathered during the frame.
  38135. */
  38136. update(): void;
  38137. /** @hidden */
  38138. _checkInputs(): void;
  38139. /** @hidden */
  38140. get rigCameras(): Camera[];
  38141. /**
  38142. * Gets the post process used by the rig cameras
  38143. */
  38144. get rigPostProcess(): Nullable<PostProcess>;
  38145. /**
  38146. * Internal, gets the first post proces.
  38147. * @returns the first post process to be run on this camera.
  38148. */
  38149. _getFirstPostProcess(): Nullable<PostProcess>;
  38150. private _cascadePostProcessesToRigCams;
  38151. /**
  38152. * Attach a post process to the camera.
  38153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38154. * @param postProcess The post process to attach to the camera
  38155. * @param insertAt The position of the post process in case several of them are in use in the scene
  38156. * @returns the position the post process has been inserted at
  38157. */
  38158. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38159. /**
  38160. * Detach a post process to the camera.
  38161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38162. * @param postProcess The post process to detach from the camera
  38163. */
  38164. detachPostProcess(postProcess: PostProcess): void;
  38165. /**
  38166. * Gets the current world matrix of the camera
  38167. */
  38168. getWorldMatrix(): Matrix;
  38169. /** @hidden */
  38170. _getViewMatrix(): Matrix;
  38171. /**
  38172. * Gets the current view matrix of the camera.
  38173. * @param force forces the camera to recompute the matrix without looking at the cached state
  38174. * @returns the view matrix
  38175. */
  38176. getViewMatrix(force?: boolean): Matrix;
  38177. /**
  38178. * Freeze the projection matrix.
  38179. * It will prevent the cache check of the camera projection compute and can speed up perf
  38180. * if no parameter of the camera are meant to change
  38181. * @param projection Defines manually a projection if necessary
  38182. */
  38183. freezeProjectionMatrix(projection?: Matrix): void;
  38184. /**
  38185. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38186. */
  38187. unfreezeProjectionMatrix(): void;
  38188. /**
  38189. * Gets the current projection matrix of the camera.
  38190. * @param force forces the camera to recompute the matrix without looking at the cached state
  38191. * @returns the projection matrix
  38192. */
  38193. getProjectionMatrix(force?: boolean): Matrix;
  38194. /**
  38195. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38196. * @returns a Matrix
  38197. */
  38198. getTransformationMatrix(): Matrix;
  38199. private _updateFrustumPlanes;
  38200. /**
  38201. * Checks if a cullable object (mesh...) is in the camera frustum
  38202. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38203. * @param target The object to check
  38204. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38205. * @returns true if the object is in frustum otherwise false
  38206. */
  38207. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38208. /**
  38209. * Checks if a cullable object (mesh...) is in the camera frustum
  38210. * Unlike isInFrustum this cheks the full bounding box
  38211. * @param target The object to check
  38212. * @returns true if the object is in frustum otherwise false
  38213. */
  38214. isCompletelyInFrustum(target: ICullable): boolean;
  38215. /**
  38216. * Gets a ray in the forward direction from the camera.
  38217. * @param length Defines the length of the ray to create
  38218. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38219. * @param origin Defines the start point of the ray which defaults to the camera position
  38220. * @returns the forward ray
  38221. */
  38222. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38223. /**
  38224. * Gets a ray in the forward direction from the camera.
  38225. * @param refRay the ray to (re)use when setting the values
  38226. * @param length Defines the length of the ray to create
  38227. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38228. * @param origin Defines the start point of the ray which defaults to the camera position
  38229. * @returns the forward ray
  38230. */
  38231. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38232. /**
  38233. * Releases resources associated with this node.
  38234. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38235. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38236. */
  38237. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38238. /** @hidden */
  38239. _isLeftCamera: boolean;
  38240. /**
  38241. * Gets the left camera of a rig setup in case of Rigged Camera
  38242. */
  38243. get isLeftCamera(): boolean;
  38244. /** @hidden */
  38245. _isRightCamera: boolean;
  38246. /**
  38247. * Gets the right camera of a rig setup in case of Rigged Camera
  38248. */
  38249. get isRightCamera(): boolean;
  38250. /**
  38251. * Gets the left camera of a rig setup in case of Rigged Camera
  38252. */
  38253. get leftCamera(): Nullable<FreeCamera>;
  38254. /**
  38255. * Gets the right camera of a rig setup in case of Rigged Camera
  38256. */
  38257. get rightCamera(): Nullable<FreeCamera>;
  38258. /**
  38259. * Gets the left camera target of a rig setup in case of Rigged Camera
  38260. * @returns the target position
  38261. */
  38262. getLeftTarget(): Nullable<Vector3>;
  38263. /**
  38264. * Gets the right camera target of a rig setup in case of Rigged Camera
  38265. * @returns the target position
  38266. */
  38267. getRightTarget(): Nullable<Vector3>;
  38268. /**
  38269. * @hidden
  38270. */
  38271. setCameraRigMode(mode: number, rigParams: any): void;
  38272. /** @hidden */
  38273. static _setStereoscopicRigMode(camera: Camera): void;
  38274. /** @hidden */
  38275. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38276. /** @hidden */
  38277. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38278. /** @hidden */
  38279. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38280. /** @hidden */
  38281. _getVRProjectionMatrix(): Matrix;
  38282. protected _updateCameraRotationMatrix(): void;
  38283. protected _updateWebVRCameraRotationMatrix(): void;
  38284. /**
  38285. * This function MUST be overwritten by the different WebVR cameras available.
  38286. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38287. * @hidden
  38288. */
  38289. _getWebVRProjectionMatrix(): Matrix;
  38290. /**
  38291. * This function MUST be overwritten by the different WebVR cameras available.
  38292. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38293. * @hidden
  38294. */
  38295. _getWebVRViewMatrix(): Matrix;
  38296. /** @hidden */
  38297. setCameraRigParameter(name: string, value: any): void;
  38298. /**
  38299. * needs to be overridden by children so sub has required properties to be copied
  38300. * @hidden
  38301. */
  38302. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38303. /**
  38304. * May need to be overridden by children
  38305. * @hidden
  38306. */
  38307. _updateRigCameras(): void;
  38308. /** @hidden */
  38309. _setupInputs(): void;
  38310. /**
  38311. * Serialiaze the camera setup to a json represention
  38312. * @returns the JSON representation
  38313. */
  38314. serialize(): any;
  38315. /**
  38316. * Clones the current camera.
  38317. * @param name The cloned camera name
  38318. * @returns the cloned camera
  38319. */
  38320. clone(name: string): Camera;
  38321. /**
  38322. * Gets the direction of the camera relative to a given local axis.
  38323. * @param localAxis Defines the reference axis to provide a relative direction.
  38324. * @return the direction
  38325. */
  38326. getDirection(localAxis: Vector3): Vector3;
  38327. /**
  38328. * Returns the current camera absolute rotation
  38329. */
  38330. get absoluteRotation(): Quaternion;
  38331. /**
  38332. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38333. * @param localAxis Defines the reference axis to provide a relative direction.
  38334. * @param result Defines the vector to store the result in
  38335. */
  38336. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38337. /**
  38338. * Gets a camera constructor for a given camera type
  38339. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38340. * @param name The name of the camera the result will be able to instantiate
  38341. * @param scene The scene the result will construct the camera in
  38342. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38343. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38344. * @returns a factory method to construc the camera
  38345. */
  38346. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38347. /**
  38348. * Compute the world matrix of the camera.
  38349. * @returns the camera world matrix
  38350. */
  38351. computeWorldMatrix(): Matrix;
  38352. /**
  38353. * Parse a JSON and creates the camera from the parsed information
  38354. * @param parsedCamera The JSON to parse
  38355. * @param scene The scene to instantiate the camera in
  38356. * @returns the newly constructed camera
  38357. */
  38358. static Parse(parsedCamera: any, scene: Scene): Camera;
  38359. }
  38360. }
  38361. declare module BABYLON {
  38362. /**
  38363. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38364. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38365. */
  38366. export class PostProcessManager {
  38367. private _scene;
  38368. private _indexBuffer;
  38369. private _vertexBuffers;
  38370. /**
  38371. * Creates a new instance PostProcess
  38372. * @param scene The scene that the post process is associated with.
  38373. */
  38374. constructor(scene: Scene);
  38375. private _prepareBuffers;
  38376. private _buildIndexBuffer;
  38377. /**
  38378. * Rebuilds the vertex buffers of the manager.
  38379. * @hidden
  38380. */
  38381. _rebuild(): void;
  38382. /**
  38383. * Prepares a frame to be run through a post process.
  38384. * @param sourceTexture The input texture to the post procesess. (default: null)
  38385. * @param postProcesses An array of post processes to be run. (default: null)
  38386. * @returns True if the post processes were able to be run.
  38387. * @hidden
  38388. */
  38389. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38390. /**
  38391. * Manually render a set of post processes to a texture.
  38392. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38393. * @param postProcesses An array of post processes to be run.
  38394. * @param targetTexture The target texture to render to.
  38395. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38396. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38397. * @param lodLevel defines which lod of the texture to render to
  38398. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38399. */
  38400. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38401. /**
  38402. * Finalize the result of the output of the postprocesses.
  38403. * @param doNotPresent If true the result will not be displayed to the screen.
  38404. * @param targetTexture The target texture to render to.
  38405. * @param faceIndex The index of the face to bind the target texture to.
  38406. * @param postProcesses The array of post processes to render.
  38407. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38408. * @hidden
  38409. */
  38410. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38411. /**
  38412. * Disposes of the post process manager.
  38413. */
  38414. dispose(): void;
  38415. }
  38416. }
  38417. declare module BABYLON {
  38418. /**
  38419. * This Helps creating a texture that will be created from a camera in your scene.
  38420. * It is basically a dynamic texture that could be used to create special effects for instance.
  38421. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38422. */
  38423. export class RenderTargetTexture extends Texture {
  38424. /**
  38425. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38426. */
  38427. static readonly REFRESHRATE_RENDER_ONCE: number;
  38428. /**
  38429. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  38430. */
  38431. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38432. /**
  38433. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38434. * the central point of your effect and can save a lot of performances.
  38435. */
  38436. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38437. /**
  38438. * Use this predicate to dynamically define the list of mesh you want to render.
  38439. * If set, the renderList property will be overwritten.
  38440. */
  38441. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38442. private _renderList;
  38443. /**
  38444. * Use this list to define the list of mesh you want to render.
  38445. */
  38446. get renderList(): Nullable<Array<AbstractMesh>>;
  38447. set renderList(value: Nullable<Array<AbstractMesh>>);
  38448. /**
  38449. * Use this function to overload the renderList array at rendering time.
  38450. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  38451. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38452. * the cube (if the RTT is a cube, else layerOrFace=0).
  38453. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38454. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38455. * hold dummy elements!
  38456. */
  38457. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38458. private _hookArray;
  38459. /**
  38460. * Define if particles should be rendered in your texture.
  38461. */
  38462. renderParticles: boolean;
  38463. /**
  38464. * Define if sprites should be rendered in your texture.
  38465. */
  38466. renderSprites: boolean;
  38467. /**
  38468. * Define the camera used to render the texture.
  38469. */
  38470. activeCamera: Nullable<Camera>;
  38471. /**
  38472. * Override the mesh isReady function with your own one.
  38473. */
  38474. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38475. /**
  38476. * Override the render function of the texture with your own one.
  38477. */
  38478. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38479. /**
  38480. * Define if camera post processes should be use while rendering the texture.
  38481. */
  38482. useCameraPostProcesses: boolean;
  38483. /**
  38484. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38485. */
  38486. ignoreCameraViewport: boolean;
  38487. private _postProcessManager;
  38488. private _postProcesses;
  38489. private _resizeObserver;
  38490. /**
  38491. * An event triggered when the texture is unbind.
  38492. */
  38493. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38494. /**
  38495. * An event triggered when the texture is unbind.
  38496. */
  38497. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38498. private _onAfterUnbindObserver;
  38499. /**
  38500. * Set a after unbind callback in the texture.
  38501. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38502. */
  38503. set onAfterUnbind(callback: () => void);
  38504. /**
  38505. * An event triggered before rendering the texture
  38506. */
  38507. onBeforeRenderObservable: Observable<number>;
  38508. private _onBeforeRenderObserver;
  38509. /**
  38510. * Set a before render callback in the texture.
  38511. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38512. */
  38513. set onBeforeRender(callback: (faceIndex: number) => void);
  38514. /**
  38515. * An event triggered after rendering the texture
  38516. */
  38517. onAfterRenderObservable: Observable<number>;
  38518. private _onAfterRenderObserver;
  38519. /**
  38520. * Set a after render callback in the texture.
  38521. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38522. */
  38523. set onAfterRender(callback: (faceIndex: number) => void);
  38524. /**
  38525. * An event triggered after the texture clear
  38526. */
  38527. onClearObservable: Observable<Engine>;
  38528. private _onClearObserver;
  38529. /**
  38530. * Set a clear callback in the texture.
  38531. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38532. */
  38533. set onClear(callback: (Engine: Engine) => void);
  38534. /**
  38535. * An event triggered when the texture is resized.
  38536. */
  38537. onResizeObservable: Observable<RenderTargetTexture>;
  38538. /**
  38539. * Define the clear color of the Render Target if it should be different from the scene.
  38540. */
  38541. clearColor: Color4;
  38542. protected _size: number | {
  38543. width: number;
  38544. height: number;
  38545. layers?: number;
  38546. };
  38547. protected _initialSizeParameter: number | {
  38548. width: number;
  38549. height: number;
  38550. } | {
  38551. ratio: number;
  38552. };
  38553. protected _sizeRatio: Nullable<number>;
  38554. /** @hidden */
  38555. _generateMipMaps: boolean;
  38556. protected _renderingManager: RenderingManager;
  38557. /** @hidden */
  38558. _waitingRenderList?: string[];
  38559. protected _doNotChangeAspectRatio: boolean;
  38560. protected _currentRefreshId: number;
  38561. protected _refreshRate: number;
  38562. protected _textureMatrix: Matrix;
  38563. protected _samples: number;
  38564. protected _renderTargetOptions: RenderTargetCreationOptions;
  38565. /**
  38566. * Gets render target creation options that were used.
  38567. */
  38568. get renderTargetOptions(): RenderTargetCreationOptions;
  38569. protected _onRatioRescale(): void;
  38570. /**
  38571. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38572. * It must define where the camera used to render the texture is set
  38573. */
  38574. boundingBoxPosition: Vector3;
  38575. private _boundingBoxSize;
  38576. /**
  38577. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38578. * When defined, the cubemap will switch to local mode
  38579. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38580. * @example https://www.babylonjs-playground.com/#RNASML
  38581. */
  38582. set boundingBoxSize(value: Vector3);
  38583. get boundingBoxSize(): Vector3;
  38584. /**
  38585. * In case the RTT has been created with a depth texture, get the associated
  38586. * depth texture.
  38587. * Otherwise, return null.
  38588. */
  38589. get depthStencilTexture(): Nullable<InternalTexture>;
  38590. /**
  38591. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  38592. * or used a shadow, depth texture...
  38593. * @param name The friendly name of the texture
  38594. * @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)
  38595. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38596. * @param generateMipMaps True if mip maps need to be generated after render.
  38597. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38598. * @param type The type of the buffer in the RTT (int, half float, float...)
  38599. * @param isCube True if a cube texture needs to be created
  38600. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38601. * @param generateDepthBuffer True to generate a depth buffer
  38602. * @param generateStencilBuffer True to generate a stencil buffer
  38603. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38604. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38605. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38606. * @param samples sample count to use when creating the RTT
  38607. */
  38608. constructor(name: string, size: number | {
  38609. width: number;
  38610. height: number;
  38611. layers?: number;
  38612. } | {
  38613. ratio: number;
  38614. }, 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);
  38615. /**
  38616. * Creates a depth stencil texture.
  38617. * This is only available in WebGL 2 or with the depth texture extension available.
  38618. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38619. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38620. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38621. * @param samples sample count of the depth/stencil texture
  38622. */
  38623. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38624. private _processSizeParameter;
  38625. /**
  38626. * Define the number of samples to use in case of MSAA.
  38627. * It defaults to one meaning no MSAA has been enabled.
  38628. */
  38629. get samples(): number;
  38630. set samples(value: number);
  38631. /**
  38632. * Resets the refresh counter of the texture and start bak from scratch.
  38633. * Could be useful to regenerate the texture if it is setup to render only once.
  38634. */
  38635. resetRefreshCounter(): void;
  38636. /**
  38637. * Define the refresh rate of the texture or the rendering frequency.
  38638. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38639. */
  38640. get refreshRate(): number;
  38641. set refreshRate(value: number);
  38642. /**
  38643. * Adds a post process to the render target rendering passes.
  38644. * @param postProcess define the post process to add
  38645. */
  38646. addPostProcess(postProcess: PostProcess): void;
  38647. /**
  38648. * Clear all the post processes attached to the render target
  38649. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  38650. */
  38651. clearPostProcesses(dispose?: boolean): void;
  38652. /**
  38653. * Remove one of the post process from the list of attached post processes to the texture
  38654. * @param postProcess define the post process to remove from the list
  38655. */
  38656. removePostProcess(postProcess: PostProcess): void;
  38657. /** @hidden */
  38658. _shouldRender(): boolean;
  38659. /**
  38660. * Gets the actual render size of the texture.
  38661. * @returns the width of the render size
  38662. */
  38663. getRenderSize(): number;
  38664. /**
  38665. * Gets the actual render width of the texture.
  38666. * @returns the width of the render size
  38667. */
  38668. getRenderWidth(): number;
  38669. /**
  38670. * Gets the actual render height of the texture.
  38671. * @returns the height of the render size
  38672. */
  38673. getRenderHeight(): number;
  38674. /**
  38675. * Gets the actual number of layers of the texture.
  38676. * @returns the number of layers
  38677. */
  38678. getRenderLayers(): number;
  38679. /**
  38680. * Get if the texture can be rescaled or not.
  38681. */
  38682. get canRescale(): boolean;
  38683. /**
  38684. * Resize the texture using a ratio.
  38685. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38686. */
  38687. scale(ratio: number): void;
  38688. /**
  38689. * Get the texture reflection matrix used to rotate/transform the reflection.
  38690. * @returns the reflection matrix
  38691. */
  38692. getReflectionTextureMatrix(): Matrix;
  38693. /**
  38694. * Resize the texture to a new desired size.
  38695. * Be carrefull as it will recreate all the data in the new texture.
  38696. * @param size Define the new size. It can be:
  38697. * - a number for squared texture,
  38698. * - an object containing { width: number, height: number }
  38699. * - or an object containing a ratio { ratio: number }
  38700. */
  38701. resize(size: number | {
  38702. width: number;
  38703. height: number;
  38704. } | {
  38705. ratio: number;
  38706. }): void;
  38707. private _defaultRenderListPrepared;
  38708. /**
  38709. * Renders all the objects from the render list into the texture.
  38710. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38711. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38712. */
  38713. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38714. private _bestReflectionRenderTargetDimension;
  38715. private _prepareRenderingManager;
  38716. /**
  38717. * @hidden
  38718. * @param faceIndex face index to bind to if this is a cubetexture
  38719. * @param layer defines the index of the texture to bind in the array
  38720. */
  38721. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38722. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38723. private renderToTarget;
  38724. /**
  38725. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38726. * This allowed control for front to back rendering or reversly depending of the special needs.
  38727. *
  38728. * @param renderingGroupId The rendering group id corresponding to its index
  38729. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38730. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38731. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38732. */
  38733. 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;
  38734. /**
  38735. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38736. *
  38737. * @param renderingGroupId The rendering group id corresponding to its index
  38738. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38739. */
  38740. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38741. /**
  38742. * Clones the texture.
  38743. * @returns the cloned texture
  38744. */
  38745. clone(): RenderTargetTexture;
  38746. /**
  38747. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  38748. * @returns The JSON representation of the texture
  38749. */
  38750. serialize(): any;
  38751. /**
  38752. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  38753. */
  38754. disposeFramebufferObjects(): void;
  38755. /**
  38756. * Dispose the texture and release its associated resources.
  38757. */
  38758. dispose(): void;
  38759. /** @hidden */
  38760. _rebuild(): void;
  38761. /**
  38762. * Clear the info related to rendering groups preventing retention point in material dispose.
  38763. */
  38764. freeRenderingGroups(): void;
  38765. /**
  38766. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  38767. * @returns the view count
  38768. */
  38769. getViewCount(): number;
  38770. }
  38771. }
  38772. declare module BABYLON {
  38773. /**
  38774. * Options to be used when creating an effect.
  38775. */
  38776. export interface IEffectCreationOptions {
  38777. /**
  38778. * Atrributes that will be used in the shader.
  38779. */
  38780. attributes: string[];
  38781. /**
  38782. * Uniform varible names that will be set in the shader.
  38783. */
  38784. uniformsNames: string[];
  38785. /**
  38786. * Uniform buffer variable names that will be set in the shader.
  38787. */
  38788. uniformBuffersNames: string[];
  38789. /**
  38790. * Sampler texture variable names that will be set in the shader.
  38791. */
  38792. samplers: string[];
  38793. /**
  38794. * Define statements that will be set in the shader.
  38795. */
  38796. defines: any;
  38797. /**
  38798. * Possible fallbacks for this effect to improve performance when needed.
  38799. */
  38800. fallbacks: Nullable<IEffectFallbacks>;
  38801. /**
  38802. * Callback that will be called when the shader is compiled.
  38803. */
  38804. onCompiled: Nullable<(effect: Effect) => void>;
  38805. /**
  38806. * Callback that will be called if an error occurs during shader compilation.
  38807. */
  38808. onError: Nullable<(effect: Effect, errors: string) => void>;
  38809. /**
  38810. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38811. */
  38812. indexParameters?: any;
  38813. /**
  38814. * Max number of lights that can be used in the shader.
  38815. */
  38816. maxSimultaneousLights?: number;
  38817. /**
  38818. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38819. */
  38820. transformFeedbackVaryings?: Nullable<string[]>;
  38821. /**
  38822. * 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
  38823. */
  38824. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38825. /**
  38826. * Is this effect rendering to several color attachments ?
  38827. */
  38828. multiTarget?: boolean;
  38829. }
  38830. /**
  38831. * Effect containing vertex and fragment shader that can be executed on an object.
  38832. */
  38833. export class Effect implements IDisposable {
  38834. /**
  38835. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38836. */
  38837. static ShadersRepository: string;
  38838. /**
  38839. * Enable logging of the shader code when a compilation error occurs
  38840. */
  38841. static LogShaderCodeOnCompilationError: boolean;
  38842. /**
  38843. * Name of the effect.
  38844. */
  38845. name: any;
  38846. /**
  38847. * String container all the define statements that should be set on the shader.
  38848. */
  38849. defines: string;
  38850. /**
  38851. * Callback that will be called when the shader is compiled.
  38852. */
  38853. onCompiled: Nullable<(effect: Effect) => void>;
  38854. /**
  38855. * Callback that will be called if an error occurs during shader compilation.
  38856. */
  38857. onError: Nullable<(effect: Effect, errors: string) => void>;
  38858. /**
  38859. * Callback that will be called when effect is bound.
  38860. */
  38861. onBind: Nullable<(effect: Effect) => void>;
  38862. /**
  38863. * Unique ID of the effect.
  38864. */
  38865. uniqueId: number;
  38866. /**
  38867. * Observable that will be called when the shader is compiled.
  38868. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38869. */
  38870. onCompileObservable: Observable<Effect>;
  38871. /**
  38872. * Observable that will be called if an error occurs during shader compilation.
  38873. */
  38874. onErrorObservable: Observable<Effect>;
  38875. /** @hidden */
  38876. _onBindObservable: Nullable<Observable<Effect>>;
  38877. /**
  38878. * @hidden
  38879. * Specifies if the effect was previously ready
  38880. */
  38881. _wasPreviouslyReady: boolean;
  38882. /**
  38883. * Observable that will be called when effect is bound.
  38884. */
  38885. get onBindObservable(): Observable<Effect>;
  38886. /** @hidden */
  38887. _bonesComputationForcedToCPU: boolean;
  38888. /** @hidden */
  38889. _uniformBuffersNames: {
  38890. [key: string]: number;
  38891. };
  38892. /** @hidden */
  38893. _samplerList: string[];
  38894. /** @hidden */
  38895. _multiTarget: boolean;
  38896. private static _uniqueIdSeed;
  38897. private _engine;
  38898. private _uniformBuffersNamesList;
  38899. private _uniformsNames;
  38900. private _samplers;
  38901. private _isReady;
  38902. private _compilationError;
  38903. private _allFallbacksProcessed;
  38904. private _attributesNames;
  38905. private _attributes;
  38906. private _attributeLocationByName;
  38907. private _uniforms;
  38908. /**
  38909. * Key for the effect.
  38910. * @hidden
  38911. */
  38912. _key: string;
  38913. private _indexParameters;
  38914. private _fallbacks;
  38915. private _vertexSourceCodeOverride;
  38916. private _fragmentSourceCodeOverride;
  38917. private _transformFeedbackVaryings;
  38918. /**
  38919. * Compiled shader to webGL program.
  38920. * @hidden
  38921. */
  38922. _pipelineContext: Nullable<IPipelineContext>;
  38923. /** @hidden */
  38924. _vertexSourceCode: string;
  38925. /** @hidden */
  38926. _fragmentSourceCode: string;
  38927. /** @hidden */
  38928. private _rawVertexSourceCode;
  38929. /** @hidden */
  38930. private _rawFragmentSourceCode;
  38931. private static _baseCache;
  38932. private _processingContext;
  38933. /**
  38934. * Instantiates an effect.
  38935. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38936. * @param baseName Name of the effect.
  38937. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38938. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38939. * @param samplers List of sampler variables that will be passed to the shader.
  38940. * @param engine Engine to be used to render the effect
  38941. * @param defines Define statements to be added to the shader.
  38942. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38943. * @param onCompiled Callback that will be called when the shader is compiled.
  38944. * @param onError Callback that will be called if an error occurs during shader compilation.
  38945. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38946. * @param key Effect Key identifying uniquely compiled shader variants
  38947. */
  38948. 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);
  38949. private _useFinalCode;
  38950. /**
  38951. * Unique key for this effect
  38952. */
  38953. get key(): string;
  38954. /**
  38955. * If the effect has been compiled and prepared.
  38956. * @returns if the effect is compiled and prepared.
  38957. */
  38958. isReady(): boolean;
  38959. private _isReadyInternal;
  38960. /**
  38961. * The engine the effect was initialized with.
  38962. * @returns the engine.
  38963. */
  38964. getEngine(): Engine;
  38965. /**
  38966. * The pipeline context for this effect
  38967. * @returns the associated pipeline context
  38968. */
  38969. getPipelineContext(): Nullable<IPipelineContext>;
  38970. /**
  38971. * The set of names of attribute variables for the shader.
  38972. * @returns An array of attribute names.
  38973. */
  38974. getAttributesNames(): string[];
  38975. /**
  38976. * Returns the attribute at the given index.
  38977. * @param index The index of the attribute.
  38978. * @returns The location of the attribute.
  38979. */
  38980. getAttributeLocation(index: number): number;
  38981. /**
  38982. * Returns the attribute based on the name of the variable.
  38983. * @param name of the attribute to look up.
  38984. * @returns the attribute location.
  38985. */
  38986. getAttributeLocationByName(name: string): number;
  38987. /**
  38988. * The number of attributes.
  38989. * @returns the numnber of attributes.
  38990. */
  38991. getAttributesCount(): number;
  38992. /**
  38993. * Gets the index of a uniform variable.
  38994. * @param uniformName of the uniform to look up.
  38995. * @returns the index.
  38996. */
  38997. getUniformIndex(uniformName: string): number;
  38998. /**
  38999. * Returns the attribute based on the name of the variable.
  39000. * @param uniformName of the uniform to look up.
  39001. * @returns the location of the uniform.
  39002. */
  39003. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39004. /**
  39005. * Returns an array of sampler variable names
  39006. * @returns The array of sampler variable names.
  39007. */
  39008. getSamplers(): string[];
  39009. /**
  39010. * Returns an array of uniform variable names
  39011. * @returns The array of uniform variable names.
  39012. */
  39013. getUniformNames(): string[];
  39014. /**
  39015. * Returns an array of uniform buffer variable names
  39016. * @returns The array of uniform buffer variable names.
  39017. */
  39018. getUniformBuffersNames(): string[];
  39019. /**
  39020. * Returns the index parameters used to create the effect
  39021. * @returns The index parameters object
  39022. */
  39023. getIndexParameters(): any;
  39024. /**
  39025. * The error from the last compilation.
  39026. * @returns the error string.
  39027. */
  39028. getCompilationError(): string;
  39029. /**
  39030. * Gets a boolean indicating that all fallbacks were used during compilation
  39031. * @returns true if all fallbacks were used
  39032. */
  39033. allFallbacksProcessed(): boolean;
  39034. /**
  39035. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39036. * @param func The callback to be used.
  39037. */
  39038. executeWhenCompiled(func: (effect: Effect) => void): void;
  39039. private _checkIsReady;
  39040. private _loadShader;
  39041. /**
  39042. * Gets the vertex shader source code of this effect
  39043. */
  39044. get vertexSourceCode(): string;
  39045. /**
  39046. * Gets the fragment shader source code of this effect
  39047. */
  39048. get fragmentSourceCode(): string;
  39049. /**
  39050. * Gets the vertex shader source code before it has been processed by the preprocessor
  39051. */
  39052. get rawVertexSourceCode(): string;
  39053. /**
  39054. * Gets the fragment shader source code before it has been processed by the preprocessor
  39055. */
  39056. get rawFragmentSourceCode(): string;
  39057. /**
  39058. * Recompiles the webGL program
  39059. * @param vertexSourceCode The source code for the vertex shader.
  39060. * @param fragmentSourceCode The source code for the fragment shader.
  39061. * @param onCompiled Callback called when completed.
  39062. * @param onError Callback called on error.
  39063. * @hidden
  39064. */
  39065. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39066. /**
  39067. * Prepares the effect
  39068. * @hidden
  39069. */
  39070. _prepareEffect(): void;
  39071. private _getShaderCodeAndErrorLine;
  39072. private _processCompilationErrors;
  39073. /**
  39074. * Checks if the effect is supported. (Must be called after compilation)
  39075. */
  39076. get isSupported(): boolean;
  39077. /**
  39078. * Binds a texture to the engine to be used as output of the shader.
  39079. * @param channel Name of the output variable.
  39080. * @param texture Texture to bind.
  39081. * @hidden
  39082. */
  39083. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39084. /**
  39085. * Sets a texture on the engine to be used in the shader.
  39086. * @param channel Name of the sampler variable.
  39087. * @param texture Texture to set.
  39088. */
  39089. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39090. /**
  39091. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39092. * @param channel Name of the sampler variable.
  39093. * @param texture Texture to set.
  39094. */
  39095. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39096. /**
  39097. * Sets an array of textures on the engine to be used in the shader.
  39098. * @param channel Name of the variable.
  39099. * @param textures Textures to set.
  39100. */
  39101. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39102. /**
  39103. * 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)
  39104. * @param channel Name of the sampler variable.
  39105. * @param postProcess Post process to get the input texture from.
  39106. */
  39107. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39108. /**
  39109. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39110. * 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)
  39111. * @param channel Name of the sampler variable.
  39112. * @param postProcess Post process to get the output texture from.
  39113. */
  39114. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39115. /**
  39116. * Binds a buffer to a uniform.
  39117. * @param buffer Buffer to bind.
  39118. * @param name Name of the uniform variable to bind to.
  39119. */
  39120. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39121. /**
  39122. * Binds block to a uniform.
  39123. * @param blockName Name of the block to bind.
  39124. * @param index Index to bind.
  39125. */
  39126. bindUniformBlock(blockName: string, index: number): void;
  39127. /**
  39128. * Sets an interger value on a uniform variable.
  39129. * @param uniformName Name of the variable.
  39130. * @param value Value to be set.
  39131. * @returns this effect.
  39132. */
  39133. setInt(uniformName: string, value: number): Effect;
  39134. /**
  39135. * Sets an int2 value on a uniform variable.
  39136. * @param uniformName Name of the variable.
  39137. * @param x First int in int2.
  39138. * @param y Second int in int2.
  39139. * @returns this effect.
  39140. */
  39141. setInt2(uniformName: string, x: number, y: number): Effect;
  39142. /**
  39143. * Sets an int3 value on a uniform variable.
  39144. * @param uniformName Name of the variable.
  39145. * @param x First int in int3.
  39146. * @param y Second int in int3.
  39147. * @param z Third int in int3.
  39148. * @returns this effect.
  39149. */
  39150. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39151. /**
  39152. * Sets an int4 value on a uniform variable.
  39153. * @param uniformName Name of the variable.
  39154. * @param x First int in int4.
  39155. * @param y Second int in int4.
  39156. * @param z Third int in int4.
  39157. * @param w Fourth int in int4.
  39158. * @returns this effect.
  39159. */
  39160. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39161. /**
  39162. * Sets an int array on a uniform variable.
  39163. * @param uniformName Name of the variable.
  39164. * @param array array to be set.
  39165. * @returns this effect.
  39166. */
  39167. setIntArray(uniformName: string, array: Int32Array): Effect;
  39168. /**
  39169. * 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)
  39170. * @param uniformName Name of the variable.
  39171. * @param array array to be set.
  39172. * @returns this effect.
  39173. */
  39174. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39175. /**
  39176. * 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)
  39177. * @param uniformName Name of the variable.
  39178. * @param array array to be set.
  39179. * @returns this effect.
  39180. */
  39181. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39182. /**
  39183. * 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)
  39184. * @param uniformName Name of the variable.
  39185. * @param array array to be set.
  39186. * @returns this effect.
  39187. */
  39188. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39189. /**
  39190. * Sets an float array on a uniform variable.
  39191. * @param uniformName Name of the variable.
  39192. * @param array array to be set.
  39193. * @returns this effect.
  39194. */
  39195. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39196. /**
  39197. * 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)
  39198. * @param uniformName Name of the variable.
  39199. * @param array array to be set.
  39200. * @returns this effect.
  39201. */
  39202. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39203. /**
  39204. * 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)
  39205. * @param uniformName Name of the variable.
  39206. * @param array array to be set.
  39207. * @returns this effect.
  39208. */
  39209. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39210. /**
  39211. * 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)
  39212. * @param uniformName Name of the variable.
  39213. * @param array array to be set.
  39214. * @returns this effect.
  39215. */
  39216. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39217. /**
  39218. * Sets an array on a uniform variable.
  39219. * @param uniformName Name of the variable.
  39220. * @param array array to be set.
  39221. * @returns this effect.
  39222. */
  39223. setArray(uniformName: string, array: number[]): Effect;
  39224. /**
  39225. * 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)
  39226. * @param uniformName Name of the variable.
  39227. * @param array array to be set.
  39228. * @returns this effect.
  39229. */
  39230. setArray2(uniformName: string, array: number[]): Effect;
  39231. /**
  39232. * 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)
  39233. * @param uniformName Name of the variable.
  39234. * @param array array to be set.
  39235. * @returns this effect.
  39236. */
  39237. setArray3(uniformName: string, array: number[]): Effect;
  39238. /**
  39239. * 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)
  39240. * @param uniformName Name of the variable.
  39241. * @param array array to be set.
  39242. * @returns this effect.
  39243. */
  39244. setArray4(uniformName: string, array: number[]): Effect;
  39245. /**
  39246. * Sets matrices on a uniform variable.
  39247. * @param uniformName Name of the variable.
  39248. * @param matrices matrices to be set.
  39249. * @returns this effect.
  39250. */
  39251. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39252. /**
  39253. * Sets matrix on a uniform variable.
  39254. * @param uniformName Name of the variable.
  39255. * @param matrix matrix to be set.
  39256. * @returns this effect.
  39257. */
  39258. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39259. /**
  39260. * 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)
  39261. * @param uniformName Name of the variable.
  39262. * @param matrix matrix to be set.
  39263. * @returns this effect.
  39264. */
  39265. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39266. /**
  39267. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39268. * @param uniformName Name of the variable.
  39269. * @param matrix matrix to be set.
  39270. * @returns this effect.
  39271. */
  39272. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39273. /**
  39274. * Sets a float on a uniform variable.
  39275. * @param uniformName Name of the variable.
  39276. * @param value value to be set.
  39277. * @returns this effect.
  39278. */
  39279. setFloat(uniformName: string, value: number): Effect;
  39280. /**
  39281. * Sets a boolean on a uniform variable.
  39282. * @param uniformName Name of the variable.
  39283. * @param bool value to be set.
  39284. * @returns this effect.
  39285. */
  39286. setBool(uniformName: string, bool: boolean): Effect;
  39287. /**
  39288. * Sets a Vector2 on a uniform variable.
  39289. * @param uniformName Name of the variable.
  39290. * @param vector2 vector2 to be set.
  39291. * @returns this effect.
  39292. */
  39293. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39294. /**
  39295. * Sets a float2 on a uniform variable.
  39296. * @param uniformName Name of the variable.
  39297. * @param x First float in float2.
  39298. * @param y Second float in float2.
  39299. * @returns this effect.
  39300. */
  39301. setFloat2(uniformName: string, x: number, y: number): Effect;
  39302. /**
  39303. * Sets a Vector3 on a uniform variable.
  39304. * @param uniformName Name of the variable.
  39305. * @param vector3 Value to be set.
  39306. * @returns this effect.
  39307. */
  39308. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39309. /**
  39310. * Sets a float3 on a uniform variable.
  39311. * @param uniformName Name of the variable.
  39312. * @param x First float in float3.
  39313. * @param y Second float in float3.
  39314. * @param z Third float in float3.
  39315. * @returns this effect.
  39316. */
  39317. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39318. /**
  39319. * Sets a Vector4 on a uniform variable.
  39320. * @param uniformName Name of the variable.
  39321. * @param vector4 Value to be set.
  39322. * @returns this effect.
  39323. */
  39324. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39325. /**
  39326. * Sets a float4 on a uniform variable.
  39327. * @param uniformName Name of the variable.
  39328. * @param x First float in float4.
  39329. * @param y Second float in float4.
  39330. * @param z Third float in float4.
  39331. * @param w Fourth float in float4.
  39332. * @returns this effect.
  39333. */
  39334. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39335. /**
  39336. * Sets a Color3 on a uniform variable.
  39337. * @param uniformName Name of the variable.
  39338. * @param color3 Value to be set.
  39339. * @returns this effect.
  39340. */
  39341. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39342. /**
  39343. * Sets a Color4 on a uniform variable.
  39344. * @param uniformName Name of the variable.
  39345. * @param color3 Value to be set.
  39346. * @param alpha Alpha value to be set.
  39347. * @returns this effect.
  39348. */
  39349. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39350. /**
  39351. * Sets a Color4 on a uniform variable
  39352. * @param uniformName defines the name of the variable
  39353. * @param color4 defines the value to be set
  39354. * @returns this effect.
  39355. */
  39356. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39357. /**
  39358. * Release all associated resources.
  39359. **/
  39360. dispose(): void;
  39361. /**
  39362. * This function will add a new shader to the shader store
  39363. * @param name the name of the shader
  39364. * @param pixelShader optional pixel shader content
  39365. * @param vertexShader optional vertex shader content
  39366. */
  39367. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39368. /**
  39369. * Store of each shader (The can be looked up using effect.key)
  39370. */
  39371. static ShadersStore: {
  39372. [key: string]: string;
  39373. };
  39374. /**
  39375. * Store of each included file for a shader (The can be looked up using effect.key)
  39376. */
  39377. static IncludesShadersStore: {
  39378. [key: string]: string;
  39379. };
  39380. /**
  39381. * Resets the cache of effects.
  39382. */
  39383. static ResetCache(): void;
  39384. }
  39385. }
  39386. declare module BABYLON {
  39387. /**
  39388. * Interface used to describe the capabilities of the engine relatively to the current browser
  39389. */
  39390. export interface EngineCapabilities {
  39391. /** Maximum textures units per fragment shader */
  39392. maxTexturesImageUnits: number;
  39393. /** Maximum texture units per vertex shader */
  39394. maxVertexTextureImageUnits: number;
  39395. /** Maximum textures units in the entire pipeline */
  39396. maxCombinedTexturesImageUnits: number;
  39397. /** Maximum texture size */
  39398. maxTextureSize: number;
  39399. /** Maximum texture samples */
  39400. maxSamples?: number;
  39401. /** Maximum cube texture size */
  39402. maxCubemapTextureSize: number;
  39403. /** Maximum render texture size */
  39404. maxRenderTextureSize: number;
  39405. /** Maximum number of vertex attributes */
  39406. maxVertexAttribs: number;
  39407. /** Maximum number of varyings */
  39408. maxVaryingVectors: number;
  39409. /** Maximum number of uniforms per vertex shader */
  39410. maxVertexUniformVectors: number;
  39411. /** Maximum number of uniforms per fragment shader */
  39412. maxFragmentUniformVectors: number;
  39413. /** Defines if standard derivates (dx/dy) are supported */
  39414. standardDerivatives: boolean;
  39415. /** Defines if s3tc texture compression is supported */
  39416. s3tc?: WEBGL_compressed_texture_s3tc;
  39417. /** Defines if pvrtc texture compression is supported */
  39418. pvrtc: any;
  39419. /** Defines if etc1 texture compression is supported */
  39420. etc1: any;
  39421. /** Defines if etc2 texture compression is supported */
  39422. etc2: any;
  39423. /** Defines if astc texture compression is supported */
  39424. astc: any;
  39425. /** Defines if bptc texture compression is supported */
  39426. bptc: any;
  39427. /** Defines if float textures are supported */
  39428. textureFloat: boolean;
  39429. /** Defines if vertex array objects are supported */
  39430. vertexArrayObject: boolean;
  39431. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39432. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39433. /** Gets the maximum level of anisotropy supported */
  39434. maxAnisotropy: number;
  39435. /** Defines if instancing is supported */
  39436. instancedArrays: boolean;
  39437. /** Defines if 32 bits indices are supported */
  39438. uintIndices: boolean;
  39439. /** Defines if high precision shaders are supported */
  39440. highPrecisionShaderSupported: boolean;
  39441. /** Defines if depth reading in the fragment shader is supported */
  39442. fragmentDepthSupported: boolean;
  39443. /** Defines if float texture linear filtering is supported*/
  39444. textureFloatLinearFiltering: boolean;
  39445. /** Defines if rendering to float textures is supported */
  39446. textureFloatRender: boolean;
  39447. /** Defines if half float textures are supported*/
  39448. textureHalfFloat: boolean;
  39449. /** Defines if half float texture linear filtering is supported*/
  39450. textureHalfFloatLinearFiltering: boolean;
  39451. /** Defines if rendering to half float textures is supported */
  39452. textureHalfFloatRender: boolean;
  39453. /** Defines if textureLOD shader command is supported */
  39454. textureLOD: boolean;
  39455. /** Defines if draw buffers extension is supported */
  39456. drawBuffersExtension: boolean;
  39457. /** Defines if depth textures are supported */
  39458. depthTextureExtension: boolean;
  39459. /** Defines if float color buffer are supported */
  39460. colorBufferFloat: boolean;
  39461. /** Gets disjoint timer query extension (null if not supported) */
  39462. timerQuery?: EXT_disjoint_timer_query;
  39463. /** Defines if timestamp can be used with timer query */
  39464. canUseTimestampForTimerQuery: boolean;
  39465. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39466. multiview?: any;
  39467. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39468. oculusMultiview?: any;
  39469. /** Function used to let the system compiles shaders in background */
  39470. parallelShaderCompile?: {
  39471. COMPLETION_STATUS_KHR: number;
  39472. };
  39473. /** Max number of texture samples for MSAA */
  39474. maxMSAASamples: number;
  39475. /** Defines if the blend min max extension is supported */
  39476. blendMinMax: boolean;
  39477. /** 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 */
  39478. canUseGLInstanceID: boolean;
  39479. }
  39480. }
  39481. declare module BABYLON {
  39482. /**
  39483. * @hidden
  39484. **/
  39485. export class DepthCullingState {
  39486. private _isDepthTestDirty;
  39487. private _isDepthMaskDirty;
  39488. private _isDepthFuncDirty;
  39489. private _isCullFaceDirty;
  39490. private _isCullDirty;
  39491. private _isZOffsetDirty;
  39492. private _isFrontFaceDirty;
  39493. private _depthTest;
  39494. private _depthMask;
  39495. private _depthFunc;
  39496. private _cull;
  39497. private _cullFace;
  39498. private _zOffset;
  39499. private _frontFace;
  39500. /**
  39501. * Initializes the state.
  39502. */
  39503. constructor();
  39504. get isDirty(): boolean;
  39505. get zOffset(): number;
  39506. set zOffset(value: number);
  39507. get cullFace(): Nullable<number>;
  39508. set cullFace(value: Nullable<number>);
  39509. get cull(): Nullable<boolean>;
  39510. set cull(value: Nullable<boolean>);
  39511. get depthFunc(): Nullable<number>;
  39512. set depthFunc(value: Nullable<number>);
  39513. get depthMask(): boolean;
  39514. set depthMask(value: boolean);
  39515. get depthTest(): boolean;
  39516. set depthTest(value: boolean);
  39517. get frontFace(): Nullable<number>;
  39518. set frontFace(value: Nullable<number>);
  39519. reset(): void;
  39520. apply(gl: WebGLRenderingContext): void;
  39521. }
  39522. }
  39523. declare module BABYLON {
  39524. /**
  39525. * @hidden
  39526. **/
  39527. export class StencilState {
  39528. /** 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 */
  39529. static readonly ALWAYS: number;
  39530. /** Passed to stencilOperation to specify that stencil value must be kept */
  39531. static readonly KEEP: number;
  39532. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39533. static readonly REPLACE: number;
  39534. private _isStencilTestDirty;
  39535. private _isStencilMaskDirty;
  39536. private _isStencilFuncDirty;
  39537. private _isStencilOpDirty;
  39538. private _stencilTest;
  39539. private _stencilMask;
  39540. private _stencilFunc;
  39541. private _stencilFuncRef;
  39542. private _stencilFuncMask;
  39543. private _stencilOpStencilFail;
  39544. private _stencilOpDepthFail;
  39545. private _stencilOpStencilDepthPass;
  39546. get isDirty(): boolean;
  39547. get stencilFunc(): number;
  39548. set stencilFunc(value: number);
  39549. get stencilFuncRef(): number;
  39550. set stencilFuncRef(value: number);
  39551. get stencilFuncMask(): number;
  39552. set stencilFuncMask(value: number);
  39553. get stencilOpStencilFail(): number;
  39554. set stencilOpStencilFail(value: number);
  39555. get stencilOpDepthFail(): number;
  39556. set stencilOpDepthFail(value: number);
  39557. get stencilOpStencilDepthPass(): number;
  39558. set stencilOpStencilDepthPass(value: number);
  39559. get stencilMask(): number;
  39560. set stencilMask(value: number);
  39561. get stencilTest(): boolean;
  39562. set stencilTest(value: boolean);
  39563. constructor();
  39564. reset(): void;
  39565. apply(gl: WebGLRenderingContext): void;
  39566. }
  39567. }
  39568. declare module BABYLON {
  39569. /**
  39570. * @hidden
  39571. **/
  39572. export class AlphaState {
  39573. _blendFunctionParameters: Nullable<number>[];
  39574. _blendEquationParameters: Nullable<number>[];
  39575. _blendConstants: Nullable<number>[];
  39576. _isBlendConstantsDirty: boolean;
  39577. private _alphaBlend;
  39578. private _isAlphaBlendDirty;
  39579. private _isBlendFunctionParametersDirty;
  39580. private _isBlendEquationParametersDirty;
  39581. /**
  39582. * Initializes the state.
  39583. */
  39584. constructor();
  39585. get isDirty(): boolean;
  39586. get alphaBlend(): boolean;
  39587. set alphaBlend(value: boolean);
  39588. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39589. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39590. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39591. reset(): void;
  39592. apply(gl: WebGLRenderingContext): void;
  39593. }
  39594. }
  39595. declare module BABYLON {
  39596. /** @hidden */
  39597. export class WebGLShaderProcessor implements IShaderProcessor {
  39598. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39599. }
  39600. }
  39601. declare module BABYLON {
  39602. /** @hidden */
  39603. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39604. attributeProcessor(attribute: string): string;
  39605. varyingProcessor(varying: string, isFragment: boolean): string;
  39606. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39607. }
  39608. }
  39609. declare module BABYLON {
  39610. /**
  39611. * Interface for attribute information associated with buffer instanciation
  39612. */
  39613. export interface InstancingAttributeInfo {
  39614. /**
  39615. * Name of the GLSL attribute
  39616. * if attribute index is not specified, this is used to retrieve the index from the effect
  39617. */
  39618. attributeName: string;
  39619. /**
  39620. * Index/offset of the attribute in the vertex shader
  39621. * if not specified, this will be computes from the name.
  39622. */
  39623. index?: number;
  39624. /**
  39625. * size of the attribute, 1, 2, 3 or 4
  39626. */
  39627. attributeSize: number;
  39628. /**
  39629. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39630. */
  39631. offset: number;
  39632. /**
  39633. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39634. * default to 1
  39635. */
  39636. divisor?: number;
  39637. /**
  39638. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39639. * default is FLOAT
  39640. */
  39641. attributeType?: number;
  39642. /**
  39643. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39644. */
  39645. normalized?: boolean;
  39646. }
  39647. }
  39648. declare module BABYLON {
  39649. /** @hidden */
  39650. export interface EngineFeatures {
  39651. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39652. forceBitmapOverHTMLImageElement: boolean;
  39653. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39654. supportRenderAndCopyToLodForFloatTextures: boolean;
  39655. /** Indicates that the engine support handling depth/stencil textures */
  39656. supportDepthStencilTexture: boolean;
  39657. /** Indicates that the engine support shadow samplers */
  39658. supportShadowSamplers: boolean;
  39659. /** 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 */
  39660. uniformBufferHardCheckMatrix: boolean;
  39661. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39662. allowTexturePrefiltering: boolean;
  39663. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39664. trackUbosInFrame: boolean;
  39665. /** Indicates that the Cascaded Shadow Map technic is supported */
  39666. supportCSM: boolean;
  39667. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39668. basisNeedsPOT: boolean;
  39669. /** Indicates that the engine supports 3D textures */
  39670. support3DTextures: boolean;
  39671. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39672. needTypeSuffixInShaderConstants: boolean;
  39673. /** Indicates that MSAA is supported */
  39674. supportMSAA: boolean;
  39675. /** Indicates that SSAO2 is supported */
  39676. supportSSAO2: boolean;
  39677. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39678. supportExtendedTextureFormats: boolean;
  39679. /** Indicates that the switch/case construct is supported in shaders */
  39680. supportSwitchCaseInShader: boolean;
  39681. /** @hidden */
  39682. _collectUbosUpdatedInFrame: boolean;
  39683. }
  39684. }
  39685. declare module BABYLON {
  39686. /** @hidden */
  39687. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39688. private _webGLTexture;
  39689. private _context;
  39690. get underlyingResource(): Nullable<WebGLTexture>;
  39691. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39692. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39693. set(hardwareTexture: WebGLTexture): void;
  39694. reset(): void;
  39695. release(): void;
  39696. }
  39697. }
  39698. declare module BABYLON {
  39699. interface ThinEngine {
  39700. /**
  39701. * Update a video texture
  39702. * @param texture defines the texture to update
  39703. * @param video defines the video element to use
  39704. * @param invertY defines if data must be stored with Y axis inverted
  39705. */
  39706. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39707. }
  39708. }
  39709. declare module BABYLON {
  39710. interface ThinEngine {
  39711. /**
  39712. * Creates a dynamic texture
  39713. * @param width defines the width of the texture
  39714. * @param height defines the height of the texture
  39715. * @param generateMipMaps defines if the engine should generate the mip levels
  39716. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39717. * @returns the dynamic texture inside an InternalTexture
  39718. */
  39719. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39720. /**
  39721. * Update the content of a dynamic texture
  39722. * @param texture defines the texture to update
  39723. * @param source defines the source containing the data
  39724. * @param invertY defines if data must be stored with Y axis inverted
  39725. * @param premulAlpha defines if alpha is stored as premultiplied
  39726. * @param format defines the format of the data
  39727. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39728. */
  39729. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39730. }
  39731. }
  39732. declare module BABYLON {
  39733. /**
  39734. * Settings for finer control over video usage
  39735. */
  39736. export interface VideoTextureSettings {
  39737. /**
  39738. * Applies `autoplay` to video, if specified
  39739. */
  39740. autoPlay?: boolean;
  39741. /**
  39742. * Applies `muted` to video, if specified
  39743. */
  39744. muted?: boolean;
  39745. /**
  39746. * Applies `loop` to video, if specified
  39747. */
  39748. loop?: boolean;
  39749. /**
  39750. * Automatically updates internal texture from video at every frame in the render loop
  39751. */
  39752. autoUpdateTexture: boolean;
  39753. /**
  39754. * Image src displayed during the video loading or until the user interacts with the video.
  39755. */
  39756. poster?: string;
  39757. }
  39758. /**
  39759. * If you want to display a video in your scene, this is the special texture for that.
  39760. * This special texture works similar to other textures, with the exception of a few parameters.
  39761. * @see https://doc.babylonjs.com/how_to/video_texture
  39762. */
  39763. export class VideoTexture extends Texture {
  39764. /**
  39765. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39766. */
  39767. readonly autoUpdateTexture: boolean;
  39768. /**
  39769. * The video instance used by the texture internally
  39770. */
  39771. readonly video: HTMLVideoElement;
  39772. private _onUserActionRequestedObservable;
  39773. /**
  39774. * Event triggerd when a dom action is required by the user to play the video.
  39775. * This happens due to recent changes in browser policies preventing video to auto start.
  39776. */
  39777. get onUserActionRequestedObservable(): Observable<Texture>;
  39778. private _generateMipMaps;
  39779. private _stillImageCaptured;
  39780. private _displayingPosterTexture;
  39781. private _settings;
  39782. private _createInternalTextureOnEvent;
  39783. private _frameId;
  39784. private _currentSrc;
  39785. /**
  39786. * Creates a video texture.
  39787. * If you want to display a video in your scene, this is the special texture for that.
  39788. * This special texture works similar to other textures, with the exception of a few parameters.
  39789. * @see https://doc.babylonjs.com/how_to/video_texture
  39790. * @param name optional name, will detect from video source, if not defined
  39791. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39792. * @param scene is obviously the current scene.
  39793. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39794. * @param invertY is false by default but can be used to invert video on Y axis
  39795. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39796. * @param settings allows finer control over video usage
  39797. */
  39798. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39799. private _getName;
  39800. private _getVideo;
  39801. private _createInternalTexture;
  39802. private reset;
  39803. /**
  39804. * @hidden Internal method to initiate `update`.
  39805. */
  39806. _rebuild(): void;
  39807. /**
  39808. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39809. */
  39810. update(): void;
  39811. /**
  39812. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39813. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39814. */
  39815. updateTexture(isVisible: boolean): void;
  39816. protected _updateInternalTexture: () => void;
  39817. /**
  39818. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39819. * @param url New url.
  39820. */
  39821. updateURL(url: string): void;
  39822. /**
  39823. * Clones the texture.
  39824. * @returns the cloned texture
  39825. */
  39826. clone(): VideoTexture;
  39827. /**
  39828. * Dispose the texture and release its associated resources.
  39829. */
  39830. dispose(): void;
  39831. /**
  39832. * Creates a video texture straight from a stream.
  39833. * @param scene Define the scene the texture should be created in
  39834. * @param stream Define the stream the texture should be created from
  39835. * @returns The created video texture as a promise
  39836. */
  39837. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39838. /**
  39839. * Creates a video texture straight from your WebCam video feed.
  39840. * @param scene Define the scene the texture should be created in
  39841. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39842. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39843. * @returns The created video texture as a promise
  39844. */
  39845. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39846. minWidth: number;
  39847. maxWidth: number;
  39848. minHeight: number;
  39849. maxHeight: number;
  39850. deviceId: string;
  39851. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39852. /**
  39853. * Creates a video texture straight from your WebCam video feed.
  39854. * @param scene Define the scene the texture should be created in
  39855. * @param onReady Define a callback to triggered once the texture will be ready
  39856. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39857. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39858. */
  39859. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39860. minWidth: number;
  39861. maxWidth: number;
  39862. minHeight: number;
  39863. maxHeight: number;
  39864. deviceId: string;
  39865. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39866. }
  39867. }
  39868. declare module BABYLON {
  39869. /**
  39870. * Defines the interface used by objects working like Scene
  39871. * @hidden
  39872. */
  39873. export interface ISceneLike {
  39874. _addPendingData(data: any): void;
  39875. _removePendingData(data: any): void;
  39876. offlineProvider: IOfflineProvider;
  39877. }
  39878. /**
  39879. * Information about the current host
  39880. */
  39881. export interface HostInformation {
  39882. /**
  39883. * Defines if the current host is a mobile
  39884. */
  39885. isMobile: boolean;
  39886. }
  39887. /** Interface defining initialization parameters for Engine class */
  39888. export interface EngineOptions extends WebGLContextAttributes {
  39889. /**
  39890. * Defines if the engine should no exceed a specified device ratio
  39891. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39892. */
  39893. limitDeviceRatio?: number;
  39894. /**
  39895. * Defines if webvr should be enabled automatically
  39896. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39897. */
  39898. autoEnableWebVR?: boolean;
  39899. /**
  39900. * Defines if webgl2 should be turned off even if supported
  39901. * @see https://doc.babylonjs.com/features/webgl2
  39902. */
  39903. disableWebGL2Support?: boolean;
  39904. /**
  39905. * Defines if webaudio should be initialized as well
  39906. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39907. */
  39908. audioEngine?: boolean;
  39909. /**
  39910. * Defines if animations should run using a deterministic lock step
  39911. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39912. */
  39913. deterministicLockstep?: boolean;
  39914. /** Defines the maximum steps to use with deterministic lock step mode */
  39915. lockstepMaxSteps?: number;
  39916. /** Defines the seconds between each deterministic lock step */
  39917. timeStep?: number;
  39918. /**
  39919. * Defines that engine should ignore context lost events
  39920. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39921. */
  39922. doNotHandleContextLost?: boolean;
  39923. /**
  39924. * Defines that engine should ignore modifying touch action attribute and style
  39925. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39926. */
  39927. doNotHandleTouchAction?: boolean;
  39928. /**
  39929. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39930. */
  39931. useHighPrecisionFloats?: boolean;
  39932. /**
  39933. * Make the canvas XR Compatible for XR sessions
  39934. */
  39935. xrCompatible?: boolean;
  39936. /**
  39937. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39938. */
  39939. useHighPrecisionMatrix?: boolean;
  39940. /**
  39941. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39942. */
  39943. failIfMajorPerformanceCaveat?: boolean;
  39944. /**
  39945. * Defines whether to adapt to the device's viewport characteristics (default: false)
  39946. */
  39947. adaptToDeviceRatio?: boolean;
  39948. }
  39949. /**
  39950. * The base engine class (root of all engines)
  39951. */
  39952. export class ThinEngine {
  39953. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39954. static ExceptionList: ({
  39955. key: string;
  39956. capture: string;
  39957. captureConstraint: number;
  39958. targets: string[];
  39959. } | {
  39960. key: string;
  39961. capture: null;
  39962. captureConstraint: null;
  39963. targets: string[];
  39964. })[];
  39965. /** @hidden */
  39966. static _TextureLoaders: IInternalTextureLoader[];
  39967. /**
  39968. * Returns the current npm package of the sdk
  39969. */
  39970. static get NpmPackage(): string;
  39971. /**
  39972. * Returns the current version of the framework
  39973. */
  39974. static get Version(): string;
  39975. /**
  39976. * Returns a string describing the current engine
  39977. */
  39978. get description(): string;
  39979. /**
  39980. * Returns the name of the engine
  39981. */
  39982. get name(): string;
  39983. /**
  39984. * Returns the version of the engine
  39985. */
  39986. get version(): number;
  39987. /**
  39988. * Gets or sets the epsilon value used by collision engine
  39989. */
  39990. static CollisionsEpsilon: number;
  39991. /**
  39992. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39993. */
  39994. static get ShadersRepository(): string;
  39995. static set ShadersRepository(value: string);
  39996. /** @hidden */
  39997. _shaderProcessor: Nullable<IShaderProcessor>;
  39998. /**
  39999. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40000. */
  40001. forcePOTTextures: boolean;
  40002. /**
  40003. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40004. */
  40005. isFullscreen: boolean;
  40006. /**
  40007. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40008. */
  40009. cullBackFaces: boolean;
  40010. /**
  40011. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40012. */
  40013. renderEvenInBackground: boolean;
  40014. /**
  40015. * Gets or sets a boolean indicating that cache can be kept between frames
  40016. */
  40017. preventCacheWipeBetweenFrames: boolean;
  40018. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40019. validateShaderPrograms: boolean;
  40020. /**
  40021. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40022. * This can provide greater z depth for distant objects.
  40023. */
  40024. useReverseDepthBuffer: boolean;
  40025. /**
  40026. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40027. */
  40028. disableUniformBuffers: boolean;
  40029. private _frameId;
  40030. /**
  40031. * Gets the current frame id
  40032. */
  40033. get frameId(): number;
  40034. /** @hidden */
  40035. _uniformBuffers: UniformBuffer[];
  40036. /**
  40037. * Gets a boolean indicating that the engine supports uniform buffers
  40038. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40039. */
  40040. get supportsUniformBuffers(): boolean;
  40041. /** @hidden */
  40042. _gl: WebGLRenderingContext;
  40043. /** @hidden */
  40044. _webGLVersion: number;
  40045. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40046. protected _windowIsBackground: boolean;
  40047. protected _creationOptions: EngineOptions;
  40048. protected _highPrecisionShadersAllowed: boolean;
  40049. /** @hidden */
  40050. get _shouldUseHighPrecisionShader(): boolean;
  40051. /**
  40052. * Gets a boolean indicating that only power of 2 textures are supported
  40053. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40054. */
  40055. get needPOTTextures(): boolean;
  40056. /** @hidden */
  40057. _badOS: boolean;
  40058. /** @hidden */
  40059. _badDesktopOS: boolean;
  40060. protected _hardwareScalingLevel: number;
  40061. /** @hidden */
  40062. _caps: EngineCapabilities;
  40063. /** @hidden */
  40064. _features: EngineFeatures;
  40065. protected _isStencilEnable: boolean;
  40066. private _glVersion;
  40067. private _glRenderer;
  40068. private _glVendor;
  40069. /** @hidden */
  40070. _videoTextureSupported: boolean;
  40071. protected _renderingQueueLaunched: boolean;
  40072. protected _activeRenderLoops: (() => void)[];
  40073. /**
  40074. * Observable signaled when a context lost event is raised
  40075. */
  40076. onContextLostObservable: Observable<ThinEngine>;
  40077. /**
  40078. * Observable signaled when a context restored event is raised
  40079. */
  40080. onContextRestoredObservable: Observable<ThinEngine>;
  40081. private _onContextLost;
  40082. private _onContextRestored;
  40083. protected _contextWasLost: boolean;
  40084. /** @hidden */
  40085. _doNotHandleContextLost: boolean;
  40086. /**
  40087. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40088. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40089. */
  40090. get doNotHandleContextLost(): boolean;
  40091. set doNotHandleContextLost(value: boolean);
  40092. /**
  40093. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40094. */
  40095. disableVertexArrayObjects: boolean;
  40096. /** @hidden */
  40097. protected _colorWrite: boolean;
  40098. /** @hidden */
  40099. protected _colorWriteChanged: boolean;
  40100. /** @hidden */
  40101. protected _depthCullingState: DepthCullingState;
  40102. /** @hidden */
  40103. protected _stencilState: StencilState;
  40104. /** @hidden */
  40105. _alphaState: AlphaState;
  40106. /** @hidden */
  40107. _alphaMode: number;
  40108. /** @hidden */
  40109. _alphaEquation: number;
  40110. /** @hidden */
  40111. _internalTexturesCache: InternalTexture[];
  40112. /** @hidden */
  40113. protected _activeChannel: number;
  40114. private _currentTextureChannel;
  40115. /** @hidden */
  40116. protected _boundTexturesCache: {
  40117. [key: string]: Nullable<InternalTexture>;
  40118. };
  40119. /** @hidden */
  40120. protected _currentEffect: Nullable<Effect>;
  40121. /** @hidden */
  40122. protected _currentProgram: Nullable<WebGLProgram>;
  40123. protected _compiledEffects: {
  40124. [key: string]: Effect;
  40125. };
  40126. private _vertexAttribArraysEnabled;
  40127. /** @hidden */
  40128. protected _cachedViewport: Nullable<IViewportLike>;
  40129. private _cachedVertexArrayObject;
  40130. /** @hidden */
  40131. protected _cachedVertexBuffers: any;
  40132. /** @hidden */
  40133. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40134. /** @hidden */
  40135. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40136. /** @hidden */
  40137. _currentRenderTarget: Nullable<InternalTexture>;
  40138. private _uintIndicesCurrentlySet;
  40139. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40140. /** @hidden */
  40141. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40142. /** @hidden */
  40143. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40144. private _currentBufferPointers;
  40145. private _currentInstanceLocations;
  40146. private _currentInstanceBuffers;
  40147. private _textureUnits;
  40148. /** @hidden */
  40149. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40150. /** @hidden */
  40151. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40152. /** @hidden */
  40153. _boundRenderFunction: any;
  40154. private _vaoRecordInProgress;
  40155. private _mustWipeVertexAttributes;
  40156. private _emptyTexture;
  40157. private _emptyCubeTexture;
  40158. private _emptyTexture3D;
  40159. private _emptyTexture2DArray;
  40160. /** @hidden */
  40161. _frameHandler: number;
  40162. private _nextFreeTextureSlots;
  40163. private _maxSimultaneousTextures;
  40164. private _activeRequests;
  40165. /** @hidden */
  40166. _transformTextureUrl: Nullable<(url: string) => string>;
  40167. /**
  40168. * Gets information about the current host
  40169. */
  40170. hostInformation: HostInformation;
  40171. protected get _supportsHardwareTextureRescaling(): boolean;
  40172. private _framebufferDimensionsObject;
  40173. /**
  40174. * sets the object from which width and height will be taken from when getting render width and height
  40175. * Will fallback to the gl object
  40176. * @param dimensions the framebuffer width and height that will be used.
  40177. */
  40178. set framebufferDimensionsObject(dimensions: Nullable<{
  40179. framebufferWidth: number;
  40180. framebufferHeight: number;
  40181. }>);
  40182. /**
  40183. * Gets the current viewport
  40184. */
  40185. get currentViewport(): Nullable<IViewportLike>;
  40186. /**
  40187. * Gets the default empty texture
  40188. */
  40189. get emptyTexture(): InternalTexture;
  40190. /**
  40191. * Gets the default empty 3D texture
  40192. */
  40193. get emptyTexture3D(): InternalTexture;
  40194. /**
  40195. * Gets the default empty 2D array texture
  40196. */
  40197. get emptyTexture2DArray(): InternalTexture;
  40198. /**
  40199. * Gets the default empty cube texture
  40200. */
  40201. get emptyCubeTexture(): InternalTexture;
  40202. /**
  40203. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40204. */
  40205. premultipliedAlpha: boolean;
  40206. /**
  40207. * Observable event triggered before each texture is initialized
  40208. */
  40209. onBeforeTextureInitObservable: Observable<Texture>;
  40210. /** @hidden */
  40211. protected _isWebGPU: boolean;
  40212. /**
  40213. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40214. */
  40215. get isWebGPU(): boolean;
  40216. /** @hidden */
  40217. protected _shaderPlatformName: string;
  40218. /**
  40219. * Gets the shader platfrom name used by the effects.
  40220. */
  40221. get shaderPlatformName(): string;
  40222. /**
  40223. * Creates a new engine
  40224. * @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
  40225. * @param antialias defines enable antialiasing (default: false)
  40226. * @param options defines further options to be sent to the getContext() function
  40227. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40228. */
  40229. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40230. /**
  40231. * @hidden
  40232. */
  40233. _debugPushGroup(groupName: string, targetObject?: number): void;
  40234. /**
  40235. * @hidden
  40236. */
  40237. _debugPopGroup(targetObject?: number): void;
  40238. /**
  40239. * @hidden
  40240. */
  40241. _debugInsertMarker(text: string, targetObject?: number): void;
  40242. /**
  40243. * Shared initialization across engines types.
  40244. * @param canvas The canvas associated with this instance of the engine.
  40245. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40246. * @param audioEngine Defines if an audio engine should be created by default
  40247. */
  40248. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40249. /**
  40250. * Gets a shader processor implementation fitting with the current engine type.
  40251. * @returns The shader processor implementation.
  40252. */
  40253. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40254. /** @hidden */
  40255. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40256. private _rebuildInternalTextures;
  40257. private _rebuildEffects;
  40258. /**
  40259. * Gets a boolean indicating if all created effects are ready
  40260. * @returns true if all effects are ready
  40261. */
  40262. areAllEffectsReady(): boolean;
  40263. protected _rebuildBuffers(): void;
  40264. protected _initGLContext(): void;
  40265. protected _initFeatures(): void;
  40266. /**
  40267. * Gets version of the current webGL context
  40268. * Keep it for back compat - use version instead
  40269. */
  40270. get webGLVersion(): number;
  40271. /**
  40272. * Gets a string identifying the name of the class
  40273. * @returns "Engine" string
  40274. */
  40275. getClassName(): string;
  40276. /**
  40277. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40278. */
  40279. get isStencilEnable(): boolean;
  40280. /** @hidden */
  40281. _prepareWorkingCanvas(): void;
  40282. /**
  40283. * Reset the texture cache to empty state
  40284. */
  40285. resetTextureCache(): void;
  40286. /**
  40287. * Gets an object containing information about the current webGL context
  40288. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40289. */
  40290. getGlInfo(): {
  40291. vendor: string;
  40292. renderer: string;
  40293. version: string;
  40294. };
  40295. /**
  40296. * Defines the hardware scaling level.
  40297. * By default the hardware scaling level is computed from the window device ratio.
  40298. * 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.
  40299. * @param level defines the level to use
  40300. */
  40301. setHardwareScalingLevel(level: number): void;
  40302. /**
  40303. * Gets the current hardware scaling level.
  40304. * By default the hardware scaling level is computed from the window device ratio.
  40305. * 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.
  40306. * @returns a number indicating the current hardware scaling level
  40307. */
  40308. getHardwareScalingLevel(): number;
  40309. /**
  40310. * Gets the list of loaded textures
  40311. * @returns an array containing all loaded textures
  40312. */
  40313. getLoadedTexturesCache(): InternalTexture[];
  40314. /**
  40315. * Gets the object containing all engine capabilities
  40316. * @returns the EngineCapabilities object
  40317. */
  40318. getCaps(): EngineCapabilities;
  40319. /**
  40320. * stop executing a render loop function and remove it from the execution array
  40321. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40322. */
  40323. stopRenderLoop(renderFunction?: () => void): void;
  40324. /** @hidden */
  40325. _renderLoop(): void;
  40326. /**
  40327. * Gets the HTML canvas attached with the current webGL context
  40328. * @returns a HTML canvas
  40329. */
  40330. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40331. /**
  40332. * Gets host window
  40333. * @returns the host window object
  40334. */
  40335. getHostWindow(): Nullable<Window>;
  40336. /**
  40337. * Gets the current render width
  40338. * @param useScreen defines if screen size must be used (or the current render target if any)
  40339. * @returns a number defining the current render width
  40340. */
  40341. getRenderWidth(useScreen?: boolean): number;
  40342. /**
  40343. * Gets the current render height
  40344. * @param useScreen defines if screen size must be used (or the current render target if any)
  40345. * @returns a number defining the current render height
  40346. */
  40347. getRenderHeight(useScreen?: boolean): number;
  40348. /**
  40349. * Can be used to override the current requestAnimationFrame requester.
  40350. * @hidden
  40351. */
  40352. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40353. /**
  40354. * Register and execute a render loop. The engine can have more than one render function
  40355. * @param renderFunction defines the function to continuously execute
  40356. */
  40357. runRenderLoop(renderFunction: () => void): void;
  40358. /**
  40359. * Clear the current render buffer or the current render target (if any is set up)
  40360. * @param color defines the color to use
  40361. * @param backBuffer defines if the back buffer must be cleared
  40362. * @param depth defines if the depth buffer must be cleared
  40363. * @param stencil defines if the stencil buffer must be cleared
  40364. */
  40365. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40366. protected _viewportCached: {
  40367. x: number;
  40368. y: number;
  40369. z: number;
  40370. w: number;
  40371. };
  40372. /** @hidden */
  40373. _viewport(x: number, y: number, width: number, height: number): void;
  40374. /**
  40375. * Set the WebGL's viewport
  40376. * @param viewport defines the viewport element to be used
  40377. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40378. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40379. */
  40380. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40381. /**
  40382. * Begin a new frame
  40383. */
  40384. beginFrame(): void;
  40385. /**
  40386. * Enf the current frame
  40387. */
  40388. endFrame(): void;
  40389. /**
  40390. * Resize the view according to the canvas' size
  40391. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40392. */
  40393. resize(forceSetSize?: boolean): void;
  40394. /**
  40395. * Force a specific size of the canvas
  40396. * @param width defines the new canvas' width
  40397. * @param height defines the new canvas' height
  40398. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40399. * @returns true if the size was changed
  40400. */
  40401. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40402. /**
  40403. * Binds the frame buffer to the specified texture.
  40404. * @param texture The texture to render to or null for the default canvas
  40405. * @param faceIndex The face of the texture to render to in case of cube texture
  40406. * @param requiredWidth The width of the target to render to
  40407. * @param requiredHeight The height of the target to render to
  40408. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40409. * @param lodLevel defines the lod level to bind to the frame buffer
  40410. * @param layer defines the 2d array index to bind to frame buffer to
  40411. */
  40412. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40413. /** @hidden */
  40414. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40415. /**
  40416. * Unbind the current render target texture from the webGL context
  40417. * @param texture defines the render target texture to unbind
  40418. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40419. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40420. */
  40421. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40422. /**
  40423. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40424. */
  40425. flushFramebuffer(): void;
  40426. /**
  40427. * Unbind the current render target and bind the default framebuffer
  40428. */
  40429. restoreDefaultFramebuffer(): void;
  40430. /** @hidden */
  40431. protected _resetVertexBufferBinding(): void;
  40432. /**
  40433. * Creates a vertex buffer
  40434. * @param data the data for the vertex buffer
  40435. * @returns the new WebGL static buffer
  40436. */
  40437. createVertexBuffer(data: DataArray): DataBuffer;
  40438. private _createVertexBuffer;
  40439. /**
  40440. * Creates a dynamic vertex buffer
  40441. * @param data the data for the dynamic vertex buffer
  40442. * @returns the new WebGL dynamic buffer
  40443. */
  40444. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40445. protected _resetIndexBufferBinding(): void;
  40446. /**
  40447. * Creates a new index buffer
  40448. * @param indices defines the content of the index buffer
  40449. * @param updatable defines if the index buffer must be updatable
  40450. * @returns a new webGL buffer
  40451. */
  40452. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40453. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40454. /**
  40455. * Bind a webGL buffer to the webGL context
  40456. * @param buffer defines the buffer to bind
  40457. */
  40458. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40459. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40460. private bindBuffer;
  40461. /**
  40462. * update the bound buffer with the given data
  40463. * @param data defines the data to update
  40464. */
  40465. updateArrayBuffer(data: Float32Array): void;
  40466. private _vertexAttribPointer;
  40467. /** @hidden */
  40468. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40469. private _bindVertexBuffersAttributes;
  40470. /**
  40471. * Records a vertex array object
  40472. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40473. * @param vertexBuffers defines the list of vertex buffers to store
  40474. * @param indexBuffer defines the index buffer to store
  40475. * @param effect defines the effect to store
  40476. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40477. * @returns the new vertex array object
  40478. */
  40479. recordVertexArrayObject(vertexBuffers: {
  40480. [key: string]: VertexBuffer;
  40481. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40482. [kind: string]: Nullable<VertexBuffer>;
  40483. }): WebGLVertexArrayObject;
  40484. /**
  40485. * Bind a specific vertex array object
  40486. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40487. * @param vertexArrayObject defines the vertex array object to bind
  40488. * @param indexBuffer defines the index buffer to bind
  40489. */
  40490. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40491. /**
  40492. * Bind webGl buffers directly to the webGL context
  40493. * @param vertexBuffer defines the vertex buffer to bind
  40494. * @param indexBuffer defines the index buffer to bind
  40495. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40496. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40497. * @param effect defines the effect associated with the vertex buffer
  40498. */
  40499. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40500. private _unbindVertexArrayObject;
  40501. /**
  40502. * Bind a list of vertex buffers to the webGL context
  40503. * @param vertexBuffers defines the list of vertex buffers to bind
  40504. * @param indexBuffer defines the index buffer to bind
  40505. * @param effect defines the effect associated with the vertex buffers
  40506. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40507. */
  40508. bindBuffers(vertexBuffers: {
  40509. [key: string]: Nullable<VertexBuffer>;
  40510. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40511. [kind: string]: Nullable<VertexBuffer>;
  40512. }): void;
  40513. /**
  40514. * Unbind all instance attributes
  40515. */
  40516. unbindInstanceAttributes(): void;
  40517. /**
  40518. * Release and free the memory of a vertex array object
  40519. * @param vao defines the vertex array object to delete
  40520. */
  40521. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40522. /** @hidden */
  40523. _releaseBuffer(buffer: DataBuffer): boolean;
  40524. protected _deleteBuffer(buffer: DataBuffer): void;
  40525. /**
  40526. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40527. * @param instancesBuffer defines the webGL buffer to update and bind
  40528. * @param data defines the data to store in the buffer
  40529. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40530. */
  40531. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40532. /**
  40533. * Bind the content of a webGL buffer used with instantiation
  40534. * @param instancesBuffer defines the webGL buffer to bind
  40535. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40536. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40537. */
  40538. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40539. /**
  40540. * Disable the instance attribute corresponding to the name in parameter
  40541. * @param name defines the name of the attribute to disable
  40542. */
  40543. disableInstanceAttributeByName(name: string): void;
  40544. /**
  40545. * Disable the instance attribute corresponding to the location in parameter
  40546. * @param attributeLocation defines the attribute location of the attribute to disable
  40547. */
  40548. disableInstanceAttribute(attributeLocation: number): void;
  40549. /**
  40550. * Disable the attribute corresponding to the location in parameter
  40551. * @param attributeLocation defines the attribute location of the attribute to disable
  40552. */
  40553. disableAttributeByIndex(attributeLocation: number): void;
  40554. /**
  40555. * Send a draw order
  40556. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40557. * @param indexStart defines the starting index
  40558. * @param indexCount defines the number of index to draw
  40559. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40560. */
  40561. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40562. /**
  40563. * Draw a list of points
  40564. * @param verticesStart defines the index of first vertex to draw
  40565. * @param verticesCount defines the count of vertices to draw
  40566. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40567. */
  40568. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40569. /**
  40570. * Draw a list of unindexed primitives
  40571. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40572. * @param verticesStart defines the index of first vertex to draw
  40573. * @param verticesCount defines the count of vertices to draw
  40574. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40575. */
  40576. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40577. /**
  40578. * Draw a list of indexed primitives
  40579. * @param fillMode defines the primitive to use
  40580. * @param indexStart defines the starting index
  40581. * @param indexCount defines the number of index to draw
  40582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40583. */
  40584. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40585. /**
  40586. * Draw a list of unindexed primitives
  40587. * @param fillMode defines the primitive to use
  40588. * @param verticesStart defines the index of first vertex to draw
  40589. * @param verticesCount defines the count of vertices to draw
  40590. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40591. */
  40592. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40593. private _drawMode;
  40594. /** @hidden */
  40595. protected _reportDrawCall(): void;
  40596. /** @hidden */
  40597. _releaseEffect(effect: Effect): void;
  40598. /** @hidden */
  40599. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40600. /**
  40601. * Create a new effect (used to store vertex/fragment shaders)
  40602. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40603. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40604. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40605. * @param samplers defines an array of string used to represent textures
  40606. * @param defines defines the string containing the defines to use to compile the shaders
  40607. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40608. * @param onCompiled defines a function to call when the effect creation is successful
  40609. * @param onError defines a function to call when the effect creation has failed
  40610. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40611. * @returns the new Effect
  40612. */
  40613. 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;
  40614. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40615. private _compileShader;
  40616. private _compileRawShader;
  40617. /** @hidden */
  40618. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40619. /**
  40620. * Directly creates a webGL program
  40621. * @param pipelineContext defines the pipeline context to attach to
  40622. * @param vertexCode defines the vertex shader code to use
  40623. * @param fragmentCode defines the fragment shader code to use
  40624. * @param context defines the webGL context to use (if not set, the current one will be used)
  40625. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40626. * @returns the new webGL program
  40627. */
  40628. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40629. /**
  40630. * Creates a webGL program
  40631. * @param pipelineContext defines the pipeline context to attach to
  40632. * @param vertexCode defines the vertex shader code to use
  40633. * @param fragmentCode defines the fragment shader code to use
  40634. * @param defines defines the string containing the defines to use to compile the shaders
  40635. * @param context defines the webGL context to use (if not set, the current one will be used)
  40636. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40637. * @returns the new webGL program
  40638. */
  40639. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40640. /**
  40641. * Creates a new pipeline context
  40642. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40643. * @returns the new pipeline
  40644. */
  40645. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40646. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40647. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40648. /** @hidden */
  40649. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40650. /** @hidden */
  40651. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40652. /** @hidden */
  40653. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40654. /**
  40655. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40656. * @param pipelineContext defines the pipeline context to use
  40657. * @param uniformsNames defines the list of uniform names
  40658. * @returns an array of webGL uniform locations
  40659. */
  40660. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40661. /**
  40662. * Gets the list of active attributes for a given webGL program
  40663. * @param pipelineContext defines the pipeline context to use
  40664. * @param attributesNames defines the list of attribute names to get
  40665. * @returns an array of indices indicating the offset of each attribute
  40666. */
  40667. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40668. /**
  40669. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40670. * @param effect defines the effect to activate
  40671. */
  40672. enableEffect(effect: Nullable<Effect>): void;
  40673. /**
  40674. * Set the value of an uniform to a number (int)
  40675. * @param uniform defines the webGL uniform location where to store the value
  40676. * @param value defines the int number to store
  40677. * @returns true if the value was set
  40678. */
  40679. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40680. /**
  40681. * Set the value of an uniform to a int2
  40682. * @param uniform defines the webGL uniform location where to store the value
  40683. * @param x defines the 1st component of the value
  40684. * @param y defines the 2nd component of the value
  40685. * @returns true if the value was set
  40686. */
  40687. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40688. /**
  40689. * Set the value of an uniform to a int3
  40690. * @param uniform defines the webGL uniform location where to store the value
  40691. * @param x defines the 1st component of the value
  40692. * @param y defines the 2nd component of the value
  40693. * @param z defines the 3rd component of the value
  40694. * @returns true if the value was set
  40695. */
  40696. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40697. /**
  40698. * Set the value of an uniform to a int4
  40699. * @param uniform defines the webGL uniform location where to store the value
  40700. * @param x defines the 1st component of the value
  40701. * @param y defines the 2nd component of the value
  40702. * @param z defines the 3rd component of the value
  40703. * @param w defines the 4th component of the value
  40704. * @returns true if the value was set
  40705. */
  40706. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40707. /**
  40708. * Set the value of an uniform to an array of int32
  40709. * @param uniform defines the webGL uniform location where to store the value
  40710. * @param array defines the array of int32 to store
  40711. * @returns true if the value was set
  40712. */
  40713. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40714. /**
  40715. * Set the value of an uniform to an array of int32 (stored as vec2)
  40716. * @param uniform defines the webGL uniform location where to store the value
  40717. * @param array defines the array of int32 to store
  40718. * @returns true if the value was set
  40719. */
  40720. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40721. /**
  40722. * Set the value of an uniform to an array of int32 (stored as vec3)
  40723. * @param uniform defines the webGL uniform location where to store the value
  40724. * @param array defines the array of int32 to store
  40725. * @returns true if the value was set
  40726. */
  40727. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40728. /**
  40729. * Set the value of an uniform to an array of int32 (stored as vec4)
  40730. * @param uniform defines the webGL uniform location where to store the value
  40731. * @param array defines the array of int32 to store
  40732. * @returns true if the value was set
  40733. */
  40734. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40735. /**
  40736. * Set the value of an uniform to an array of number
  40737. * @param uniform defines the webGL uniform location where to store the value
  40738. * @param array defines the array of number to store
  40739. * @returns true if the value was set
  40740. */
  40741. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40742. /**
  40743. * Set the value of an uniform to an array of number (stored as vec2)
  40744. * @param uniform defines the webGL uniform location where to store the value
  40745. * @param array defines the array of number to store
  40746. * @returns true if the value was set
  40747. */
  40748. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40749. /**
  40750. * Set the value of an uniform to an array of number (stored as vec3)
  40751. * @param uniform defines the webGL uniform location where to store the value
  40752. * @param array defines the array of number to store
  40753. * @returns true if the value was set
  40754. */
  40755. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40756. /**
  40757. * Set the value of an uniform to an array of number (stored as vec4)
  40758. * @param uniform defines the webGL uniform location where to store the value
  40759. * @param array defines the array of number to store
  40760. * @returns true if the value was set
  40761. */
  40762. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40763. /**
  40764. * Set the value of an uniform to an array of float32 (stored as matrices)
  40765. * @param uniform defines the webGL uniform location where to store the value
  40766. * @param matrices defines the array of float32 to store
  40767. * @returns true if the value was set
  40768. */
  40769. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40770. /**
  40771. * Set the value of an uniform to a matrix (3x3)
  40772. * @param uniform defines the webGL uniform location where to store the value
  40773. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40774. * @returns true if the value was set
  40775. */
  40776. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40777. /**
  40778. * Set the value of an uniform to a matrix (2x2)
  40779. * @param uniform defines the webGL uniform location where to store the value
  40780. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40781. * @returns true if the value was set
  40782. */
  40783. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40784. /**
  40785. * Set the value of an uniform to a number (float)
  40786. * @param uniform defines the webGL uniform location where to store the value
  40787. * @param value defines the float number to store
  40788. * @returns true if the value was transfered
  40789. */
  40790. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40791. /**
  40792. * Set the value of an uniform to a vec2
  40793. * @param uniform defines the webGL uniform location where to store the value
  40794. * @param x defines the 1st component of the value
  40795. * @param y defines the 2nd component of the value
  40796. * @returns true if the value was set
  40797. */
  40798. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40799. /**
  40800. * Set the value of an uniform to a vec3
  40801. * @param uniform defines the webGL uniform location where to store the value
  40802. * @param x defines the 1st component of the value
  40803. * @param y defines the 2nd component of the value
  40804. * @param z defines the 3rd component of the value
  40805. * @returns true if the value was set
  40806. */
  40807. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40808. /**
  40809. * Set the value of an uniform to a vec4
  40810. * @param uniform defines the webGL uniform location where to store the value
  40811. * @param x defines the 1st component of the value
  40812. * @param y defines the 2nd component of the value
  40813. * @param z defines the 3rd component of the value
  40814. * @param w defines the 4th component of the value
  40815. * @returns true if the value was set
  40816. */
  40817. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40818. /**
  40819. * Apply all cached states (depth, culling, stencil and alpha)
  40820. */
  40821. applyStates(): void;
  40822. /**
  40823. * Enable or disable color writing
  40824. * @param enable defines the state to set
  40825. */
  40826. setColorWrite(enable: boolean): void;
  40827. /**
  40828. * Gets a boolean indicating if color writing is enabled
  40829. * @returns the current color writing state
  40830. */
  40831. getColorWrite(): boolean;
  40832. /**
  40833. * Gets the depth culling state manager
  40834. */
  40835. get depthCullingState(): DepthCullingState;
  40836. /**
  40837. * Gets the alpha state manager
  40838. */
  40839. get alphaState(): AlphaState;
  40840. /**
  40841. * Gets the stencil state manager
  40842. */
  40843. get stencilState(): StencilState;
  40844. /**
  40845. * Clears the list of texture accessible through engine.
  40846. * This can help preventing texture load conflict due to name collision.
  40847. */
  40848. clearInternalTexturesCache(): void;
  40849. /**
  40850. * Force the entire cache to be cleared
  40851. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40852. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40853. */
  40854. wipeCaches(bruteForce?: boolean): void;
  40855. /** @hidden */
  40856. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40857. min: number;
  40858. mag: number;
  40859. };
  40860. /** @hidden */
  40861. protected _createTexture(): WebGLTexture;
  40862. /** @hidden */
  40863. _createHardwareTexture(): HardwareTextureWrapper;
  40864. 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 | {
  40865. width: number;
  40866. height: number;
  40867. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40868. width: number;
  40869. height: number;
  40870. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40871. width: number;
  40872. height: number;
  40873. }, 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;
  40874. /**
  40875. * Usually called from Texture.ts.
  40876. * Passed information to create a WebGLTexture
  40877. * @param url defines a value which contains one of the following:
  40878. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40879. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40880. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40881. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40882. * @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)
  40883. * @param scene needed for loading to the correct scene
  40884. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40885. * @param onLoad optional callback to be called upon successful completion
  40886. * @param onError optional callback to be called upon failure
  40887. * @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
  40888. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40889. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40890. * @param forcedExtension defines the extension to use to pick the right loader
  40891. * @param mimeType defines an optional mime type
  40892. * @param loaderOptions options to be passed to the loader
  40893. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40894. */
  40895. 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;
  40896. /**
  40897. * Loads an image as an HTMLImageElement.
  40898. * @param input url string, ArrayBuffer, or Blob to load
  40899. * @param onLoad callback called when the image successfully loads
  40900. * @param onError callback called when the image fails to load
  40901. * @param offlineProvider offline provider for caching
  40902. * @param mimeType optional mime type
  40903. * @returns the HTMLImageElement of the loaded image
  40904. * @hidden
  40905. */
  40906. 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>;
  40907. /**
  40908. * @hidden
  40909. */
  40910. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40911. private _unpackFlipYCached;
  40912. /**
  40913. * In case you are sharing the context with other applications, it might
  40914. * be interested to not cache the unpack flip y state to ensure a consistent
  40915. * value would be set.
  40916. */
  40917. enableUnpackFlipYCached: boolean;
  40918. /** @hidden */
  40919. _unpackFlipY(value: boolean): void;
  40920. /** @hidden */
  40921. _getUnpackAlignement(): number;
  40922. private _getTextureTarget;
  40923. /**
  40924. * Update the sampling mode of a given texture
  40925. * @param samplingMode defines the required sampling mode
  40926. * @param texture defines the texture to update
  40927. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40928. */
  40929. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40930. /**
  40931. * Update the dimensions of a texture
  40932. * @param texture texture to update
  40933. * @param width new width of the texture
  40934. * @param height new height of the texture
  40935. * @param depth new depth of the texture
  40936. */
  40937. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  40938. /**
  40939. * Update the sampling mode of a given texture
  40940. * @param texture defines the texture to update
  40941. * @param wrapU defines the texture wrap mode of the u coordinates
  40942. * @param wrapV defines the texture wrap mode of the v coordinates
  40943. * @param wrapR defines the texture wrap mode of the r coordinates
  40944. */
  40945. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40946. /** @hidden */
  40947. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40948. width: number;
  40949. height: number;
  40950. layers?: number;
  40951. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  40952. /** @hidden */
  40953. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40954. /** @hidden */
  40955. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40956. /**
  40957. * Update a portion of an internal texture
  40958. * @param texture defines the texture to update
  40959. * @param imageData defines the data to store into the texture
  40960. * @param xOffset defines the x coordinates of the update rectangle
  40961. * @param yOffset defines the y coordinates of the update rectangle
  40962. * @param width defines the width of the update rectangle
  40963. * @param height defines the height of the update rectangle
  40964. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40965. * @param lod defines the lod level to update (0 by default)
  40966. */
  40967. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40968. /** @hidden */
  40969. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40970. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40971. private _prepareWebGLTexture;
  40972. /** @hidden */
  40973. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40974. private _getDepthStencilBuffer;
  40975. /** @hidden */
  40976. _releaseFramebufferObjects(texture: InternalTexture): void;
  40977. /** @hidden */
  40978. _releaseTexture(texture: InternalTexture): void;
  40979. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40980. protected _setProgram(program: WebGLProgram): void;
  40981. protected _boundUniforms: {
  40982. [key: number]: WebGLUniformLocation;
  40983. };
  40984. /**
  40985. * Binds an effect to the webGL context
  40986. * @param effect defines the effect to bind
  40987. */
  40988. bindSamplers(effect: Effect): void;
  40989. private _activateCurrentTexture;
  40990. /** @hidden */
  40991. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40992. /** @hidden */
  40993. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  40994. /**
  40995. * Unbind all textures from the webGL context
  40996. */
  40997. unbindAllTextures(): void;
  40998. /**
  40999. * Sets a texture to the according uniform.
  41000. * @param channel The texture channel
  41001. * @param uniform The uniform to set
  41002. * @param texture The texture to apply
  41003. * @param name The name of the uniform in the effect
  41004. */
  41005. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41006. private _bindSamplerUniformToChannel;
  41007. private _getTextureWrapMode;
  41008. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41009. /**
  41010. * Sets an array of texture to the webGL context
  41011. * @param channel defines the channel where the texture array must be set
  41012. * @param uniform defines the associated uniform location
  41013. * @param textures defines the array of textures to bind
  41014. * @param name name of the channel
  41015. */
  41016. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41017. /** @hidden */
  41018. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41019. private _setTextureParameterFloat;
  41020. private _setTextureParameterInteger;
  41021. /**
  41022. * Unbind all vertex attributes from the webGL context
  41023. */
  41024. unbindAllAttributes(): void;
  41025. /**
  41026. * 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
  41027. */
  41028. releaseEffects(): void;
  41029. /**
  41030. * Dispose and release all associated resources
  41031. */
  41032. dispose(): void;
  41033. /**
  41034. * Attach a new callback raised when context lost event is fired
  41035. * @param callback defines the callback to call
  41036. */
  41037. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41038. /**
  41039. * Attach a new callback raised when context restored event is fired
  41040. * @param callback defines the callback to call
  41041. */
  41042. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41043. /**
  41044. * Get the current error code of the webGL context
  41045. * @returns the error code
  41046. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41047. */
  41048. getError(): number;
  41049. private _canRenderToFloatFramebuffer;
  41050. private _canRenderToHalfFloatFramebuffer;
  41051. private _canRenderToFramebuffer;
  41052. /** @hidden */
  41053. _getWebGLTextureType(type: number): number;
  41054. /** @hidden */
  41055. _getInternalFormat(format: number): number;
  41056. /** @hidden */
  41057. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41058. /** @hidden */
  41059. _getRGBAMultiSampleBufferFormat(type: number): number;
  41060. /** @hidden */
  41061. _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;
  41062. /**
  41063. * Loads a file from a url
  41064. * @param url url to load
  41065. * @param onSuccess callback called when the file successfully loads
  41066. * @param onProgress callback called while file is loading (if the server supports this mode)
  41067. * @param offlineProvider defines the offline provider for caching
  41068. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41069. * @param onError callback called when the file fails to load
  41070. * @returns a file request object
  41071. * @hidden
  41072. */
  41073. 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;
  41074. /**
  41075. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41076. * @param x defines the x coordinate of the rectangle where pixels must be read
  41077. * @param y defines the y coordinate of the rectangle where pixels must be read
  41078. * @param width defines the width of the rectangle where pixels must be read
  41079. * @param height defines the height of the rectangle where pixels must be read
  41080. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41081. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41082. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41083. */
  41084. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41085. private static _IsSupported;
  41086. private static _HasMajorPerformanceCaveat;
  41087. /**
  41088. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41089. */
  41090. static get IsSupported(): boolean;
  41091. /**
  41092. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41093. * @returns true if the engine can be created
  41094. * @ignorenaming
  41095. */
  41096. static isSupported(): boolean;
  41097. /**
  41098. * 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)
  41099. */
  41100. static get HasMajorPerformanceCaveat(): boolean;
  41101. /**
  41102. * Find the next highest power of two.
  41103. * @param x Number to start search from.
  41104. * @return Next highest power of two.
  41105. */
  41106. static CeilingPOT(x: number): number;
  41107. /**
  41108. * Find the next lowest power of two.
  41109. * @param x Number to start search from.
  41110. * @return Next lowest power of two.
  41111. */
  41112. static FloorPOT(x: number): number;
  41113. /**
  41114. * Find the nearest power of two.
  41115. * @param x Number to start search from.
  41116. * @return Next nearest power of two.
  41117. */
  41118. static NearestPOT(x: number): number;
  41119. /**
  41120. * Get the closest exponent of two
  41121. * @param value defines the value to approximate
  41122. * @param max defines the maximum value to return
  41123. * @param mode defines how to define the closest value
  41124. * @returns closest exponent of two of the given value
  41125. */
  41126. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41127. /**
  41128. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41129. * @param func - the function to be called
  41130. * @param requester - the object that will request the next frame. Falls back to window.
  41131. * @returns frame number
  41132. */
  41133. static QueueNewFrame(func: () => void, requester?: any): number;
  41134. /**
  41135. * Gets host document
  41136. * @returns the host document object
  41137. */
  41138. getHostDocument(): Nullable<Document>;
  41139. }
  41140. }
  41141. declare module BABYLON {
  41142. /**
  41143. * Defines the source of the internal texture
  41144. */
  41145. export enum InternalTextureSource {
  41146. /**
  41147. * The source of the texture data is unknown
  41148. */
  41149. Unknown = 0,
  41150. /**
  41151. * Texture data comes from an URL
  41152. */
  41153. Url = 1,
  41154. /**
  41155. * Texture data is only used for temporary storage
  41156. */
  41157. Temp = 2,
  41158. /**
  41159. * Texture data comes from raw data (ArrayBuffer)
  41160. */
  41161. Raw = 3,
  41162. /**
  41163. * Texture content is dynamic (video or dynamic texture)
  41164. */
  41165. Dynamic = 4,
  41166. /**
  41167. * Texture content is generated by rendering to it
  41168. */
  41169. RenderTarget = 5,
  41170. /**
  41171. * Texture content is part of a multi render target process
  41172. */
  41173. MultiRenderTarget = 6,
  41174. /**
  41175. * Texture data comes from a cube data file
  41176. */
  41177. Cube = 7,
  41178. /**
  41179. * Texture data comes from a raw cube data
  41180. */
  41181. CubeRaw = 8,
  41182. /**
  41183. * Texture data come from a prefiltered cube data file
  41184. */
  41185. CubePrefiltered = 9,
  41186. /**
  41187. * Texture content is raw 3D data
  41188. */
  41189. Raw3D = 10,
  41190. /**
  41191. * Texture content is raw 2D array data
  41192. */
  41193. Raw2DArray = 11,
  41194. /**
  41195. * Texture content is a depth texture
  41196. */
  41197. Depth = 12,
  41198. /**
  41199. * Texture data comes from a raw cube data encoded with RGBD
  41200. */
  41201. CubeRawRGBD = 13
  41202. }
  41203. /**
  41204. * Class used to store data associated with WebGL texture data for the engine
  41205. * This class should not be used directly
  41206. */
  41207. export class InternalTexture {
  41208. /** @hidden */
  41209. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41210. /**
  41211. * Defines if the texture is ready
  41212. */
  41213. isReady: boolean;
  41214. /**
  41215. * Defines if the texture is a cube texture
  41216. */
  41217. isCube: boolean;
  41218. /**
  41219. * Defines if the texture contains 3D data
  41220. */
  41221. is3D: boolean;
  41222. /**
  41223. * Defines if the texture contains 2D array data
  41224. */
  41225. is2DArray: boolean;
  41226. /**
  41227. * Defines if the texture contains multiview data
  41228. */
  41229. isMultiview: boolean;
  41230. /**
  41231. * Gets the URL used to load this texture
  41232. */
  41233. url: string;
  41234. /** @hidden */
  41235. _originalUrl: string;
  41236. /**
  41237. * Gets the sampling mode of the texture
  41238. */
  41239. samplingMode: number;
  41240. /**
  41241. * Gets a boolean indicating if the texture needs mipmaps generation
  41242. */
  41243. generateMipMaps: boolean;
  41244. /**
  41245. * Gets the number of samples used by the texture (WebGL2+ only)
  41246. */
  41247. samples: number;
  41248. /**
  41249. * Gets the type of the texture (int, float...)
  41250. */
  41251. type: number;
  41252. /**
  41253. * Gets the format of the texture (RGB, RGBA...)
  41254. */
  41255. format: number;
  41256. /**
  41257. * Observable called when the texture is loaded
  41258. */
  41259. onLoadedObservable: Observable<InternalTexture>;
  41260. /**
  41261. * Gets the width of the texture
  41262. */
  41263. width: number;
  41264. /**
  41265. * Gets the height of the texture
  41266. */
  41267. height: number;
  41268. /**
  41269. * Gets the depth of the texture
  41270. */
  41271. depth: number;
  41272. /**
  41273. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41274. */
  41275. baseWidth: number;
  41276. /**
  41277. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41278. */
  41279. baseHeight: number;
  41280. /**
  41281. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41282. */
  41283. baseDepth: number;
  41284. /**
  41285. * Gets a boolean indicating if the texture is inverted on Y axis
  41286. */
  41287. invertY: boolean;
  41288. /** @hidden */
  41289. _invertVScale: boolean;
  41290. /** @hidden */
  41291. _associatedChannel: number;
  41292. /** @hidden */
  41293. _source: InternalTextureSource;
  41294. /** @hidden */
  41295. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41296. /** @hidden */
  41297. _bufferView: Nullable<ArrayBufferView>;
  41298. /** @hidden */
  41299. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41300. /** @hidden */
  41301. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41302. /** @hidden */
  41303. _size: number;
  41304. /** @hidden */
  41305. _extension: string;
  41306. /** @hidden */
  41307. _files: Nullable<string[]>;
  41308. /** @hidden */
  41309. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41310. /** @hidden */
  41311. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41312. /** @hidden */
  41313. _framebuffer: Nullable<WebGLFramebuffer>;
  41314. /** @hidden */
  41315. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41316. /** @hidden */
  41317. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41318. /** @hidden */
  41319. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41320. /** @hidden */
  41321. _attachments: Nullable<number[]>;
  41322. /** @hidden */
  41323. _textureArray: Nullable<InternalTexture[]>;
  41324. /** @hidden */
  41325. _cachedCoordinatesMode: Nullable<number>;
  41326. /** @hidden */
  41327. _cachedWrapU: Nullable<number>;
  41328. /** @hidden */
  41329. _cachedWrapV: Nullable<number>;
  41330. /** @hidden */
  41331. _cachedWrapR: Nullable<number>;
  41332. /** @hidden */
  41333. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41334. /** @hidden */
  41335. _isDisabled: boolean;
  41336. /** @hidden */
  41337. _compression: Nullable<string>;
  41338. /** @hidden */
  41339. _generateStencilBuffer: boolean;
  41340. /** @hidden */
  41341. _generateDepthBuffer: boolean;
  41342. /** @hidden */
  41343. _comparisonFunction: number;
  41344. /** @hidden */
  41345. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41346. /** @hidden */
  41347. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41348. /** @hidden */
  41349. _sphericalPolynomialComputed: boolean;
  41350. /** @hidden */
  41351. _lodGenerationScale: number;
  41352. /** @hidden */
  41353. _lodGenerationOffset: number;
  41354. /** @hidden */
  41355. _depthStencilTexture: Nullable<InternalTexture>;
  41356. /** @hidden */
  41357. _colorTextureArray: Nullable<WebGLTexture>;
  41358. /** @hidden */
  41359. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41360. /** @hidden */
  41361. _lodTextureHigh: Nullable<BaseTexture>;
  41362. /** @hidden */
  41363. _lodTextureMid: Nullable<BaseTexture>;
  41364. /** @hidden */
  41365. _lodTextureLow: Nullable<BaseTexture>;
  41366. /** @hidden */
  41367. _isRGBD: boolean;
  41368. /** @hidden */
  41369. _linearSpecularLOD: boolean;
  41370. /** @hidden */
  41371. _irradianceTexture: Nullable<BaseTexture>;
  41372. /** @hidden */
  41373. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41374. /** @hidden */
  41375. _references: number;
  41376. /** @hidden */
  41377. _gammaSpace: Nullable<boolean>;
  41378. private _engine;
  41379. private _uniqueId;
  41380. private static _Counter;
  41381. /** Gets the unique id of the internal texture */
  41382. get uniqueId(): number;
  41383. /**
  41384. * Gets the Engine the texture belongs to.
  41385. * @returns The babylon engine
  41386. */
  41387. getEngine(): ThinEngine;
  41388. /**
  41389. * Gets the data source type of the texture
  41390. */
  41391. get source(): InternalTextureSource;
  41392. /**
  41393. * Creates a new InternalTexture
  41394. * @param engine defines the engine to use
  41395. * @param source defines the type of data that will be used
  41396. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41397. */
  41398. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41399. /**
  41400. * Increments the number of references (ie. the number of Texture that point to it)
  41401. */
  41402. incrementReferences(): void;
  41403. /**
  41404. * Change the size of the texture (not the size of the content)
  41405. * @param width defines the new width
  41406. * @param height defines the new height
  41407. * @param depth defines the new depth (1 by default)
  41408. */
  41409. updateSize(width: int, height: int, depth?: int): void;
  41410. /** @hidden */
  41411. _rebuild(): void;
  41412. /** @hidden */
  41413. _swapAndDie(target: InternalTexture): void;
  41414. /**
  41415. * Dispose the current allocated resources
  41416. */
  41417. dispose(): void;
  41418. }
  41419. }
  41420. declare module BABYLON {
  41421. /**
  41422. * Interface used to present a loading screen while loading a scene
  41423. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41424. */
  41425. export interface ILoadingScreen {
  41426. /**
  41427. * Function called to display the loading screen
  41428. */
  41429. displayLoadingUI: () => void;
  41430. /**
  41431. * Function called to hide the loading screen
  41432. */
  41433. hideLoadingUI: () => void;
  41434. /**
  41435. * Gets or sets the color to use for the background
  41436. */
  41437. loadingUIBackgroundColor: string;
  41438. /**
  41439. * Gets or sets the text to display while loading
  41440. */
  41441. loadingUIText: string;
  41442. }
  41443. /**
  41444. * Class used for the default loading screen
  41445. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41446. */
  41447. export class DefaultLoadingScreen implements ILoadingScreen {
  41448. private _renderingCanvas;
  41449. private _loadingText;
  41450. private _loadingDivBackgroundColor;
  41451. private _loadingDiv;
  41452. private _loadingTextDiv;
  41453. /** Gets or sets the logo url to use for the default loading screen */
  41454. static DefaultLogoUrl: string;
  41455. /** Gets or sets the spinner url to use for the default loading screen */
  41456. static DefaultSpinnerUrl: string;
  41457. /**
  41458. * Creates a new default loading screen
  41459. * @param _renderingCanvas defines the canvas used to render the scene
  41460. * @param _loadingText defines the default text to display
  41461. * @param _loadingDivBackgroundColor defines the default background color
  41462. */
  41463. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41464. /**
  41465. * Function called to display the loading screen
  41466. */
  41467. displayLoadingUI(): void;
  41468. /**
  41469. * Function called to hide the loading screen
  41470. */
  41471. hideLoadingUI(): void;
  41472. /**
  41473. * Gets or sets the text to display while loading
  41474. */
  41475. set loadingUIText(text: string);
  41476. get loadingUIText(): string;
  41477. /**
  41478. * Gets or sets the color to use for the background
  41479. */
  41480. get loadingUIBackgroundColor(): string;
  41481. set loadingUIBackgroundColor(color: string);
  41482. private _resizeLoadingUI;
  41483. }
  41484. }
  41485. declare module BABYLON {
  41486. /**
  41487. * Interface for any object that can request an animation frame
  41488. */
  41489. export interface ICustomAnimationFrameRequester {
  41490. /**
  41491. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41492. */
  41493. renderFunction?: Function;
  41494. /**
  41495. * Called to request the next frame to render to
  41496. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41497. */
  41498. requestAnimationFrame: Function;
  41499. /**
  41500. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41501. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41502. */
  41503. requestID?: number;
  41504. }
  41505. }
  41506. declare module BABYLON {
  41507. /**
  41508. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41509. */
  41510. export class PerformanceMonitor {
  41511. private _enabled;
  41512. private _rollingFrameTime;
  41513. private _lastFrameTimeMs;
  41514. /**
  41515. * constructor
  41516. * @param frameSampleSize The number of samples required to saturate the sliding window
  41517. */
  41518. constructor(frameSampleSize?: number);
  41519. /**
  41520. * Samples current frame
  41521. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41522. */
  41523. sampleFrame(timeMs?: number): void;
  41524. /**
  41525. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41526. */
  41527. get averageFrameTime(): number;
  41528. /**
  41529. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41530. */
  41531. get averageFrameTimeVariance(): number;
  41532. /**
  41533. * Returns the frame time of the most recent frame
  41534. */
  41535. get instantaneousFrameTime(): number;
  41536. /**
  41537. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41538. */
  41539. get averageFPS(): number;
  41540. /**
  41541. * Returns the average framerate in frames per second using the most recent frame time
  41542. */
  41543. get instantaneousFPS(): number;
  41544. /**
  41545. * Returns true if enough samples have been taken to completely fill the sliding window
  41546. */
  41547. get isSaturated(): boolean;
  41548. /**
  41549. * Enables contributions to the sliding window sample set
  41550. */
  41551. enable(): void;
  41552. /**
  41553. * Disables contributions to the sliding window sample set
  41554. * Samples will not be interpolated over the disabled period
  41555. */
  41556. disable(): void;
  41557. /**
  41558. * Returns true if sampling is enabled
  41559. */
  41560. get isEnabled(): boolean;
  41561. /**
  41562. * Resets performance monitor
  41563. */
  41564. reset(): void;
  41565. }
  41566. /**
  41567. * RollingAverage
  41568. *
  41569. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41570. */
  41571. export class RollingAverage {
  41572. /**
  41573. * Current average
  41574. */
  41575. average: number;
  41576. /**
  41577. * Current variance
  41578. */
  41579. variance: number;
  41580. protected _samples: Array<number>;
  41581. protected _sampleCount: number;
  41582. protected _pos: number;
  41583. protected _m2: number;
  41584. /**
  41585. * constructor
  41586. * @param length The number of samples required to saturate the sliding window
  41587. */
  41588. constructor(length: number);
  41589. /**
  41590. * Adds a sample to the sample set
  41591. * @param v The sample value
  41592. */
  41593. add(v: number): void;
  41594. /**
  41595. * Returns previously added values or null if outside of history or outside the sliding window domain
  41596. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41597. * @return Value previously recorded with add() or null if outside of range
  41598. */
  41599. history(i: number): number;
  41600. /**
  41601. * Returns true if enough samples have been taken to completely fill the sliding window
  41602. * @return true if sample-set saturated
  41603. */
  41604. isSaturated(): boolean;
  41605. /**
  41606. * Resets the rolling average (equivalent to 0 samples taken so far)
  41607. */
  41608. reset(): void;
  41609. /**
  41610. * Wraps a value around the sample range boundaries
  41611. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41612. * @return Wrapped position in sample range
  41613. */
  41614. protected _wrapPosition(i: number): number;
  41615. }
  41616. }
  41617. declare module BABYLON {
  41618. /**
  41619. * This class is used to track a performance counter which is number based.
  41620. * The user has access to many properties which give statistics of different nature.
  41621. *
  41622. * The implementer can track two kinds of Performance Counter: time and count.
  41623. * 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.
  41624. * 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.
  41625. */
  41626. export class PerfCounter {
  41627. /**
  41628. * Gets or sets a global boolean to turn on and off all the counters
  41629. */
  41630. static Enabled: boolean;
  41631. /**
  41632. * Returns the smallest value ever
  41633. */
  41634. get min(): number;
  41635. /**
  41636. * Returns the biggest value ever
  41637. */
  41638. get max(): number;
  41639. /**
  41640. * Returns the average value since the performance counter is running
  41641. */
  41642. get average(): number;
  41643. /**
  41644. * Returns the average value of the last second the counter was monitored
  41645. */
  41646. get lastSecAverage(): number;
  41647. /**
  41648. * Returns the current value
  41649. */
  41650. get current(): number;
  41651. /**
  41652. * Gets the accumulated total
  41653. */
  41654. get total(): number;
  41655. /**
  41656. * Gets the total value count
  41657. */
  41658. get count(): number;
  41659. /**
  41660. * Creates a new counter
  41661. */
  41662. constructor();
  41663. /**
  41664. * Call this method to start monitoring a new frame.
  41665. * 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.
  41666. */
  41667. fetchNewFrame(): void;
  41668. /**
  41669. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41670. * @param newCount the count value to add to the monitored count
  41671. * @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.
  41672. */
  41673. addCount(newCount: number, fetchResult: boolean): void;
  41674. /**
  41675. * Start monitoring this performance counter
  41676. */
  41677. beginMonitoring(): void;
  41678. /**
  41679. * Compute the time lapsed since the previous beginMonitoring() call.
  41680. * @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
  41681. */
  41682. endMonitoring(newFrame?: boolean): void;
  41683. private _fetchResult;
  41684. private _startMonitoringTime;
  41685. private _min;
  41686. private _max;
  41687. private _average;
  41688. private _current;
  41689. private _totalValueCount;
  41690. private _totalAccumulated;
  41691. private _lastSecAverage;
  41692. private _lastSecAccumulated;
  41693. private _lastSecTime;
  41694. private _lastSecValueCount;
  41695. }
  41696. }
  41697. declare module BABYLON {
  41698. interface ThinEngine {
  41699. /** @hidden */
  41700. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41701. }
  41702. }
  41703. declare module BABYLON {
  41704. /**
  41705. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41706. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41707. */
  41708. export class Analyser {
  41709. /**
  41710. * Gets or sets the smoothing
  41711. * @ignorenaming
  41712. */
  41713. SMOOTHING: number;
  41714. /**
  41715. * Gets or sets the FFT table size
  41716. * @ignorenaming
  41717. */
  41718. FFT_SIZE: number;
  41719. /**
  41720. * Gets or sets the bar graph amplitude
  41721. * @ignorenaming
  41722. */
  41723. BARGRAPHAMPLITUDE: number;
  41724. /**
  41725. * Gets or sets the position of the debug canvas
  41726. * @ignorenaming
  41727. */
  41728. DEBUGCANVASPOS: {
  41729. x: number;
  41730. y: number;
  41731. };
  41732. /**
  41733. * Gets or sets the debug canvas size
  41734. * @ignorenaming
  41735. */
  41736. DEBUGCANVASSIZE: {
  41737. width: number;
  41738. height: number;
  41739. };
  41740. private _byteFreqs;
  41741. private _byteTime;
  41742. private _floatFreqs;
  41743. private _webAudioAnalyser;
  41744. private _debugCanvas;
  41745. private _debugCanvasContext;
  41746. private _scene;
  41747. private _registerFunc;
  41748. private _audioEngine;
  41749. /**
  41750. * Creates a new analyser
  41751. * @param scene defines hosting scene
  41752. */
  41753. constructor(scene: Scene);
  41754. /**
  41755. * Get the number of data values you will have to play with for the visualization
  41756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41757. * @returns a number
  41758. */
  41759. getFrequencyBinCount(): number;
  41760. /**
  41761. * Gets the current frequency data as a byte array
  41762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41763. * @returns a Uint8Array
  41764. */
  41765. getByteFrequencyData(): Uint8Array;
  41766. /**
  41767. * Gets the current waveform as a byte array
  41768. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41769. * @returns a Uint8Array
  41770. */
  41771. getByteTimeDomainData(): Uint8Array;
  41772. /**
  41773. * Gets the current frequency data as a float array
  41774. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41775. * @returns a Float32Array
  41776. */
  41777. getFloatFrequencyData(): Float32Array;
  41778. /**
  41779. * Renders the debug canvas
  41780. */
  41781. drawDebugCanvas(): void;
  41782. /**
  41783. * Stops rendering the debug canvas and removes it
  41784. */
  41785. stopDebugCanvas(): void;
  41786. /**
  41787. * Connects two audio nodes
  41788. * @param inputAudioNode defines first node to connect
  41789. * @param outputAudioNode defines second node to connect
  41790. */
  41791. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41792. /**
  41793. * Releases all associated resources
  41794. */
  41795. dispose(): void;
  41796. }
  41797. }
  41798. declare module BABYLON {
  41799. /**
  41800. * This represents an audio engine and it is responsible
  41801. * to play, synchronize and analyse sounds throughout the application.
  41802. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41803. */
  41804. export interface IAudioEngine extends IDisposable {
  41805. /**
  41806. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41807. */
  41808. readonly canUseWebAudio: boolean;
  41809. /**
  41810. * Gets the current AudioContext if available.
  41811. */
  41812. readonly audioContext: Nullable<AudioContext>;
  41813. /**
  41814. * The master gain node defines the global audio volume of your audio engine.
  41815. */
  41816. readonly masterGain: GainNode;
  41817. /**
  41818. * Gets whether or not mp3 are supported by your browser.
  41819. */
  41820. readonly isMP3supported: boolean;
  41821. /**
  41822. * Gets whether or not ogg are supported by your browser.
  41823. */
  41824. readonly isOGGsupported: boolean;
  41825. /**
  41826. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41827. * @ignoreNaming
  41828. */
  41829. WarnedWebAudioUnsupported: boolean;
  41830. /**
  41831. * Defines if the audio engine relies on a custom unlocked button.
  41832. * In this case, the embedded button will not be displayed.
  41833. */
  41834. useCustomUnlockedButton: boolean;
  41835. /**
  41836. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41837. */
  41838. readonly unlocked: boolean;
  41839. /**
  41840. * Event raised when audio has been unlocked on the browser.
  41841. */
  41842. onAudioUnlockedObservable: Observable<IAudioEngine>;
  41843. /**
  41844. * Event raised when audio has been locked on the browser.
  41845. */
  41846. onAudioLockedObservable: Observable<IAudioEngine>;
  41847. /**
  41848. * Flags the audio engine in Locked state.
  41849. * This happens due to new browser policies preventing audio to autoplay.
  41850. */
  41851. lock(): void;
  41852. /**
  41853. * Unlocks the audio engine once a user action has been done on the dom.
  41854. * This is helpful to resume play once browser policies have been satisfied.
  41855. */
  41856. unlock(): void;
  41857. /**
  41858. * Gets the global volume sets on the master gain.
  41859. * @returns the global volume if set or -1 otherwise
  41860. */
  41861. getGlobalVolume(): number;
  41862. /**
  41863. * Sets the global volume of your experience (sets on the master gain).
  41864. * @param newVolume Defines the new global volume of the application
  41865. */
  41866. setGlobalVolume(newVolume: number): void;
  41867. /**
  41868. * Connect the audio engine to an audio analyser allowing some amazing
  41869. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41870. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41871. * @param analyser The analyser to connect to the engine
  41872. */
  41873. connectToAnalyser(analyser: Analyser): void;
  41874. }
  41875. }
  41876. declare module BABYLON {
  41877. /**
  41878. * Defines the interface used by display changed events
  41879. */
  41880. export interface IDisplayChangedEventArgs {
  41881. /** Gets the vrDisplay object (if any) */
  41882. vrDisplay: Nullable<any>;
  41883. /** Gets a boolean indicating if webVR is supported */
  41884. vrSupported: boolean;
  41885. }
  41886. /**
  41887. * Defines the interface used by objects containing a viewport (like a camera)
  41888. */
  41889. interface IViewportOwnerLike {
  41890. /**
  41891. * Gets or sets the viewport
  41892. */
  41893. viewport: IViewportLike;
  41894. }
  41895. /**
  41896. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41897. */
  41898. export class Engine extends ThinEngine {
  41899. /** Defines that alpha blending is disabled */
  41900. static readonly ALPHA_DISABLE: number;
  41901. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41902. static readonly ALPHA_ADD: number;
  41903. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41904. static readonly ALPHA_COMBINE: number;
  41905. /** Defines that alpha blending to DEST - SRC * DEST */
  41906. static readonly ALPHA_SUBTRACT: number;
  41907. /** Defines that alpha blending to SRC * DEST */
  41908. static readonly ALPHA_MULTIPLY: number;
  41909. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41910. static readonly ALPHA_MAXIMIZED: number;
  41911. /** Defines that alpha blending to SRC + DEST */
  41912. static readonly ALPHA_ONEONE: number;
  41913. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41914. static readonly ALPHA_PREMULTIPLIED: number;
  41915. /**
  41916. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41917. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41918. */
  41919. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41920. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41921. static readonly ALPHA_INTERPOLATE: number;
  41922. /**
  41923. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41924. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41925. */
  41926. static readonly ALPHA_SCREENMODE: number;
  41927. /** Defines that the ressource is not delayed*/
  41928. static readonly DELAYLOADSTATE_NONE: number;
  41929. /** Defines that the ressource was successfully delay loaded */
  41930. static readonly DELAYLOADSTATE_LOADED: number;
  41931. /** Defines that the ressource is currently delay loading */
  41932. static readonly DELAYLOADSTATE_LOADING: number;
  41933. /** Defines that the ressource is delayed and has not started loading */
  41934. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41935. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41936. static readonly NEVER: number;
  41937. /** 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 */
  41938. static readonly ALWAYS: number;
  41939. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41940. static readonly LESS: number;
  41941. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41942. static readonly EQUAL: number;
  41943. /** 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 */
  41944. static readonly LEQUAL: number;
  41945. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41946. static readonly GREATER: number;
  41947. /** 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 */
  41948. static readonly GEQUAL: number;
  41949. /** 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 */
  41950. static readonly NOTEQUAL: number;
  41951. /** Passed to stencilOperation to specify that stencil value must be kept */
  41952. static readonly KEEP: number;
  41953. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41954. static readonly REPLACE: number;
  41955. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41956. static readonly INCR: number;
  41957. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41958. static readonly DECR: number;
  41959. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41960. static readonly INVERT: number;
  41961. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41962. static readonly INCR_WRAP: number;
  41963. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41964. static readonly DECR_WRAP: number;
  41965. /** Texture is not repeating outside of 0..1 UVs */
  41966. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41967. /** Texture is repeating outside of 0..1 UVs */
  41968. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41969. /** Texture is repeating and mirrored */
  41970. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41971. /** ALPHA */
  41972. static readonly TEXTUREFORMAT_ALPHA: number;
  41973. /** LUMINANCE */
  41974. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41975. /** LUMINANCE_ALPHA */
  41976. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41977. /** RGB */
  41978. static readonly TEXTUREFORMAT_RGB: number;
  41979. /** RGBA */
  41980. static readonly TEXTUREFORMAT_RGBA: number;
  41981. /** RED */
  41982. static readonly TEXTUREFORMAT_RED: number;
  41983. /** RED (2nd reference) */
  41984. static readonly TEXTUREFORMAT_R: number;
  41985. /** RG */
  41986. static readonly TEXTUREFORMAT_RG: number;
  41987. /** RED_INTEGER */
  41988. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41989. /** RED_INTEGER (2nd reference) */
  41990. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41991. /** RG_INTEGER */
  41992. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41993. /** RGB_INTEGER */
  41994. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41995. /** RGBA_INTEGER */
  41996. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41997. /** UNSIGNED_BYTE */
  41998. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41999. /** UNSIGNED_BYTE (2nd reference) */
  42000. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42001. /** FLOAT */
  42002. static readonly TEXTURETYPE_FLOAT: number;
  42003. /** HALF_FLOAT */
  42004. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42005. /** BYTE */
  42006. static readonly TEXTURETYPE_BYTE: number;
  42007. /** SHORT */
  42008. static readonly TEXTURETYPE_SHORT: number;
  42009. /** UNSIGNED_SHORT */
  42010. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42011. /** INT */
  42012. static readonly TEXTURETYPE_INT: number;
  42013. /** UNSIGNED_INT */
  42014. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42015. /** UNSIGNED_SHORT_4_4_4_4 */
  42016. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42017. /** UNSIGNED_SHORT_5_5_5_1 */
  42018. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42019. /** UNSIGNED_SHORT_5_6_5 */
  42020. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42021. /** UNSIGNED_INT_2_10_10_10_REV */
  42022. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42023. /** UNSIGNED_INT_24_8 */
  42024. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42025. /** UNSIGNED_INT_10F_11F_11F_REV */
  42026. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42027. /** UNSIGNED_INT_5_9_9_9_REV */
  42028. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42029. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42030. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42031. /** nearest is mag = nearest and min = nearest and mip = none */
  42032. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42033. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42034. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42035. /** Trilinear is mag = linear and min = linear and mip = linear */
  42036. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42037. /** nearest is mag = nearest and min = nearest and mip = linear */
  42038. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42039. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42040. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42041. /** Trilinear is mag = linear and min = linear and mip = linear */
  42042. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42043. /** mag = nearest and min = nearest and mip = nearest */
  42044. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42045. /** mag = nearest and min = linear and mip = nearest */
  42046. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42047. /** mag = nearest and min = linear and mip = linear */
  42048. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42049. /** mag = nearest and min = linear and mip = none */
  42050. static readonly TEXTURE_NEAREST_LINEAR: number;
  42051. /** mag = nearest and min = nearest and mip = none */
  42052. static readonly TEXTURE_NEAREST_NEAREST: number;
  42053. /** mag = linear and min = nearest and mip = nearest */
  42054. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42055. /** mag = linear and min = nearest and mip = linear */
  42056. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42057. /** mag = linear and min = linear and mip = none */
  42058. static readonly TEXTURE_LINEAR_LINEAR: number;
  42059. /** mag = linear and min = nearest and mip = none */
  42060. static readonly TEXTURE_LINEAR_NEAREST: number;
  42061. /** Explicit coordinates mode */
  42062. static readonly TEXTURE_EXPLICIT_MODE: number;
  42063. /** Spherical coordinates mode */
  42064. static readonly TEXTURE_SPHERICAL_MODE: number;
  42065. /** Planar coordinates mode */
  42066. static readonly TEXTURE_PLANAR_MODE: number;
  42067. /** Cubic coordinates mode */
  42068. static readonly TEXTURE_CUBIC_MODE: number;
  42069. /** Projection coordinates mode */
  42070. static readonly TEXTURE_PROJECTION_MODE: number;
  42071. /** Skybox coordinates mode */
  42072. static readonly TEXTURE_SKYBOX_MODE: number;
  42073. /** Inverse Cubic coordinates mode */
  42074. static readonly TEXTURE_INVCUBIC_MODE: number;
  42075. /** Equirectangular coordinates mode */
  42076. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42077. /** Equirectangular Fixed coordinates mode */
  42078. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42079. /** Equirectangular Fixed Mirrored coordinates mode */
  42080. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42081. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42082. static readonly SCALEMODE_FLOOR: number;
  42083. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42084. static readonly SCALEMODE_NEAREST: number;
  42085. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42086. static readonly SCALEMODE_CEILING: number;
  42087. /**
  42088. * Returns the current npm package of the sdk
  42089. */
  42090. static get NpmPackage(): string;
  42091. /**
  42092. * Returns the current version of the framework
  42093. */
  42094. static get Version(): string;
  42095. /** Gets the list of created engines */
  42096. static get Instances(): Engine[];
  42097. /**
  42098. * Gets the latest created engine
  42099. */
  42100. static get LastCreatedEngine(): Nullable<Engine>;
  42101. /**
  42102. * Gets the latest created scene
  42103. */
  42104. static get LastCreatedScene(): Nullable<Scene>;
  42105. /**
  42106. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42107. * @param flag defines which part of the materials must be marked as dirty
  42108. * @param predicate defines a predicate used to filter which materials should be affected
  42109. */
  42110. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42111. /**
  42112. * Method called to create the default loading screen.
  42113. * This can be overriden in your own app.
  42114. * @param canvas The rendering canvas element
  42115. * @returns The loading screen
  42116. */
  42117. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42118. /**
  42119. * Method called to create the default rescale post process on each engine.
  42120. */
  42121. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42122. /**
  42123. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42124. **/
  42125. enableOfflineSupport: boolean;
  42126. /**
  42127. * 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)
  42128. **/
  42129. disableManifestCheck: boolean;
  42130. /**
  42131. * Gets the list of created scenes
  42132. */
  42133. scenes: Scene[];
  42134. /**
  42135. * Event raised when a new scene is created
  42136. */
  42137. onNewSceneAddedObservable: Observable<Scene>;
  42138. /**
  42139. * Gets the list of created postprocesses
  42140. */
  42141. postProcesses: PostProcess[];
  42142. /**
  42143. * Gets a boolean indicating if the pointer is currently locked
  42144. */
  42145. isPointerLock: boolean;
  42146. /**
  42147. * Observable event triggered each time the rendering canvas is resized
  42148. */
  42149. onResizeObservable: Observable<Engine>;
  42150. /**
  42151. * Observable event triggered each time the canvas loses focus
  42152. */
  42153. onCanvasBlurObservable: Observable<Engine>;
  42154. /**
  42155. * Observable event triggered each time the canvas gains focus
  42156. */
  42157. onCanvasFocusObservable: Observable<Engine>;
  42158. /**
  42159. * Observable event triggered each time the canvas receives pointerout event
  42160. */
  42161. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42162. /**
  42163. * Observable raised when the engine begins a new frame
  42164. */
  42165. onBeginFrameObservable: Observable<Engine>;
  42166. /**
  42167. * If set, will be used to request the next animation frame for the render loop
  42168. */
  42169. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42170. /**
  42171. * Observable raised when the engine ends the current frame
  42172. */
  42173. onEndFrameObservable: Observable<Engine>;
  42174. /**
  42175. * Observable raised when the engine is about to compile a shader
  42176. */
  42177. onBeforeShaderCompilationObservable: Observable<Engine>;
  42178. /**
  42179. * Observable raised when the engine has jsut compiled a shader
  42180. */
  42181. onAfterShaderCompilationObservable: Observable<Engine>;
  42182. /**
  42183. * Gets the audio engine
  42184. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42185. * @ignorenaming
  42186. */
  42187. static audioEngine: IAudioEngine;
  42188. /**
  42189. * Default AudioEngine factory responsible of creating the Audio Engine.
  42190. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42191. */
  42192. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42193. /**
  42194. * Default offline support factory responsible of creating a tool used to store data locally.
  42195. * By default, this will create a Database object if the workload has been embedded.
  42196. */
  42197. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42198. private _loadingScreen;
  42199. private _pointerLockRequested;
  42200. private _rescalePostProcess;
  42201. protected _deterministicLockstep: boolean;
  42202. protected _lockstepMaxSteps: number;
  42203. protected _timeStep: number;
  42204. protected get _supportsHardwareTextureRescaling(): boolean;
  42205. private _fps;
  42206. private _deltaTime;
  42207. /** @hidden */
  42208. _drawCalls: PerfCounter;
  42209. /** 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 */
  42210. canvasTabIndex: number;
  42211. /**
  42212. * Turn this value on if you want to pause FPS computation when in background
  42213. */
  42214. disablePerformanceMonitorInBackground: boolean;
  42215. private _performanceMonitor;
  42216. /**
  42217. * Gets the performance monitor attached to this engine
  42218. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42219. */
  42220. get performanceMonitor(): PerformanceMonitor;
  42221. private _onFocus;
  42222. private _onBlur;
  42223. private _onCanvasPointerOut;
  42224. private _onCanvasBlur;
  42225. private _onCanvasFocus;
  42226. private _onFullscreenChange;
  42227. private _onPointerLockChange;
  42228. /**
  42229. * Gets the HTML element used to attach event listeners
  42230. * @returns a HTML element
  42231. */
  42232. getInputElement(): Nullable<HTMLElement>;
  42233. /**
  42234. * Creates a new engine
  42235. * @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
  42236. * @param antialias defines enable antialiasing (default: false)
  42237. * @param options defines further options to be sent to the getContext() function
  42238. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42239. */
  42240. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42241. /**
  42242. * Shared initialization across engines types.
  42243. * @param canvas The canvas associated with this instance of the engine.
  42244. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42245. * @param audioEngine Defines if an audio engine should be created by default
  42246. */
  42247. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42248. /**
  42249. * Gets current aspect ratio
  42250. * @param viewportOwner defines the camera to use to get the aspect ratio
  42251. * @param useScreen defines if screen size must be used (or the current render target if any)
  42252. * @returns a number defining the aspect ratio
  42253. */
  42254. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42255. /**
  42256. * Gets current screen aspect ratio
  42257. * @returns a number defining the aspect ratio
  42258. */
  42259. getScreenAspectRatio(): number;
  42260. /**
  42261. * Gets the client rect of the HTML canvas attached with the current webGL context
  42262. * @returns a client rectanglee
  42263. */
  42264. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42265. /**
  42266. * Gets the client rect of the HTML element used for events
  42267. * @returns a client rectanglee
  42268. */
  42269. getInputElementClientRect(): Nullable<ClientRect>;
  42270. /**
  42271. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42272. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42273. * @returns true if engine is in deterministic lock step mode
  42274. */
  42275. isDeterministicLockStep(): boolean;
  42276. /**
  42277. * Gets the max steps when engine is running in deterministic lock step
  42278. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42279. * @returns the max steps
  42280. */
  42281. getLockstepMaxSteps(): number;
  42282. /**
  42283. * Returns the time in ms between steps when using deterministic lock step.
  42284. * @returns time step in (ms)
  42285. */
  42286. getTimeStep(): number;
  42287. /**
  42288. * Force the mipmap generation for the given render target texture
  42289. * @param texture defines the render target texture to use
  42290. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42291. */
  42292. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42293. /** States */
  42294. /**
  42295. * Set various states to the webGL context
  42296. * @param culling defines backface culling state
  42297. * @param zOffset defines the value to apply to zOffset (0 by default)
  42298. * @param force defines if states must be applied even if cache is up to date
  42299. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42300. */
  42301. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42302. /**
  42303. * Set the z offset to apply to current rendering
  42304. * @param value defines the offset to apply
  42305. */
  42306. setZOffset(value: number): void;
  42307. /**
  42308. * Gets the current value of the zOffset
  42309. * @returns the current zOffset state
  42310. */
  42311. getZOffset(): number;
  42312. /**
  42313. * Gets a boolean indicating if depth testing is enabled
  42314. * @returns the current state
  42315. */
  42316. getDepthBuffer(): boolean;
  42317. /**
  42318. * Enable or disable depth buffering
  42319. * @param enable defines the state to set
  42320. */
  42321. setDepthBuffer(enable: boolean): void;
  42322. /**
  42323. * Gets a boolean indicating if depth writing is enabled
  42324. * @returns the current depth writing state
  42325. */
  42326. getDepthWrite(): boolean;
  42327. /**
  42328. * Enable or disable depth writing
  42329. * @param enable defines the state to set
  42330. */
  42331. setDepthWrite(enable: boolean): void;
  42332. /**
  42333. * Gets a boolean indicating if stencil buffer is enabled
  42334. * @returns the current stencil buffer state
  42335. */
  42336. getStencilBuffer(): boolean;
  42337. /**
  42338. * Enable or disable the stencil buffer
  42339. * @param enable defines if the stencil buffer must be enabled or disabled
  42340. */
  42341. setStencilBuffer(enable: boolean): void;
  42342. /**
  42343. * Gets the current stencil mask
  42344. * @returns a number defining the new stencil mask to use
  42345. */
  42346. getStencilMask(): number;
  42347. /**
  42348. * Sets the current stencil mask
  42349. * @param mask defines the new stencil mask to use
  42350. */
  42351. setStencilMask(mask: number): void;
  42352. /**
  42353. * Gets the current stencil function
  42354. * @returns a number defining the stencil function to use
  42355. */
  42356. getStencilFunction(): number;
  42357. /**
  42358. * Gets the current stencil reference value
  42359. * @returns a number defining the stencil reference value to use
  42360. */
  42361. getStencilFunctionReference(): number;
  42362. /**
  42363. * Gets the current stencil mask
  42364. * @returns a number defining the stencil mask to use
  42365. */
  42366. getStencilFunctionMask(): number;
  42367. /**
  42368. * Sets the current stencil function
  42369. * @param stencilFunc defines the new stencil function to use
  42370. */
  42371. setStencilFunction(stencilFunc: number): void;
  42372. /**
  42373. * Sets the current stencil reference
  42374. * @param reference defines the new stencil reference to use
  42375. */
  42376. setStencilFunctionReference(reference: number): void;
  42377. /**
  42378. * Sets the current stencil mask
  42379. * @param mask defines the new stencil mask to use
  42380. */
  42381. setStencilFunctionMask(mask: number): void;
  42382. /**
  42383. * Gets the current stencil operation when stencil fails
  42384. * @returns a number defining stencil operation to use when stencil fails
  42385. */
  42386. getStencilOperationFail(): number;
  42387. /**
  42388. * Gets the current stencil operation when depth fails
  42389. * @returns a number defining stencil operation to use when depth fails
  42390. */
  42391. getStencilOperationDepthFail(): number;
  42392. /**
  42393. * Gets the current stencil operation when stencil passes
  42394. * @returns a number defining stencil operation to use when stencil passes
  42395. */
  42396. getStencilOperationPass(): number;
  42397. /**
  42398. * Sets the stencil operation to use when stencil fails
  42399. * @param operation defines the stencil operation to use when stencil fails
  42400. */
  42401. setStencilOperationFail(operation: number): void;
  42402. /**
  42403. * Sets the stencil operation to use when depth fails
  42404. * @param operation defines the stencil operation to use when depth fails
  42405. */
  42406. setStencilOperationDepthFail(operation: number): void;
  42407. /**
  42408. * Sets the stencil operation to use when stencil passes
  42409. * @param operation defines the stencil operation to use when stencil passes
  42410. */
  42411. setStencilOperationPass(operation: number): void;
  42412. /**
  42413. * Sets a boolean indicating if the dithering state is enabled or disabled
  42414. * @param value defines the dithering state
  42415. */
  42416. setDitheringState(value: boolean): void;
  42417. /**
  42418. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42419. * @param value defines the rasterizer state
  42420. */
  42421. setRasterizerState(value: boolean): void;
  42422. /**
  42423. * Gets the current depth function
  42424. * @returns a number defining the depth function
  42425. */
  42426. getDepthFunction(): Nullable<number>;
  42427. /**
  42428. * Sets the current depth function
  42429. * @param depthFunc defines the function to use
  42430. */
  42431. setDepthFunction(depthFunc: number): void;
  42432. /**
  42433. * Sets the current depth function to GREATER
  42434. */
  42435. setDepthFunctionToGreater(): void;
  42436. /**
  42437. * Sets the current depth function to GEQUAL
  42438. */
  42439. setDepthFunctionToGreaterOrEqual(): void;
  42440. /**
  42441. * Sets the current depth function to LESS
  42442. */
  42443. setDepthFunctionToLess(): void;
  42444. /**
  42445. * Sets the current depth function to LEQUAL
  42446. */
  42447. setDepthFunctionToLessOrEqual(): void;
  42448. private _cachedStencilBuffer;
  42449. private _cachedStencilFunction;
  42450. private _cachedStencilMask;
  42451. private _cachedStencilOperationPass;
  42452. private _cachedStencilOperationFail;
  42453. private _cachedStencilOperationDepthFail;
  42454. private _cachedStencilReference;
  42455. /**
  42456. * Caches the the state of the stencil buffer
  42457. */
  42458. cacheStencilState(): void;
  42459. /**
  42460. * Restores the state of the stencil buffer
  42461. */
  42462. restoreStencilState(): void;
  42463. /**
  42464. * Directly set the WebGL Viewport
  42465. * @param x defines the x coordinate of the viewport (in screen space)
  42466. * @param y defines the y coordinate of the viewport (in screen space)
  42467. * @param width defines the width of the viewport (in screen space)
  42468. * @param height defines the height of the viewport (in screen space)
  42469. * @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
  42470. */
  42471. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42472. /**
  42473. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42474. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42475. * @param y defines the y-coordinate of the corner of the clear rectangle
  42476. * @param width defines the width of the clear rectangle
  42477. * @param height defines the height of the clear rectangle
  42478. * @param clearColor defines the clear color
  42479. */
  42480. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42481. /**
  42482. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42483. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42484. * @param y defines the y-coordinate of the corner of the clear rectangle
  42485. * @param width defines the width of the clear rectangle
  42486. * @param height defines the height of the clear rectangle
  42487. */
  42488. enableScissor(x: number, y: number, width: number, height: number): void;
  42489. /**
  42490. * Disable previously set scissor test rectangle
  42491. */
  42492. disableScissor(): void;
  42493. protected _reportDrawCall(): void;
  42494. /**
  42495. * Initializes a webVR display and starts listening to display change events
  42496. * The onVRDisplayChangedObservable will be notified upon these changes
  42497. * @returns The onVRDisplayChangedObservable
  42498. */
  42499. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42500. /** @hidden */
  42501. _prepareVRComponent(): void;
  42502. /** @hidden */
  42503. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42504. /** @hidden */
  42505. _submitVRFrame(): void;
  42506. /**
  42507. * Call this function to leave webVR mode
  42508. * Will do nothing if webVR is not supported or if there is no webVR device
  42509. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42510. */
  42511. disableVR(): void;
  42512. /**
  42513. * Gets a boolean indicating that the system is in VR mode and is presenting
  42514. * @returns true if VR mode is engaged
  42515. */
  42516. isVRPresenting(): boolean;
  42517. /** @hidden */
  42518. _requestVRFrame(): void;
  42519. /** @hidden */
  42520. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42521. /**
  42522. * Gets the source code of the vertex shader associated with a specific webGL program
  42523. * @param program defines the program to use
  42524. * @returns a string containing the source code of the vertex shader associated with the program
  42525. */
  42526. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42527. /**
  42528. * Gets the source code of the fragment shader associated with a specific webGL program
  42529. * @param program defines the program to use
  42530. * @returns a string containing the source code of the fragment shader associated with the program
  42531. */
  42532. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42533. /**
  42534. * Sets a depth stencil texture from a render target to the according uniform.
  42535. * @param channel The texture channel
  42536. * @param uniform The uniform to set
  42537. * @param texture The render target texture containing the depth stencil texture to apply
  42538. * @param name The texture name
  42539. */
  42540. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42541. /**
  42542. * Sets a texture to the webGL context from a postprocess
  42543. * @param channel defines the channel to use
  42544. * @param postProcess defines the source postprocess
  42545. * @param name name of the channel
  42546. */
  42547. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42548. /**
  42549. * Binds the output of the passed in post process to the texture channel specified
  42550. * @param channel The channel the texture should be bound to
  42551. * @param postProcess The post process which's output should be bound
  42552. * @param name name of the channel
  42553. */
  42554. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42555. protected _rebuildBuffers(): void;
  42556. /** @hidden */
  42557. _renderFrame(): void;
  42558. _renderLoop(): void;
  42559. /** @hidden */
  42560. _renderViews(): boolean;
  42561. /**
  42562. * Toggle full screen mode
  42563. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42564. */
  42565. switchFullscreen(requestPointerLock: boolean): void;
  42566. /**
  42567. * Enters full screen mode
  42568. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42569. */
  42570. enterFullscreen(requestPointerLock: boolean): void;
  42571. /**
  42572. * Exits full screen mode
  42573. */
  42574. exitFullscreen(): void;
  42575. /**
  42576. * Enters Pointerlock mode
  42577. */
  42578. enterPointerlock(): void;
  42579. /**
  42580. * Exits Pointerlock mode
  42581. */
  42582. exitPointerlock(): void;
  42583. /**
  42584. * Begin a new frame
  42585. */
  42586. beginFrame(): void;
  42587. /**
  42588. * End the current frame
  42589. */
  42590. endFrame(): void;
  42591. /**
  42592. * Resize the view according to the canvas' size
  42593. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42594. */
  42595. resize(forceSetSize?: boolean): void;
  42596. /**
  42597. * Force a specific size of the canvas
  42598. * @param width defines the new canvas' width
  42599. * @param height defines the new canvas' height
  42600. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42601. * @returns true if the size was changed
  42602. */
  42603. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42604. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42605. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42606. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42607. _releaseTexture(texture: InternalTexture): void;
  42608. /**
  42609. * @hidden
  42610. * Rescales a texture
  42611. * @param source input texutre
  42612. * @param destination destination texture
  42613. * @param scene scene to use to render the resize
  42614. * @param internalFormat format to use when resizing
  42615. * @param onComplete callback to be called when resize has completed
  42616. */
  42617. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42618. /**
  42619. * Gets the current framerate
  42620. * @returns a number representing the framerate
  42621. */
  42622. getFps(): number;
  42623. /**
  42624. * Gets the time spent between current and previous frame
  42625. * @returns a number representing the delta time in ms
  42626. */
  42627. getDeltaTime(): number;
  42628. private _measureFps;
  42629. /** @hidden */
  42630. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42631. /**
  42632. * Updates the sample count of a render target texture
  42633. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42634. * @param texture defines the texture to update
  42635. * @param samples defines the sample count to set
  42636. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42637. */
  42638. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42639. /**
  42640. * Updates a depth texture Comparison Mode and Function.
  42641. * If the comparison Function is equal to 0, the mode will be set to none.
  42642. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42643. * @param texture The texture to set the comparison function for
  42644. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42645. */
  42646. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42647. /**
  42648. * Creates a webGL buffer to use with instanciation
  42649. * @param capacity defines the size of the buffer
  42650. * @returns the webGL buffer
  42651. */
  42652. createInstancesBuffer(capacity: number): DataBuffer;
  42653. /**
  42654. * Delete a webGL buffer used with instanciation
  42655. * @param buffer defines the webGL buffer to delete
  42656. */
  42657. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42658. private _clientWaitAsync;
  42659. /** @hidden */
  42660. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42661. dispose(): void;
  42662. private _disableTouchAction;
  42663. /**
  42664. * Display the loading screen
  42665. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42666. */
  42667. displayLoadingUI(): void;
  42668. /**
  42669. * Hide the loading screen
  42670. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42671. */
  42672. hideLoadingUI(): void;
  42673. /**
  42674. * Gets the current loading screen object
  42675. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42676. */
  42677. get loadingScreen(): ILoadingScreen;
  42678. /**
  42679. * Sets the current loading screen object
  42680. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42681. */
  42682. set loadingScreen(loadingScreen: ILoadingScreen);
  42683. /**
  42684. * Sets the current loading screen text
  42685. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42686. */
  42687. set loadingUIText(text: string);
  42688. /**
  42689. * Sets the current loading screen background color
  42690. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42691. */
  42692. set loadingUIBackgroundColor(color: string);
  42693. /** Pointerlock and fullscreen */
  42694. /**
  42695. * Ask the browser to promote the current element to pointerlock mode
  42696. * @param element defines the DOM element to promote
  42697. */
  42698. static _RequestPointerlock(element: HTMLElement): void;
  42699. /**
  42700. * Asks the browser to exit pointerlock mode
  42701. */
  42702. static _ExitPointerlock(): void;
  42703. /**
  42704. * Ask the browser to promote the current element to fullscreen rendering mode
  42705. * @param element defines the DOM element to promote
  42706. */
  42707. static _RequestFullscreen(element: HTMLElement): void;
  42708. /**
  42709. * Asks the browser to exit fullscreen mode
  42710. */
  42711. static _ExitFullscreen(): void;
  42712. }
  42713. }
  42714. declare module BABYLON {
  42715. /**
  42716. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42717. * during the life time of the application.
  42718. */
  42719. export class EngineStore {
  42720. /** Gets the list of created engines */
  42721. static Instances: Engine[];
  42722. /** @hidden */
  42723. static _LastCreatedScene: Nullable<Scene>;
  42724. /**
  42725. * Gets the latest created engine
  42726. */
  42727. static get LastCreatedEngine(): Nullable<Engine>;
  42728. /**
  42729. * Gets the latest created scene
  42730. */
  42731. static get LastCreatedScene(): Nullable<Scene>;
  42732. /**
  42733. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42734. * @ignorenaming
  42735. */
  42736. static UseFallbackTexture: boolean;
  42737. /**
  42738. * Texture content used if a texture cannot loaded
  42739. * @ignorenaming
  42740. */
  42741. static FallbackTexture: string;
  42742. }
  42743. }
  42744. declare module BABYLON {
  42745. /**
  42746. * Helper class that provides a small promise polyfill
  42747. */
  42748. export class PromisePolyfill {
  42749. /**
  42750. * Static function used to check if the polyfill is required
  42751. * If this is the case then the function will inject the polyfill to window.Promise
  42752. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42753. */
  42754. static Apply(force?: boolean): void;
  42755. }
  42756. }
  42757. declare module BABYLON {
  42758. /**
  42759. * Interface for screenshot methods with describe argument called `size` as object with options
  42760. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42761. */
  42762. export interface IScreenshotSize {
  42763. /**
  42764. * number in pixels for canvas height
  42765. */
  42766. height?: number;
  42767. /**
  42768. * multiplier allowing render at a higher or lower resolution
  42769. * If value is defined then height and width will be ignored and taken from camera
  42770. */
  42771. precision?: number;
  42772. /**
  42773. * number in pixels for canvas width
  42774. */
  42775. width?: number;
  42776. }
  42777. }
  42778. declare module BABYLON {
  42779. interface IColor4Like {
  42780. r: float;
  42781. g: float;
  42782. b: float;
  42783. a: float;
  42784. }
  42785. /**
  42786. * Class containing a set of static utilities functions
  42787. */
  42788. export class Tools {
  42789. /**
  42790. * Gets or sets the base URL to use to load assets
  42791. */
  42792. static get BaseUrl(): string;
  42793. static set BaseUrl(value: string);
  42794. /**
  42795. * Enable/Disable Custom HTTP Request Headers globally.
  42796. * default = false
  42797. * @see CustomRequestHeaders
  42798. */
  42799. static UseCustomRequestHeaders: boolean;
  42800. /**
  42801. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42802. * i.e. when loading files, where the server/service expects an Authorization header
  42803. */
  42804. static CustomRequestHeaders: {
  42805. [key: string]: string;
  42806. };
  42807. /**
  42808. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42809. */
  42810. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42811. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42812. /**
  42813. * Default behaviour for cors in the application.
  42814. * It can be a string if the expected behavior is identical in the entire app.
  42815. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42816. */
  42817. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42818. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42819. /**
  42820. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42821. * @ignorenaming
  42822. */
  42823. static get UseFallbackTexture(): boolean;
  42824. static set UseFallbackTexture(value: boolean);
  42825. /**
  42826. * Use this object to register external classes like custom textures or material
  42827. * to allow the laoders to instantiate them
  42828. */
  42829. static get RegisteredExternalClasses(): {
  42830. [key: string]: Object;
  42831. };
  42832. static set RegisteredExternalClasses(classes: {
  42833. [key: string]: Object;
  42834. });
  42835. /**
  42836. * Texture content used if a texture cannot loaded
  42837. * @ignorenaming
  42838. */
  42839. static get fallbackTexture(): string;
  42840. static set fallbackTexture(value: string);
  42841. /**
  42842. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42843. * @param u defines the coordinate on X axis
  42844. * @param v defines the coordinate on Y axis
  42845. * @param width defines the width of the source data
  42846. * @param height defines the height of the source data
  42847. * @param pixels defines the source byte array
  42848. * @param color defines the output color
  42849. */
  42850. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42851. /**
  42852. * Interpolates between a and b via alpha
  42853. * @param a The lower value (returned when alpha = 0)
  42854. * @param b The upper value (returned when alpha = 1)
  42855. * @param alpha The interpolation-factor
  42856. * @return The mixed value
  42857. */
  42858. static Mix(a: number, b: number, alpha: number): number;
  42859. /**
  42860. * Tries to instantiate a new object from a given class name
  42861. * @param className defines the class name to instantiate
  42862. * @returns the new object or null if the system was not able to do the instantiation
  42863. */
  42864. static Instantiate(className: string): any;
  42865. /**
  42866. * Provides a slice function that will work even on IE
  42867. * @param data defines the array to slice
  42868. * @param start defines the start of the data (optional)
  42869. * @param end defines the end of the data (optional)
  42870. * @returns the new sliced array
  42871. */
  42872. static Slice<T>(data: T, start?: number, end?: number): T;
  42873. /**
  42874. * Provides a slice function that will work even on IE
  42875. * The difference between this and Slice is that this will force-convert to array
  42876. * @param data defines the array to slice
  42877. * @param start defines the start of the data (optional)
  42878. * @param end defines the end of the data (optional)
  42879. * @returns the new sliced array
  42880. */
  42881. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  42882. /**
  42883. * Polyfill for setImmediate
  42884. * @param action defines the action to execute after the current execution block
  42885. */
  42886. static SetImmediate(action: () => void): void;
  42887. /**
  42888. * Function indicating if a number is an exponent of 2
  42889. * @param value defines the value to test
  42890. * @returns true if the value is an exponent of 2
  42891. */
  42892. static IsExponentOfTwo(value: number): boolean;
  42893. private static _tmpFloatArray;
  42894. /**
  42895. * Returns the nearest 32-bit single precision float representation of a Number
  42896. * @param value A Number. If the parameter is of a different type, it will get converted
  42897. * to a number or to NaN if it cannot be converted
  42898. * @returns number
  42899. */
  42900. static FloatRound(value: number): number;
  42901. /**
  42902. * Extracts the filename from a path
  42903. * @param path defines the path to use
  42904. * @returns the filename
  42905. */
  42906. static GetFilename(path: string): string;
  42907. /**
  42908. * Extracts the "folder" part of a path (everything before the filename).
  42909. * @param uri The URI to extract the info from
  42910. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42911. * @returns The "folder" part of the path
  42912. */
  42913. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42914. /**
  42915. * Extracts text content from a DOM element hierarchy
  42916. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42917. */
  42918. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42919. /**
  42920. * Convert an angle in radians to degrees
  42921. * @param angle defines the angle to convert
  42922. * @returns the angle in degrees
  42923. */
  42924. static ToDegrees(angle: number): number;
  42925. /**
  42926. * Convert an angle in degrees to radians
  42927. * @param angle defines the angle to convert
  42928. * @returns the angle in radians
  42929. */
  42930. static ToRadians(angle: number): number;
  42931. /**
  42932. * Returns an array if obj is not an array
  42933. * @param obj defines the object to evaluate as an array
  42934. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42935. * @returns either obj directly if obj is an array or a new array containing obj
  42936. */
  42937. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42938. /**
  42939. * Gets the pointer prefix to use
  42940. * @param engine defines the engine we are finding the prefix for
  42941. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42942. */
  42943. static GetPointerPrefix(engine: Engine): string;
  42944. /**
  42945. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42946. * @param url define the url we are trying
  42947. * @param element define the dom element where to configure the cors policy
  42948. */
  42949. static SetCorsBehavior(url: string | string[], element: {
  42950. crossOrigin: string | null;
  42951. }): void;
  42952. /**
  42953. * Removes unwanted characters from an url
  42954. * @param url defines the url to clean
  42955. * @returns the cleaned url
  42956. */
  42957. static CleanUrl(url: string): string;
  42958. /**
  42959. * Gets or sets a function used to pre-process url before using them to load assets
  42960. */
  42961. static get PreprocessUrl(): (url: string) => string;
  42962. static set PreprocessUrl(processor: (url: string) => string);
  42963. /**
  42964. * Loads an image as an HTMLImageElement.
  42965. * @param input url string, ArrayBuffer, or Blob to load
  42966. * @param onLoad callback called when the image successfully loads
  42967. * @param onError callback called when the image fails to load
  42968. * @param offlineProvider offline provider for caching
  42969. * @param mimeType optional mime type
  42970. * @returns the HTMLImageElement of the loaded image
  42971. */
  42972. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42973. /**
  42974. * Loads a file from a url
  42975. * @param url url string, ArrayBuffer, or Blob to load
  42976. * @param onSuccess callback called when the file successfully loads
  42977. * @param onProgress callback called while file is loading (if the server supports this mode)
  42978. * @param offlineProvider defines the offline provider for caching
  42979. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42980. * @param onError callback called when the file fails to load
  42981. * @returns a file request object
  42982. */
  42983. 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;
  42984. /**
  42985. * Loads a file from a url
  42986. * @param url the file url to load
  42987. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42988. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42989. */
  42990. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42991. /**
  42992. * Load a script (identified by an url). When the url returns, the
  42993. * content of this file is added into a new script element, attached to the DOM (body element)
  42994. * @param scriptUrl defines the url of the script to laod
  42995. * @param onSuccess defines the callback called when the script is loaded
  42996. * @param onError defines the callback to call if an error occurs
  42997. * @param scriptId defines the id of the script element
  42998. */
  42999. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43000. /**
  43001. * Load an asynchronous script (identified by an url). When the url returns, the
  43002. * content of this file is added into a new script element, attached to the DOM (body element)
  43003. * @param scriptUrl defines the url of the script to laod
  43004. * @param scriptId defines the id of the script element
  43005. * @returns a promise request object
  43006. */
  43007. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43008. /**
  43009. * Loads a file from a blob
  43010. * @param fileToLoad defines the blob to use
  43011. * @param callback defines the callback to call when data is loaded
  43012. * @param progressCallback defines the callback to call during loading process
  43013. * @returns a file request object
  43014. */
  43015. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43016. /**
  43017. * Reads a file from a File object
  43018. * @param file defines the file to load
  43019. * @param onSuccess defines the callback to call when data is loaded
  43020. * @param onProgress defines the callback to call during loading process
  43021. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43022. * @param onError defines the callback to call when an error occurs
  43023. * @returns a file request object
  43024. */
  43025. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43026. /**
  43027. * Creates a data url from a given string content
  43028. * @param content defines the content to convert
  43029. * @returns the new data url link
  43030. */
  43031. static FileAsURL(content: string): string;
  43032. /**
  43033. * Format the given number to a specific decimal format
  43034. * @param value defines the number to format
  43035. * @param decimals defines the number of decimals to use
  43036. * @returns the formatted string
  43037. */
  43038. static Format(value: number, decimals?: number): string;
  43039. /**
  43040. * Tries to copy an object by duplicating every property
  43041. * @param source defines the source object
  43042. * @param destination defines the target object
  43043. * @param doNotCopyList defines a list of properties to avoid
  43044. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43045. */
  43046. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43047. /**
  43048. * Gets a boolean indicating if the given object has no own property
  43049. * @param obj defines the object to test
  43050. * @returns true if object has no own property
  43051. */
  43052. static IsEmpty(obj: any): boolean;
  43053. /**
  43054. * Function used to register events at window level
  43055. * @param windowElement defines the Window object to use
  43056. * @param events defines the events to register
  43057. */
  43058. static RegisterTopRootEvents(windowElement: Window, events: {
  43059. name: string;
  43060. handler: Nullable<(e: FocusEvent) => any>;
  43061. }[]): void;
  43062. /**
  43063. * Function used to unregister events from window level
  43064. * @param windowElement defines the Window object to use
  43065. * @param events defines the events to unregister
  43066. */
  43067. static UnregisterTopRootEvents(windowElement: Window, events: {
  43068. name: string;
  43069. handler: Nullable<(e: FocusEvent) => any>;
  43070. }[]): void;
  43071. /**
  43072. * @ignore
  43073. */
  43074. static _ScreenshotCanvas: HTMLCanvasElement;
  43075. /**
  43076. * Dumps the current bound framebuffer
  43077. * @param width defines the rendering width
  43078. * @param height defines the rendering height
  43079. * @param engine defines the hosting engine
  43080. * @param successCallback defines the callback triggered once the data are available
  43081. * @param mimeType defines the mime type of the result
  43082. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43083. * @return a void promise
  43084. */
  43085. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43086. /**
  43087. * Dumps an array buffer
  43088. * @param width defines the rendering width
  43089. * @param height defines the rendering height
  43090. * @param data the data array
  43091. * @param successCallback defines the callback triggered once the data are available
  43092. * @param mimeType defines the mime type of the result
  43093. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43094. * @param invertY true to invert the picture in the Y dimension
  43095. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43096. */
  43097. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43098. /**
  43099. * Dumps an array buffer
  43100. * @param width defines the rendering width
  43101. * @param height defines the rendering height
  43102. * @param data the data array
  43103. * @param successCallback defines the callback triggered once the data are available
  43104. * @param mimeType defines the mime type of the result
  43105. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43106. * @param invertY true to invert the picture in the Y dimension
  43107. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43108. * @return a promise that resolve to the final data
  43109. */
  43110. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43111. /**
  43112. * Converts the canvas data to blob.
  43113. * This acts as a polyfill for browsers not supporting the to blob function.
  43114. * @param canvas Defines the canvas to extract the data from
  43115. * @param successCallback Defines the callback triggered once the data are available
  43116. * @param mimeType Defines the mime type of the result
  43117. */
  43118. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43119. /**
  43120. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43121. * @param successCallback defines the callback triggered once the data are available
  43122. * @param mimeType defines the mime type of the result
  43123. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43124. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43125. */
  43126. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43127. /**
  43128. * Downloads a blob in the browser
  43129. * @param blob defines the blob to download
  43130. * @param fileName defines the name of the downloaded file
  43131. */
  43132. static Download(blob: Blob, fileName: string): void;
  43133. /**
  43134. * Will return the right value of the noPreventDefault variable
  43135. * Needed to keep backwards compatibility to the old API.
  43136. *
  43137. * @param args arguments passed to the attachControl function
  43138. * @returns the correct value for noPreventDefault
  43139. */
  43140. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43141. /**
  43142. * Captures a screenshot of the current rendering
  43143. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43144. * @param engine defines the rendering engine
  43145. * @param camera defines the source camera
  43146. * @param size This parameter can be set to a single number or to an object with the
  43147. * following (optional) properties: precision, width, height. If a single number is passed,
  43148. * it will be used for both width and height. If an object is passed, the screenshot size
  43149. * will be derived from the parameters. The precision property is a multiplier allowing
  43150. * rendering at a higher or lower resolution
  43151. * @param successCallback defines the callback receives a single parameter which contains the
  43152. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43153. * src parameter of an <img> to display it
  43154. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43155. * Check your browser for supported MIME types
  43156. */
  43157. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43158. /**
  43159. * Captures a screenshot of the current rendering
  43160. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43161. * @param engine defines the rendering engine
  43162. * @param camera defines the source camera
  43163. * @param size This parameter can be set to a single number or to an object with the
  43164. * following (optional) properties: precision, width, height. If a single number is passed,
  43165. * it will be used for both width and height. If an object is passed, the screenshot size
  43166. * will be derived from the parameters. The precision property is a multiplier allowing
  43167. * rendering at a higher or lower resolution
  43168. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43169. * Check your browser for supported MIME types
  43170. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43171. * to the src parameter of an <img> to display it
  43172. */
  43173. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43174. /**
  43175. * Generates an image screenshot from the specified camera.
  43176. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43177. * @param engine The engine to use for rendering
  43178. * @param camera The camera to use for rendering
  43179. * @param size This parameter can be set to a single number or to an object with the
  43180. * following (optional) properties: precision, width, height. If a single number is passed,
  43181. * it will be used for both width and height. If an object is passed, the screenshot size
  43182. * will be derived from the parameters. The precision property is a multiplier allowing
  43183. * rendering at a higher or lower resolution
  43184. * @param successCallback The callback receives a single parameter which contains the
  43185. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43186. * src parameter of an <img> to display it
  43187. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43188. * Check your browser for supported MIME types
  43189. * @param samples Texture samples (default: 1)
  43190. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43191. * @param fileName A name for for the downloaded file.
  43192. */
  43193. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43194. /**
  43195. * Generates an image screenshot from the specified camera.
  43196. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43197. * @param engine The engine to use for rendering
  43198. * @param camera The camera to use for rendering
  43199. * @param size This parameter can be set to a single number or to an object with the
  43200. * following (optional) properties: precision, width, height. If a single number is passed,
  43201. * it will be used for both width and height. If an object is passed, the screenshot size
  43202. * will be derived from the parameters. The precision property is a multiplier allowing
  43203. * rendering at a higher or lower resolution
  43204. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43205. * Check your browser for supported MIME types
  43206. * @param samples Texture samples (default: 1)
  43207. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43208. * @param fileName A name for for the downloaded file.
  43209. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43210. * to the src parameter of an <img> to display it
  43211. */
  43212. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43213. /**
  43214. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43215. * Be aware Math.random() could cause collisions, but:
  43216. * "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"
  43217. * @returns a pseudo random id
  43218. */
  43219. static RandomId(): string;
  43220. /**
  43221. * Test if the given uri is a base64 string
  43222. * @param uri The uri to test
  43223. * @return True if the uri is a base64 string or false otherwise
  43224. */
  43225. static IsBase64(uri: string): boolean;
  43226. /**
  43227. * Decode the given base64 uri.
  43228. * @param uri The uri to decode
  43229. * @return The decoded base64 data.
  43230. */
  43231. static DecodeBase64(uri: string): ArrayBuffer;
  43232. /**
  43233. * Gets the absolute url.
  43234. * @param url the input url
  43235. * @return the absolute url
  43236. */
  43237. static GetAbsoluteUrl(url: string): string;
  43238. /**
  43239. * No log
  43240. */
  43241. static readonly NoneLogLevel: number;
  43242. /**
  43243. * Only message logs
  43244. */
  43245. static readonly MessageLogLevel: number;
  43246. /**
  43247. * Only warning logs
  43248. */
  43249. static readonly WarningLogLevel: number;
  43250. /**
  43251. * Only error logs
  43252. */
  43253. static readonly ErrorLogLevel: number;
  43254. /**
  43255. * All logs
  43256. */
  43257. static readonly AllLogLevel: number;
  43258. /**
  43259. * Gets a value indicating the number of loading errors
  43260. * @ignorenaming
  43261. */
  43262. static get errorsCount(): number;
  43263. /**
  43264. * Callback called when a new log is added
  43265. */
  43266. static OnNewCacheEntry: (entry: string) => void;
  43267. /**
  43268. * Log a message to the console
  43269. * @param message defines the message to log
  43270. */
  43271. static Log(message: string): void;
  43272. /**
  43273. * Write a warning message to the console
  43274. * @param message defines the message to log
  43275. */
  43276. static Warn(message: string): void;
  43277. /**
  43278. * Write an error message to the console
  43279. * @param message defines the message to log
  43280. */
  43281. static Error(message: string): void;
  43282. /**
  43283. * Gets current log cache (list of logs)
  43284. */
  43285. static get LogCache(): string;
  43286. /**
  43287. * Clears the log cache
  43288. */
  43289. static ClearLogCache(): void;
  43290. /**
  43291. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43292. */
  43293. static set LogLevels(level: number);
  43294. /**
  43295. * Checks if the window object exists
  43296. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43297. */
  43298. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43299. /**
  43300. * No performance log
  43301. */
  43302. static readonly PerformanceNoneLogLevel: number;
  43303. /**
  43304. * Use user marks to log performance
  43305. */
  43306. static readonly PerformanceUserMarkLogLevel: number;
  43307. /**
  43308. * Log performance to the console
  43309. */
  43310. static readonly PerformanceConsoleLogLevel: number;
  43311. private static _performance;
  43312. /**
  43313. * Sets the current performance log level
  43314. */
  43315. static set PerformanceLogLevel(level: number);
  43316. private static _StartPerformanceCounterDisabled;
  43317. private static _EndPerformanceCounterDisabled;
  43318. private static _StartUserMark;
  43319. private static _EndUserMark;
  43320. private static _StartPerformanceConsole;
  43321. private static _EndPerformanceConsole;
  43322. /**
  43323. * Starts a performance counter
  43324. */
  43325. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43326. /**
  43327. * Ends a specific performance coutner
  43328. */
  43329. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43330. /**
  43331. * Gets either window.performance.now() if supported or Date.now() else
  43332. */
  43333. static get Now(): number;
  43334. /**
  43335. * This method will return the name of the class used to create the instance of the given object.
  43336. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43337. * @param object the object to get the class name from
  43338. * @param isType defines if the object is actually a type
  43339. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43340. */
  43341. static GetClassName(object: any, isType?: boolean): string;
  43342. /**
  43343. * Gets the first element of an array satisfying a given predicate
  43344. * @param array defines the array to browse
  43345. * @param predicate defines the predicate to use
  43346. * @returns null if not found or the element
  43347. */
  43348. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43349. /**
  43350. * This method will return the name of the full name of the class, including its owning module (if any).
  43351. * 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).
  43352. * @param object the object to get the class name from
  43353. * @param isType defines if the object is actually a type
  43354. * @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.
  43355. * @ignorenaming
  43356. */
  43357. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43358. /**
  43359. * Returns a promise that resolves after the given amount of time.
  43360. * @param delay Number of milliseconds to delay
  43361. * @returns Promise that resolves after the given amount of time
  43362. */
  43363. static DelayAsync(delay: number): Promise<void>;
  43364. /**
  43365. * Utility function to detect if the current user agent is Safari
  43366. * @returns whether or not the current user agent is safari
  43367. */
  43368. static IsSafari(): boolean;
  43369. }
  43370. /**
  43371. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43372. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43373. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43374. * @param name The name of the class, case should be preserved
  43375. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43376. */
  43377. export function className(name: string, module?: string): (target: Object) => void;
  43378. /**
  43379. * An implementation of a loop for asynchronous functions.
  43380. */
  43381. export class AsyncLoop {
  43382. /**
  43383. * Defines the number of iterations for the loop
  43384. */
  43385. iterations: number;
  43386. /**
  43387. * Defines the current index of the loop.
  43388. */
  43389. index: number;
  43390. private _done;
  43391. private _fn;
  43392. private _successCallback;
  43393. /**
  43394. * Constructor.
  43395. * @param iterations the number of iterations.
  43396. * @param func the function to run each iteration
  43397. * @param successCallback the callback that will be called upon succesful execution
  43398. * @param offset starting offset.
  43399. */
  43400. constructor(
  43401. /**
  43402. * Defines the number of iterations for the loop
  43403. */
  43404. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43405. /**
  43406. * Execute the next iteration. Must be called after the last iteration was finished.
  43407. */
  43408. executeNext(): void;
  43409. /**
  43410. * Break the loop and run the success callback.
  43411. */
  43412. breakLoop(): void;
  43413. /**
  43414. * Create and run an async loop.
  43415. * @param iterations the number of iterations.
  43416. * @param fn the function to run each iteration
  43417. * @param successCallback the callback that will be called upon succesful execution
  43418. * @param offset starting offset.
  43419. * @returns the created async loop object
  43420. */
  43421. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43422. /**
  43423. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43424. * @param iterations total number of iterations
  43425. * @param syncedIterations number of synchronous iterations in each async iteration.
  43426. * @param fn the function to call each iteration.
  43427. * @param callback a success call back that will be called when iterating stops.
  43428. * @param breakFunction a break condition (optional)
  43429. * @param timeout timeout settings for the setTimeout function. default - 0.
  43430. * @returns the created async loop object
  43431. */
  43432. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43433. }
  43434. }
  43435. declare module BABYLON {
  43436. /**
  43437. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43438. * The underlying implementation relies on an associative array to ensure the best performances.
  43439. * The value can be anything including 'null' but except 'undefined'
  43440. */
  43441. export class StringDictionary<T> {
  43442. /**
  43443. * This will clear this dictionary and copy the content from the 'source' one.
  43444. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43445. * @param source the dictionary to take the content from and copy to this dictionary
  43446. */
  43447. copyFrom(source: StringDictionary<T>): void;
  43448. /**
  43449. * Get a value based from its key
  43450. * @param key the given key to get the matching value from
  43451. * @return the value if found, otherwise undefined is returned
  43452. */
  43453. get(key: string): T | undefined;
  43454. /**
  43455. * Get a value from its key or add it if it doesn't exist.
  43456. * This method will ensure you that a given key/data will be present in the dictionary.
  43457. * @param key the given key to get the matching value from
  43458. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43459. * The factory will only be invoked if there's no data for the given key.
  43460. * @return the value corresponding to the key.
  43461. */
  43462. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43463. /**
  43464. * Get a value from its key if present in the dictionary otherwise add it
  43465. * @param key the key to get the value from
  43466. * @param val if there's no such key/value pair in the dictionary add it with this value
  43467. * @return the value corresponding to the key
  43468. */
  43469. getOrAdd(key: string, val: T): T;
  43470. /**
  43471. * Check if there's a given key in the dictionary
  43472. * @param key the key to check for
  43473. * @return true if the key is present, false otherwise
  43474. */
  43475. contains(key: string): boolean;
  43476. /**
  43477. * Add a new key and its corresponding value
  43478. * @param key the key to add
  43479. * @param value the value corresponding to the key
  43480. * @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
  43481. */
  43482. add(key: string, value: T): boolean;
  43483. /**
  43484. * Update a specific value associated to a key
  43485. * @param key defines the key to use
  43486. * @param value defines the value to store
  43487. * @returns true if the value was updated (or false if the key was not found)
  43488. */
  43489. set(key: string, value: T): boolean;
  43490. /**
  43491. * Get the element of the given key and remove it from the dictionary
  43492. * @param key defines the key to search
  43493. * @returns the value associated with the key or null if not found
  43494. */
  43495. getAndRemove(key: string): Nullable<T>;
  43496. /**
  43497. * Remove a key/value from the dictionary.
  43498. * @param key the key to remove
  43499. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43500. */
  43501. remove(key: string): boolean;
  43502. /**
  43503. * Clear the whole content of the dictionary
  43504. */
  43505. clear(): void;
  43506. /**
  43507. * Gets the current count
  43508. */
  43509. get count(): number;
  43510. /**
  43511. * Execute a callback on each key/val of the dictionary.
  43512. * Note that you can remove any element in this dictionary in the callback implementation
  43513. * @param callback the callback to execute on a given key/value pair
  43514. */
  43515. forEach(callback: (key: string, val: T) => void): void;
  43516. /**
  43517. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43518. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43519. * Note that you can remove any element in this dictionary in the callback implementation
  43520. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43521. * @returns the first item
  43522. */
  43523. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43524. private _count;
  43525. private _data;
  43526. }
  43527. }
  43528. declare module BABYLON {
  43529. /** @hidden */
  43530. export interface ICollisionCoordinator {
  43531. createCollider(): Collider;
  43532. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43533. init(scene: Scene): void;
  43534. }
  43535. /** @hidden */
  43536. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43537. private _scene;
  43538. private _scaledPosition;
  43539. private _scaledVelocity;
  43540. private _finalPosition;
  43541. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43542. createCollider(): Collider;
  43543. init(scene: Scene): void;
  43544. private _collideWithWorld;
  43545. }
  43546. }
  43547. declare module BABYLON {
  43548. /**
  43549. * Class used to manage all inputs for the scene.
  43550. */
  43551. export class InputManager {
  43552. /** The distance in pixel that you have to move to prevent some events */
  43553. static DragMovementThreshold: number;
  43554. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43555. static LongPressDelay: number;
  43556. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43557. static DoubleClickDelay: number;
  43558. /** If you need to check double click without raising a single click at first click, enable this flag */
  43559. static ExclusiveDoubleClickMode: boolean;
  43560. /** 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. */
  43561. private _alreadyAttached;
  43562. private _alreadyAttachedTo;
  43563. private _wheelEventName;
  43564. private _onPointerMove;
  43565. private _onPointerDown;
  43566. private _onPointerUp;
  43567. private _initClickEvent;
  43568. private _initActionManager;
  43569. private _delayedSimpleClick;
  43570. private _delayedSimpleClickTimeout;
  43571. private _previousDelayedSimpleClickTimeout;
  43572. private _meshPickProceed;
  43573. private _previousButtonPressed;
  43574. private _currentPickResult;
  43575. private _previousPickResult;
  43576. private _totalPointersPressed;
  43577. private _doubleClickOccured;
  43578. private _pointerOverMesh;
  43579. private _pickedDownMesh;
  43580. private _pickedUpMesh;
  43581. private _pointerX;
  43582. private _pointerY;
  43583. private _unTranslatedPointerX;
  43584. private _unTranslatedPointerY;
  43585. private _startingPointerPosition;
  43586. private _previousStartingPointerPosition;
  43587. private _startingPointerTime;
  43588. private _previousStartingPointerTime;
  43589. private _pointerCaptures;
  43590. private _meshUnderPointerId;
  43591. private _onKeyDown;
  43592. private _onKeyUp;
  43593. private _keyboardIsAttached;
  43594. private _onCanvasFocusObserver;
  43595. private _onCanvasBlurObserver;
  43596. private _scene;
  43597. /**
  43598. * Creates a new InputManager
  43599. * @param scene defines the hosting scene
  43600. */
  43601. constructor(scene: Scene);
  43602. /**
  43603. * Gets the mesh that is currently under the pointer
  43604. */
  43605. get meshUnderPointer(): Nullable<AbstractMesh>;
  43606. /**
  43607. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43608. * @param pointerId the pointer id to use
  43609. * @returns The mesh under this pointer id or null if not found
  43610. */
  43611. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43612. /**
  43613. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43614. */
  43615. get unTranslatedPointer(): Vector2;
  43616. /**
  43617. * Gets or sets the current on-screen X position of the pointer
  43618. */
  43619. get pointerX(): number;
  43620. set pointerX(value: number);
  43621. /**
  43622. * Gets or sets the current on-screen Y position of the pointer
  43623. */
  43624. get pointerY(): number;
  43625. set pointerY(value: number);
  43626. private _updatePointerPosition;
  43627. private _processPointerMove;
  43628. private _setRayOnPointerInfo;
  43629. private _checkPrePointerObservable;
  43630. /**
  43631. * Use this method to simulate a pointer move on a mesh
  43632. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43633. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43634. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43635. */
  43636. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43637. /**
  43638. * Use this method to simulate a pointer down on a mesh
  43639. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43640. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43641. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43642. */
  43643. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43644. private _processPointerDown;
  43645. /** @hidden */
  43646. _isPointerSwiping(): boolean;
  43647. /**
  43648. * Use this method to simulate a pointer up on a mesh
  43649. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43650. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43651. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43652. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43653. */
  43654. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43655. private _processPointerUp;
  43656. /**
  43657. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43658. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43659. * @returns true if the pointer was captured
  43660. */
  43661. isPointerCaptured(pointerId?: number): boolean;
  43662. /**
  43663. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43664. * @param attachUp defines if you want to attach events to pointerup
  43665. * @param attachDown defines if you want to attach events to pointerdown
  43666. * @param attachMove defines if you want to attach events to pointermove
  43667. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43668. */
  43669. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43670. /**
  43671. * Detaches all event handlers
  43672. */
  43673. detachControl(): void;
  43674. /**
  43675. * Force the value of meshUnderPointer
  43676. * @param mesh defines the mesh to use
  43677. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43678. */
  43679. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43680. /**
  43681. * Gets the mesh under the pointer
  43682. * @returns a Mesh or null if no mesh is under the pointer
  43683. */
  43684. getPointerOverMesh(): Nullable<AbstractMesh>;
  43685. }
  43686. }
  43687. declare module BABYLON {
  43688. /**
  43689. * This class defines the direct association between an animation and a target
  43690. */
  43691. export class TargetedAnimation {
  43692. /**
  43693. * Animation to perform
  43694. */
  43695. animation: Animation;
  43696. /**
  43697. * Target to animate
  43698. */
  43699. target: any;
  43700. /**
  43701. * Returns the string "TargetedAnimation"
  43702. * @returns "TargetedAnimation"
  43703. */
  43704. getClassName(): string;
  43705. /**
  43706. * Serialize the object
  43707. * @returns the JSON object representing the current entity
  43708. */
  43709. serialize(): any;
  43710. }
  43711. /**
  43712. * Use this class to create coordinated animations on multiple targets
  43713. */
  43714. export class AnimationGroup implements IDisposable {
  43715. /** The name of the animation group */
  43716. name: string;
  43717. private _scene;
  43718. private _targetedAnimations;
  43719. private _animatables;
  43720. private _from;
  43721. private _to;
  43722. private _isStarted;
  43723. private _isPaused;
  43724. private _speedRatio;
  43725. private _loopAnimation;
  43726. private _isAdditive;
  43727. /**
  43728. * Gets or sets the unique id of the node
  43729. */
  43730. uniqueId: number;
  43731. /**
  43732. * This observable will notify when one animation have ended
  43733. */
  43734. onAnimationEndObservable: Observable<TargetedAnimation>;
  43735. /**
  43736. * Observer raised when one animation loops
  43737. */
  43738. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43739. /**
  43740. * Observer raised when all animations have looped
  43741. */
  43742. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43743. /**
  43744. * This observable will notify when all animations have ended.
  43745. */
  43746. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43747. /**
  43748. * This observable will notify when all animations have paused.
  43749. */
  43750. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43751. /**
  43752. * This observable will notify when all animations are playing.
  43753. */
  43754. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43755. /**
  43756. * Gets the first frame
  43757. */
  43758. get from(): number;
  43759. /**
  43760. * Gets the last frame
  43761. */
  43762. get to(): number;
  43763. /**
  43764. * Define if the animations are started
  43765. */
  43766. get isStarted(): boolean;
  43767. /**
  43768. * Gets a value indicating that the current group is playing
  43769. */
  43770. get isPlaying(): boolean;
  43771. /**
  43772. * Gets or sets the speed ratio to use for all animations
  43773. */
  43774. get speedRatio(): number;
  43775. /**
  43776. * Gets or sets the speed ratio to use for all animations
  43777. */
  43778. set speedRatio(value: number);
  43779. /**
  43780. * Gets or sets if all animations should loop or not
  43781. */
  43782. get loopAnimation(): boolean;
  43783. set loopAnimation(value: boolean);
  43784. /**
  43785. * Gets or sets if all animations should be evaluated additively
  43786. */
  43787. get isAdditive(): boolean;
  43788. set isAdditive(value: boolean);
  43789. /**
  43790. * Gets the targeted animations for this animation group
  43791. */
  43792. get targetedAnimations(): Array<TargetedAnimation>;
  43793. /**
  43794. * returning the list of animatables controlled by this animation group.
  43795. */
  43796. get animatables(): Array<Animatable>;
  43797. /**
  43798. * Gets the list of target animations
  43799. */
  43800. get children(): TargetedAnimation[];
  43801. /**
  43802. * Instantiates a new Animation Group.
  43803. * This helps managing several animations at once.
  43804. * @see https://doc.babylonjs.com/how_to/group
  43805. * @param name Defines the name of the group
  43806. * @param scene Defines the scene the group belongs to
  43807. */
  43808. constructor(
  43809. /** The name of the animation group */
  43810. name: string, scene?: Nullable<Scene>);
  43811. /**
  43812. * Add an animation (with its target) in the group
  43813. * @param animation defines the animation we want to add
  43814. * @param target defines the target of the animation
  43815. * @returns the TargetedAnimation object
  43816. */
  43817. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43818. /**
  43819. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43820. * It can add constant keys at begin or end
  43821. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43822. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43823. * @returns the animation group
  43824. */
  43825. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43826. private _animationLoopCount;
  43827. private _animationLoopFlags;
  43828. private _processLoop;
  43829. /**
  43830. * Start all animations on given targets
  43831. * @param loop defines if animations must loop
  43832. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43833. * @param from defines the from key (optional)
  43834. * @param to defines the to key (optional)
  43835. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43836. * @returns the current animation group
  43837. */
  43838. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43839. /**
  43840. * Pause all animations
  43841. * @returns the animation group
  43842. */
  43843. pause(): AnimationGroup;
  43844. /**
  43845. * Play all animations to initial state
  43846. * This function will start() the animations if they were not started or will restart() them if they were paused
  43847. * @param loop defines if animations must loop
  43848. * @returns the animation group
  43849. */
  43850. play(loop?: boolean): AnimationGroup;
  43851. /**
  43852. * Reset all animations to initial state
  43853. * @returns the animation group
  43854. */
  43855. reset(): AnimationGroup;
  43856. /**
  43857. * Restart animations from key 0
  43858. * @returns the animation group
  43859. */
  43860. restart(): AnimationGroup;
  43861. /**
  43862. * Stop all animations
  43863. * @returns the animation group
  43864. */
  43865. stop(): AnimationGroup;
  43866. /**
  43867. * Set animation weight for all animatables
  43868. * @param weight defines the weight to use
  43869. * @return the animationGroup
  43870. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43871. */
  43872. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43873. /**
  43874. * Synchronize and normalize all animatables with a source animatable
  43875. * @param root defines the root animatable to synchronize with
  43876. * @return the animationGroup
  43877. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43878. */
  43879. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43880. /**
  43881. * Goes to a specific frame in this animation group
  43882. * @param frame the frame number to go to
  43883. * @return the animationGroup
  43884. */
  43885. goToFrame(frame: number): AnimationGroup;
  43886. /**
  43887. * Dispose all associated resources
  43888. */
  43889. dispose(): void;
  43890. private _checkAnimationGroupEnded;
  43891. /**
  43892. * Clone the current animation group and returns a copy
  43893. * @param newName defines the name of the new group
  43894. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43895. * @returns the new aniamtion group
  43896. */
  43897. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43898. /**
  43899. * Serializes the animationGroup to an object
  43900. * @returns Serialized object
  43901. */
  43902. serialize(): any;
  43903. /**
  43904. * Returns a new AnimationGroup object parsed from the source provided.
  43905. * @param parsedAnimationGroup defines the source
  43906. * @param scene defines the scene that will receive the animationGroup
  43907. * @returns a new AnimationGroup
  43908. */
  43909. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43910. /**
  43911. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43912. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43913. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43914. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43915. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43916. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43917. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43918. */
  43919. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43920. /**
  43921. * Returns the string "AnimationGroup"
  43922. * @returns "AnimationGroup"
  43923. */
  43924. getClassName(): string;
  43925. /**
  43926. * Creates a detailled string about the object
  43927. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43928. * @returns a string representing the object
  43929. */
  43930. toString(fullDetails?: boolean): string;
  43931. }
  43932. }
  43933. declare module BABYLON {
  43934. /**
  43935. * @hidden
  43936. **/
  43937. export class _TimeToken {
  43938. _startTimeQuery: Nullable<WebGLQuery>;
  43939. _endTimeQuery: Nullable<WebGLQuery>;
  43940. _timeElapsedQuery: Nullable<WebGLQuery>;
  43941. _timeElapsedQueryEnded: boolean;
  43942. }
  43943. }
  43944. declare module BABYLON {
  43945. /** @hidden */
  43946. export enum ExtensionName {
  43947. DepthClamping = "depth-clamping",
  43948. Depth24UnormStencil8 = "depth24unorm-stencil8",
  43949. Depth32FloatStencil8 = "depth32float-stencil8",
  43950. PipelineStatisticsQuery = "pipeline-statistics-query",
  43951. TextureCompressionBC = "texture-compression-bc",
  43952. TimestampQuery = "timestamp-query"
  43953. }
  43954. /** @hidden */
  43955. export enum AddressMode {
  43956. ClampToEdge = "clamp-to-edge",
  43957. Repeat = "repeat",
  43958. MirrorRepeat = "mirror-repeat"
  43959. }
  43960. /** @hidden */
  43961. export enum BindingType {
  43962. UniformBuffer = "uniform-buffer",
  43963. StorageBuffer = "storage-buffer",
  43964. ReadonlyStorageBuffer = "readonly-storage-buffer",
  43965. Sampler = "sampler",
  43966. ComparisonSampler = "comparison-sampler",
  43967. SampledTexture = "sampled-texture",
  43968. ReadonlyStorageTexture = "readonly-storage-texture",
  43969. WriteonlyStorageTexture = "writeonly-storage-texture"
  43970. }
  43971. /** @hidden */
  43972. export enum BlendFactor {
  43973. Zero = "zero",
  43974. One = "one",
  43975. SrcColor = "src-color",
  43976. OneMinusSrcColor = "one-minus-src-color",
  43977. SrcAlpha = "src-alpha",
  43978. OneMinusSrcAlpha = "one-minus-src-alpha",
  43979. DstColor = "dst-color",
  43980. OneMinusDstColor = "one-minus-dst-color",
  43981. DstAlpha = "dst-alpha",
  43982. OneMinusDstAlpha = "one-minus-dst-alpha",
  43983. SrcAlphaSaturated = "src-alpha-saturated",
  43984. BlendColor = "blend-color",
  43985. OneMinusBlendColor = "one-minus-blend-color"
  43986. }
  43987. /** @hidden */
  43988. export enum BlendOperation {
  43989. Add = "add",
  43990. Subtract = "subtract",
  43991. ReverseSubtract = "reverse-subtract",
  43992. Min = "min",
  43993. Max = "max"
  43994. }
  43995. /** @hidden */
  43996. export enum CompareFunction {
  43997. Never = "never",
  43998. Less = "less",
  43999. Equal = "equal",
  44000. LessEqual = "less-equal",
  44001. Greater = "greater",
  44002. NotEqual = "not-equal",
  44003. GreaterEqual = "greater-equal",
  44004. Always = "always"
  44005. }
  44006. /** @hidden */
  44007. export enum CullMode {
  44008. None = "none",
  44009. Front = "front",
  44010. Back = "back"
  44011. }
  44012. /** @hidden */
  44013. export enum FilterMode {
  44014. Nearest = "nearest",
  44015. Linear = "linear"
  44016. }
  44017. /** @hidden */
  44018. export enum FrontFace {
  44019. CCW = "ccw",
  44020. CW = "cw"
  44021. }
  44022. /** @hidden */
  44023. export enum IndexFormat {
  44024. Uint16 = "uint16",
  44025. Uint32 = "uint32"
  44026. }
  44027. /** @hidden */
  44028. export enum InputStepMode {
  44029. Vertex = "vertex",
  44030. Instance = "instance"
  44031. }
  44032. /** @hidden */
  44033. export enum LoadOp {
  44034. Load = "load"
  44035. }
  44036. /** @hidden */
  44037. export enum PrimitiveTopology {
  44038. PointList = "point-list",
  44039. LineList = "line-list",
  44040. LineStrip = "line-strip",
  44041. TriangleList = "triangle-list",
  44042. TriangleStrip = "triangle-strip"
  44043. }
  44044. /** @hidden */
  44045. export enum StencilOperation {
  44046. Keep = "keep",
  44047. Zero = "zero",
  44048. Replace = "replace",
  44049. Invert = "invert",
  44050. IncrementClamp = "increment-clamp",
  44051. DecrementClamp = "decrement-clamp",
  44052. IncrementWrap = "increment-wrap",
  44053. DecrementWrap = "decrement-wrap"
  44054. }
  44055. /** @hidden */
  44056. export enum StoreOp {
  44057. Store = "store",
  44058. Clear = "clear"
  44059. }
  44060. /** @hidden */
  44061. export enum TextureDimension {
  44062. E1d = "1d",
  44063. E2d = "2d",
  44064. E3d = "3d"
  44065. }
  44066. /** @hidden */
  44067. export enum TextureFormat {
  44068. R8Unorm = "r8unorm",
  44069. R8Snorm = "r8snorm",
  44070. R8Uint = "r8uint",
  44071. R8Sint = "r8sint",
  44072. R16Uint = "r16uint",
  44073. R16Sint = "r16sint",
  44074. R16Float = "r16float",
  44075. RG8Unorm = "rg8unorm",
  44076. RG8Snorm = "rg8snorm",
  44077. RG8Uint = "rg8uint",
  44078. RG8Sint = "rg8sint",
  44079. R32Uint = "r32uint",
  44080. R32Sint = "r32sint",
  44081. R32Float = "r32float",
  44082. RG16Uint = "rg16uint",
  44083. RG16Sint = "rg16sint",
  44084. RG16Float = "rg16float",
  44085. RGBA8Unorm = "rgba8unorm",
  44086. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44087. RGBA8Snorm = "rgba8snorm",
  44088. RGBA8Uint = "rgba8uint",
  44089. RGBA8Sint = "rgba8sint",
  44090. BGRA8Unorm = "bgra8unorm",
  44091. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44092. RGB9E5UFloat = "rgb9e5ufloat",
  44093. RGB10A2Unorm = "rgb10a2unorm",
  44094. RG11B10UFloat = "rg11b10ufloat",
  44095. RG32Uint = "rg32uint",
  44096. RG32Sint = "rg32sint",
  44097. RG32Float = "rg32float",
  44098. RGBA16Uint = "rgba16uint",
  44099. RGBA16Sint = "rgba16sint",
  44100. RGBA16Float = "rgba16float",
  44101. RGBA32Uint = "rgba32uint",
  44102. RGBA32Sint = "rgba32sint",
  44103. RGBA32Float = "rgba32float",
  44104. Stencil8 = "stencil8",
  44105. Depth16Unorm = "depth16unorm",
  44106. Depth24Plus = "depth24plus",
  44107. Depth24PlusStencil8 = "depth24plus-stencil8",
  44108. Depth32Float = "depth32float",
  44109. BC1RGBAUNorm = "bc1-rgba-unorm",
  44110. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44111. BC2RGBAUnorm = "bc2-rgba-unorm",
  44112. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44113. BC3RGBAUnorm = "bc3-rgba-unorm",
  44114. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44115. BC4RUnorm = "bc4-r-unorm",
  44116. BC4RSnorm = "bc4-r-snorm",
  44117. BC5RGUnorm = "bc5-rg-unorm",
  44118. BC5RGSnorm = "bc5-rg-snorm",
  44119. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44120. BC6HRGBFloat = "bc6h-rgb-float",
  44121. BC7RGBAUnorm = "bc7-rgba-unorm",
  44122. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44123. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44124. Depth32FloatStencil8 = "depth32float-stencil8"
  44125. }
  44126. /** @hidden */
  44127. export enum TextureComponentType {
  44128. Float = "float",
  44129. Sint = "sint",
  44130. Uint = "uint",
  44131. DepthComparison = "depth-comparison"
  44132. }
  44133. /** @hidden */
  44134. export enum TextureViewDimension {
  44135. E1d = "1d",
  44136. E2d = "2d",
  44137. E2dArray = "2d-array",
  44138. Cube = "cube",
  44139. CubeArray = "cube-array",
  44140. E3d = "3d"
  44141. }
  44142. /** @hidden */
  44143. export enum VertexFormat {
  44144. Uchar2 = "uchar2",
  44145. Uchar4 = "uchar4",
  44146. Char2 = "char2",
  44147. Char4 = "char4",
  44148. Uchar2Norm = "uchar2norm",
  44149. Uchar4Norm = "uchar4norm",
  44150. Char2Norm = "char2norm",
  44151. Char4Norm = "char4norm",
  44152. Ushort2 = "ushort2",
  44153. Ushort4 = "ushort4",
  44154. Short2 = "short2",
  44155. Short4 = "short4",
  44156. Ushort2Norm = "ushort2norm",
  44157. Ushort4Norm = "ushort4norm",
  44158. Short2Norm = "short2norm",
  44159. Short4Norm = "short4norm",
  44160. Half2 = "half2",
  44161. Half4 = "half4",
  44162. Float = "float",
  44163. Float2 = "float2",
  44164. Float3 = "float3",
  44165. Float4 = "float4",
  44166. Uint = "uint",
  44167. Uint2 = "uint2",
  44168. Uint3 = "uint3",
  44169. Uint4 = "uint4",
  44170. Int = "int",
  44171. Int2 = "int2",
  44172. Int3 = "int3",
  44173. Int4 = "int4"
  44174. }
  44175. /** @hidden */
  44176. export enum TextureAspect {
  44177. All = "all",
  44178. StencilOnly = "stencil-only",
  44179. DepthOnly = "depth-only"
  44180. }
  44181. /** @hidden */
  44182. export enum CompilationMessageType {
  44183. Error = "error",
  44184. Warning = "warning",
  44185. Info = "info"
  44186. }
  44187. /** @hidden */
  44188. export enum QueryType {
  44189. Occlusion = "occlusion"
  44190. }
  44191. /** @hidden */
  44192. export enum BufferUsage {
  44193. MapRead = 1,
  44194. MapWrite = 2,
  44195. CopySrc = 4,
  44196. CopyDst = 8,
  44197. Index = 16,
  44198. Vertex = 32,
  44199. Uniform = 64,
  44200. Storage = 128,
  44201. Indirect = 256,
  44202. QueryResolve = 512
  44203. }
  44204. /** @hidden */
  44205. export enum ColorWrite {
  44206. Red = 1,
  44207. Green = 2,
  44208. Blue = 4,
  44209. Alpha = 8,
  44210. All = 15
  44211. }
  44212. /** @hidden */
  44213. export enum ShaderStage {
  44214. Vertex = 1,
  44215. Fragment = 2,
  44216. Compute = 4
  44217. }
  44218. /** @hidden */
  44219. export enum TextureUsage {
  44220. CopySrc = 1,
  44221. CopyDst = 2,
  44222. Sampled = 4,
  44223. Storage = 8,
  44224. OutputAttachment = 16
  44225. }
  44226. /** @hidden */
  44227. export enum MapMode {
  44228. Read = 1,
  44229. Write = 2
  44230. }
  44231. }
  44232. declare module BABYLON {
  44233. /** @hidden */
  44234. export interface WebGPUBindingInfo {
  44235. setIndex: number;
  44236. bindingIndex: number;
  44237. }
  44238. /** @hidden */
  44239. export interface WebGPUTextureSamplerBindingDescription {
  44240. sampler: WebGPUBindingInfo;
  44241. isTextureArray: boolean;
  44242. textures: Array<WebGPUBindingInfo>;
  44243. }
  44244. /** @hidden
  44245. * If the binding is a UBO, isSampler=isTexture=false
  44246. */
  44247. export interface WebGPUBindingDescription {
  44248. name: string;
  44249. usedInVertex: boolean;
  44250. usedInFragment: boolean;
  44251. isSampler: boolean;
  44252. isComparisonSampler?: boolean;
  44253. isTexture: boolean;
  44254. componentType?: GPUTextureComponentType;
  44255. textureDimension?: GPUTextureViewDimension;
  44256. }
  44257. /**
  44258. * @hidden
  44259. */
  44260. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44261. uboNextBindingIndex: number;
  44262. freeSetIndex: number;
  44263. freeBindingIndex: number;
  44264. availableVaryings: {
  44265. [key: string]: number;
  44266. };
  44267. availableAttributes: {
  44268. [key: string]: number;
  44269. };
  44270. availableUBOs: {
  44271. [key: string]: {
  44272. setIndex: number;
  44273. bindingIndex: number;
  44274. };
  44275. };
  44276. availableSamplers: {
  44277. [key: string]: WebGPUTextureSamplerBindingDescription;
  44278. };
  44279. leftOverUniforms: {
  44280. name: string;
  44281. type: string;
  44282. length: number;
  44283. }[];
  44284. orderedAttributes: string[];
  44285. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44286. uniformBufferNames: string[];
  44287. private _attributeNextLocation;
  44288. private _varyingNextLocation;
  44289. constructor();
  44290. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44291. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44292. getNextFreeUBOBinding(): {
  44293. setIndex: number;
  44294. bindingIndex: number;
  44295. };
  44296. private _getNextFreeBinding;
  44297. }
  44298. }
  44299. declare module BABYLON {
  44300. /** @hidden */
  44301. export interface IWebGPUPipelineContextSamplerCache {
  44302. samplerBinding: number;
  44303. firstTextureName: string;
  44304. }
  44305. /** @hidden */
  44306. export interface IWebGPUPipelineContextTextureCache {
  44307. textureBinding: number;
  44308. texture: InternalTexture;
  44309. }
  44310. /** @hidden */
  44311. export interface IWebGPUPipelineContextVertexInputsCache {
  44312. indexBuffer: Nullable<GPUBuffer>;
  44313. indexOffset: number;
  44314. vertexStartSlot: number;
  44315. vertexBuffers: GPUBuffer[];
  44316. vertexOffsets: number[];
  44317. }
  44318. /** @hidden */
  44319. export interface IWebGPURenderPipelineStageDescriptor {
  44320. vertexStage: GPUProgrammableStageDescriptor;
  44321. fragmentStage?: GPUProgrammableStageDescriptor;
  44322. }
  44323. /** @hidden */
  44324. export class WebGPUPipelineContext implements IPipelineContext {
  44325. engine: WebGPUEngine;
  44326. shaderProcessingContext: WebGPUShaderProcessingContext;
  44327. leftOverUniformsByName: {
  44328. [name: string]: string;
  44329. };
  44330. sources: {
  44331. vertex: string;
  44332. fragment: string;
  44333. rawVertex: string;
  44334. rawFragment: string;
  44335. };
  44336. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44337. samplers: {
  44338. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44339. };
  44340. textures: {
  44341. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44342. };
  44343. bindGroupLayouts: GPUBindGroupLayout[];
  44344. bindGroupsCache: {
  44345. [key: string]: GPUBindGroup[];
  44346. };
  44347. /**
  44348. * Stores the uniform buffer
  44349. */
  44350. uniformBuffer: Nullable<UniformBuffer>;
  44351. onCompiled?: () => void;
  44352. get isAsync(): boolean;
  44353. get isReady(): boolean;
  44354. /** @hidden */
  44355. _name: string;
  44356. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44357. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44358. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44359. [key: string]: number;
  44360. }, uniformsNames: string[], uniforms: {
  44361. [key: string]: Nullable<WebGLUniformLocation>;
  44362. }, samplerList: string[], samplers: {
  44363. [key: string]: number;
  44364. }, attributesNames: string[], attributes: number[]): void;
  44365. /** @hidden */
  44366. /**
  44367. * Build the uniform buffer used in the material.
  44368. */
  44369. buildUniformLayout(): void;
  44370. /**
  44371. * Release all associated resources.
  44372. **/
  44373. dispose(): void;
  44374. /**
  44375. * Sets an integer value on a uniform variable.
  44376. * @param uniformName Name of the variable.
  44377. * @param value Value to be set.
  44378. */
  44379. setInt(uniformName: string, value: number): void;
  44380. /**
  44381. * Sets an int2 value on a uniform variable.
  44382. * @param uniformName Name of the variable.
  44383. * @param x First int in int2.
  44384. * @param y Second int in int2.
  44385. */
  44386. setInt2(uniformName: string, x: number, y: number): void;
  44387. /**
  44388. * Sets an int3 value on a uniform variable.
  44389. * @param uniformName Name of the variable.
  44390. * @param x First int in int3.
  44391. * @param y Second int in int3.
  44392. * @param z Third int in int3.
  44393. */
  44394. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44395. /**
  44396. * Sets an int4 value on a uniform variable.
  44397. * @param uniformName Name of the variable.
  44398. * @param x First int in int4.
  44399. * @param y Second int in int4.
  44400. * @param z Third int in int4.
  44401. * @param w Fourth int in int4.
  44402. */
  44403. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44404. /**
  44405. * Sets an int array on a uniform variable.
  44406. * @param uniformName Name of the variable.
  44407. * @param array array to be set.
  44408. */
  44409. setIntArray(uniformName: string, array: Int32Array): void;
  44410. /**
  44411. * 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)
  44412. * @param uniformName Name of the variable.
  44413. * @param array array to be set.
  44414. */
  44415. setIntArray2(uniformName: string, array: Int32Array): void;
  44416. /**
  44417. * 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)
  44418. * @param uniformName Name of the variable.
  44419. * @param array array to be set.
  44420. */
  44421. setIntArray3(uniformName: string, array: Int32Array): void;
  44422. /**
  44423. * 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)
  44424. * @param uniformName Name of the variable.
  44425. * @param array array to be set.
  44426. */
  44427. setIntArray4(uniformName: string, array: Int32Array): void;
  44428. /**
  44429. * Sets an array on a uniform variable.
  44430. * @param uniformName Name of the variable.
  44431. * @param array array to be set.
  44432. */
  44433. setArray(uniformName: string, array: number[]): void;
  44434. /**
  44435. * 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)
  44436. * @param uniformName Name of the variable.
  44437. * @param array array to be set.
  44438. */
  44439. setArray2(uniformName: string, array: number[]): void;
  44440. /**
  44441. * 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)
  44442. * @param uniformName Name of the variable.
  44443. * @param array array to be set.
  44444. * @returns this effect.
  44445. */
  44446. setArray3(uniformName: string, array: number[]): void;
  44447. /**
  44448. * 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)
  44449. * @param uniformName Name of the variable.
  44450. * @param array array to be set.
  44451. */
  44452. setArray4(uniformName: string, array: number[]): void;
  44453. /**
  44454. * Sets matrices on a uniform variable.
  44455. * @param uniformName Name of the variable.
  44456. * @param matrices matrices to be set.
  44457. */
  44458. setMatrices(uniformName: string, matrices: Float32Array): void;
  44459. /**
  44460. * Sets matrix on a uniform variable.
  44461. * @param uniformName Name of the variable.
  44462. * @param matrix matrix to be set.
  44463. */
  44464. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44465. /**
  44466. * 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)
  44467. * @param uniformName Name of the variable.
  44468. * @param matrix matrix to be set.
  44469. */
  44470. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44471. /**
  44472. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44473. * @param uniformName Name of the variable.
  44474. * @param matrix matrix to be set.
  44475. */
  44476. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44477. /**
  44478. * Sets a float on a uniform variable.
  44479. * @param uniformName Name of the variable.
  44480. * @param value value to be set.
  44481. * @returns this effect.
  44482. */
  44483. setFloat(uniformName: string, value: number): void;
  44484. /**
  44485. * Sets a Vector2 on a uniform variable.
  44486. * @param uniformName Name of the variable.
  44487. * @param vector2 vector2 to be set.
  44488. */
  44489. setVector2(uniformName: string, vector2: IVector2Like): void;
  44490. /**
  44491. * Sets a float2 on a uniform variable.
  44492. * @param uniformName Name of the variable.
  44493. * @param x First float in float2.
  44494. * @param y Second float in float2.
  44495. */
  44496. setFloat2(uniformName: string, x: number, y: number): void;
  44497. /**
  44498. * Sets a Vector3 on a uniform variable.
  44499. * @param uniformName Name of the variable.
  44500. * @param vector3 Value to be set.
  44501. */
  44502. setVector3(uniformName: string, vector3: IVector3Like): void;
  44503. /**
  44504. * Sets a float3 on a uniform variable.
  44505. * @param uniformName Name of the variable.
  44506. * @param x First float in float3.
  44507. * @param y Second float in float3.
  44508. * @param z Third float in float3.
  44509. */
  44510. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44511. /**
  44512. * Sets a Vector4 on a uniform variable.
  44513. * @param uniformName Name of the variable.
  44514. * @param vector4 Value to be set.
  44515. */
  44516. setVector4(uniformName: string, vector4: IVector4Like): void;
  44517. /**
  44518. * Sets a float4 on a uniform variable.
  44519. * @param uniformName Name of the variable.
  44520. * @param x First float in float4.
  44521. * @param y Second float in float4.
  44522. * @param z Third float in float4.
  44523. * @param w Fourth float in float4.
  44524. * @returns this effect.
  44525. */
  44526. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44527. /**
  44528. * Sets a Color3 on a uniform variable.
  44529. * @param uniformName Name of the variable.
  44530. * @param color3 Value to be set.
  44531. */
  44532. setColor3(uniformName: string, color3: IColor3Like): void;
  44533. /**
  44534. * Sets a Color4 on a uniform variable.
  44535. * @param uniformName Name of the variable.
  44536. * @param color3 Value to be set.
  44537. * @param alpha Alpha value to be set.
  44538. */
  44539. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44540. /**
  44541. * Sets a Color4 on a uniform variable
  44542. * @param uniformName defines the name of the variable
  44543. * @param color4 defines the value to be set
  44544. */
  44545. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44546. _getVertexShaderCode(): string | null;
  44547. _getFragmentShaderCode(): string | null;
  44548. }
  44549. }
  44550. declare module BABYLON {
  44551. /** @hidden */
  44552. export class WebGPUDataBuffer extends DataBuffer {
  44553. private _buffer;
  44554. constructor(resource: GPUBuffer);
  44555. get underlyingResource(): any;
  44556. }
  44557. }
  44558. declare module BABYLON {
  44559. /**
  44560. * Class used to inline functions in shader code
  44561. */
  44562. export class ShaderCodeInliner {
  44563. private static readonly _RegexpFindFunctionNameAndType;
  44564. private _sourceCode;
  44565. private _functionDescr;
  44566. private _numMaxIterations;
  44567. /** Gets or sets the token used to mark the functions to inline */
  44568. inlineToken: string;
  44569. /** Gets or sets the debug mode */
  44570. debug: boolean;
  44571. /** Gets the code after the inlining process */
  44572. get code(): string;
  44573. /**
  44574. * Initializes the inliner
  44575. * @param sourceCode shader code source to inline
  44576. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44577. */
  44578. constructor(sourceCode: string, numMaxIterations?: number);
  44579. /**
  44580. * Start the processing of the shader code
  44581. */
  44582. processCode(): void;
  44583. private _collectFunctions;
  44584. private _processInlining;
  44585. private _extractBetweenMarkers;
  44586. private _skipWhitespaces;
  44587. private _isIdentifierChar;
  44588. private _removeComments;
  44589. private _replaceFunctionCallsByCode;
  44590. private _findBackward;
  44591. private _escapeRegExp;
  44592. private _replaceNames;
  44593. }
  44594. }
  44595. declare module BABYLON {
  44596. /** @hidden */
  44597. export class WebGPUShaderProcessor implements IShaderProcessor {
  44598. protected _missingVaryings: Array<string>;
  44599. protected _textureArrayProcessing: Array<string>;
  44600. protected _preProcessors: {
  44601. [key: string]: string;
  44602. };
  44603. private _getArraySize;
  44604. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44605. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44606. [key: string]: string;
  44607. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44608. attributeProcessor(attribute: string, preProcessors: {
  44609. [key: string]: string;
  44610. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44611. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44612. [key: string]: string;
  44613. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44614. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44615. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44616. private _applyTextureArrayProcessing;
  44617. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44618. vertexCode: string;
  44619. fragmentCode: string;
  44620. };
  44621. }
  44622. }
  44623. declare module BABYLON {
  44624. /** @hidden */
  44625. export class WebGPUBufferManager {
  44626. private _device;
  44627. private _deferredReleaseBuffers;
  44628. private static _IsGPUBuffer;
  44629. constructor(device: GPUDevice);
  44630. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44631. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44632. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44633. private _FromHalfFloat;
  44634. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44635. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44636. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44637. destroyDeferredBuffers(): void;
  44638. }
  44639. }
  44640. declare module BABYLON {
  44641. /** @hidden */
  44642. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44643. private _webgpuTexture;
  44644. private _webgpuMSAATexture;
  44645. get underlyingResource(): Nullable<GPUTexture>;
  44646. get msaaTexture(): Nullable<GPUTexture>;
  44647. set msaaTexture(texture: Nullable<GPUTexture>);
  44648. view: Nullable<GPUTextureView>;
  44649. format: GPUTextureFormat;
  44650. textureUsages: number;
  44651. constructor(existingTexture?: Nullable<GPUTexture>);
  44652. set(hardwareTexture: GPUTexture): void;
  44653. setMSAATexture(hardwareTexture: GPUTexture): void;
  44654. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44655. createView(descriptor?: GPUTextureViewDescriptor): void;
  44656. reset(): void;
  44657. release(): void;
  44658. }
  44659. }
  44660. declare module BABYLON {
  44661. /** @hidden */
  44662. export class WebGPUTextureHelper {
  44663. private _device;
  44664. private _glslang;
  44665. private _bufferManager;
  44666. private _mipmapSampler;
  44667. private _invertYPreMultiplyAlphaSampler;
  44668. private _pipelines;
  44669. private _compiledShaders;
  44670. private _deferredReleaseTextures;
  44671. private _commandEncoderForCreation;
  44672. static ComputeNumMipmapLevels(width: number, height: number): number;
  44673. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44674. private _getPipeline;
  44675. private static _GetTextureTypeFromFormat;
  44676. private static _GetBlockInformationFromFormat;
  44677. private static _IsHardwareTexture;
  44678. private static _IsInternalTexture;
  44679. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44680. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44681. width: number;
  44682. height: number;
  44683. }): imageBitmap is ImageBitmap;
  44684. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44685. width: number;
  44686. height: number;
  44687. }): imageBitmap is ImageBitmap[];
  44688. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44689. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44690. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44691. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44692. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44693. createTexture(imageBitmap: ImageBitmap | {
  44694. width: number;
  44695. height: number;
  44696. layers: number;
  44697. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44698. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44699. width: number;
  44700. height: number;
  44701. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44702. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44703. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44704. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44705. createMSAATexture(texture: InternalTexture, samples: number): void;
  44706. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44707. 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;
  44708. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44709. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44710. destroyDeferredTextures(): void;
  44711. }
  44712. }
  44713. declare module BABYLON {
  44714. /** @hidden */
  44715. export class WebGPURenderPassWrapper {
  44716. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44717. renderPass: Nullable<GPURenderPassEncoder>;
  44718. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44719. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44720. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44721. depthTextureFormat: GPUTextureFormat | undefined;
  44722. constructor();
  44723. reset(fullReset?: boolean): void;
  44724. }
  44725. }
  44726. declare module BABYLON {
  44727. /** @hidden */
  44728. export class WebGPUCacheSampler {
  44729. private _samplers;
  44730. private _device;
  44731. disabled: boolean;
  44732. constructor(device: GPUDevice);
  44733. private static _GetSamplerHashCode;
  44734. private static _GetSamplerFilterDescriptor;
  44735. private static _GetWrappingMode;
  44736. private static _GetSamplerWrappingDescriptor;
  44737. private static _GetSamplerDescriptor;
  44738. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  44739. }
  44740. }
  44741. declare module BABYLON {
  44742. /** @hidden */
  44743. export class WebGPUShaderManager {
  44744. private _shaders;
  44745. private _device;
  44746. constructor(device: GPUDevice);
  44747. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  44748. }
  44749. }
  44750. declare module BABYLON {
  44751. /** @hidden */
  44752. export class WebGPUCacheRenderPipeline {
  44753. static NumCacheHitWithoutHash: number;
  44754. static NumCacheHitWithHash: number;
  44755. static NumCacheMiss: number;
  44756. static NumPipelineCreationLastFrame: number;
  44757. disabled: boolean;
  44758. private static _Cache;
  44759. private static _NumPipelineCreationCurrentFrame;
  44760. private _device;
  44761. private _states;
  44762. private _isDirty;
  44763. private _currentRenderPipeline;
  44764. private _emptyVertexBuffer;
  44765. private _shaderId;
  44766. private _alphaToCoverageEnabled;
  44767. private _frontFace;
  44768. private _cullEnabled;
  44769. private _cullFace;
  44770. private _clampDepth;
  44771. private _rasterizationState;
  44772. private _depthBias;
  44773. private _depthBiasClamp;
  44774. private _depthBiasSlopeScale;
  44775. private _colorFormat;
  44776. private _webgpuColorFormat;
  44777. private _mrtAttachments1;
  44778. private _mrtAttachments2;
  44779. private _mrtFormats;
  44780. private _alphaBlendEnabled;
  44781. private _alphaBlendFuncParams;
  44782. private _alphaBlendEqParams;
  44783. private _writeMask;
  44784. private _colorStates;
  44785. private _depthStencilFormat;
  44786. private _webgpuDepthStencilFormat;
  44787. private _depthTestEnabled;
  44788. private _depthWriteEnabled;
  44789. private _depthCompare;
  44790. private _stencilEnabled;
  44791. private _stencilFrontCompare;
  44792. private _stencilFrontDepthFailOp;
  44793. private _stencilFrontPassOp;
  44794. private _stencilFrontFailOp;
  44795. private _stencilReadMask;
  44796. private _stencilWriteMask;
  44797. private _depthStencilState;
  44798. private _vertexBuffers;
  44799. private _indexBuffer;
  44800. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  44801. reset(): void;
  44802. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  44803. endFrame(): void;
  44804. setAlphaToCoverage(enabled: boolean): void;
  44805. setFrontFace(frontFace: number): void;
  44806. setCullEnabled(enabled: boolean): void;
  44807. setCullFace(cullFace: number): void;
  44808. setClampDepth(clampDepth: boolean): void;
  44809. resetDepthCullingState(): void;
  44810. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  44811. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  44812. setColorFormat(format: GPUTextureFormat): void;
  44813. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  44814. setAlphaBlendEnabled(enabled: boolean): void;
  44815. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  44816. setWriteMask(mask: number): void;
  44817. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  44818. setDepthTestEnabled(enabled: boolean): void;
  44819. setDepthWriteEnabled(enabled: boolean): void;
  44820. setDepthCompare(func: Nullable<number>): void;
  44821. setStencilEnabled(enabled: boolean): void;
  44822. setStencilCompare(func: Nullable<number>): void;
  44823. setStencilDepthFailOp(op: Nullable<number>): void;
  44824. setStencilPassOp(op: Nullable<number>): void;
  44825. setStencilFailOp(op: Nullable<number>): void;
  44826. setStencilReadMask(mask: number): void;
  44827. setStencilWriteMask(mask: number): void;
  44828. resetStencilState(): void;
  44829. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  44830. setBuffers(vertexBuffers: Nullable<{
  44831. [key: string]: Nullable<VertexBuffer>;
  44832. }>, indexBuffer: Nullable<DataBuffer>): void;
  44833. private static _GetTopology;
  44834. private static _GetAphaBlendOperation;
  44835. private static _GetAphaBlendFactor;
  44836. private static _GetCompareFunction;
  44837. private static _GetStencilOpFunction;
  44838. private static _GetVertexInputDescriptorFormat;
  44839. private _getAphaBlendState;
  44840. private _getColorBlendState;
  44841. private _setShaderStage;
  44842. private _setRasterizationState;
  44843. private _setColorStates;
  44844. private _setDepthStencilState;
  44845. private _setVertexState;
  44846. private _createPipelineLayout;
  44847. private _getVertexInputDescriptor;
  44848. private _createRenderPipeline;
  44849. }
  44850. }
  44851. declare module BABYLON {
  44852. /** @hidden */
  44853. export var clearQuadVertexShader: {
  44854. name: string;
  44855. shader: string;
  44856. };
  44857. }
  44858. declare module BABYLON {
  44859. /** @hidden */
  44860. export var clearQuadPixelShader: {
  44861. name: string;
  44862. shader: string;
  44863. };
  44864. }
  44865. declare module BABYLON {
  44866. /**
  44867. * Options to load the associated Glslang library
  44868. */
  44869. export interface GlslangOptions {
  44870. /**
  44871. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  44872. */
  44873. glslang?: any;
  44874. /**
  44875. * Defines the URL of the glslang JS File.
  44876. */
  44877. jsPath?: string;
  44878. /**
  44879. * Defines the URL of the glslang WASM File.
  44880. */
  44881. wasmPath?: string;
  44882. }
  44883. /**
  44884. * Options to create the WebGPU engine
  44885. */
  44886. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  44887. /**
  44888. * If delta time between frames should be constant
  44889. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44890. */
  44891. deterministicLockstep?: boolean;
  44892. /**
  44893. * Maximum about of steps between frames (Default: 4)
  44894. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44895. */
  44896. lockstepMaxSteps?: number;
  44897. /**
  44898. * Defines the seconds between each deterministic lock step
  44899. */
  44900. timeStep?: number;
  44901. /**
  44902. * Defines that engine should ignore modifying touch action attribute and style
  44903. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  44904. */
  44905. doNotHandleTouchAction?: boolean;
  44906. /**
  44907. * Defines if webaudio should be initialized as well
  44908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  44909. */
  44910. audioEngine?: boolean;
  44911. /**
  44912. * Defines the category of adapter to use.
  44913. * Is it the discrete or integrated device.
  44914. */
  44915. powerPreference?: GPUPowerPreference;
  44916. /**
  44917. * Defines the device descriptor used to create a device.
  44918. */
  44919. deviceDescriptor?: GPUDeviceDescriptor;
  44920. /**
  44921. * Defines the requested Swap Chain Format.
  44922. */
  44923. swapChainFormat?: GPUTextureFormat;
  44924. /**
  44925. * Defines wether MSAA is enabled on the canvas.
  44926. */
  44927. antialiasing?: boolean;
  44928. /**
  44929. * Defines wether the stencil buffer should be enabled.
  44930. */
  44931. stencil?: boolean;
  44932. /**
  44933. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  44934. */
  44935. enableGPUDebugMarkers?: boolean;
  44936. /**
  44937. * Options to load the associated Glslang library
  44938. */
  44939. glslangOptions?: GlslangOptions;
  44940. }
  44941. /**
  44942. * The web GPU engine class provides support for WebGPU version of babylon.js.
  44943. */
  44944. export class WebGPUEngine extends Engine {
  44945. private static readonly _glslangDefaultOptions;
  44946. private readonly _uploadEncoderDescriptor;
  44947. private readonly _renderEncoderDescriptor;
  44948. private readonly _renderTargetEncoderDescriptor;
  44949. private readonly _clearDepthValue;
  44950. private readonly _clearReverseDepthValue;
  44951. private readonly _clearStencilValue;
  44952. private readonly _defaultSampleCount;
  44953. private _canvas;
  44954. private _options;
  44955. private _glslang;
  44956. private _adapter;
  44957. private _adapterSupportedExtensions;
  44958. private _device;
  44959. private _deviceEnabledExtensions;
  44960. private _context;
  44961. private _swapChain;
  44962. private _swapChainTexture;
  44963. private _mainPassSampleCount;
  44964. private _textureHelper;
  44965. private _bufferManager;
  44966. private _shaderManager;
  44967. private _cacheSampler;
  44968. private _cacheRenderPipeline;
  44969. private _emptyVertexBuffer;
  44970. private _lastCachedWrapU;
  44971. private _lastCachedWrapV;
  44972. private _lastCachedWrapR;
  44973. private _mrtAttachments;
  44974. private _counters;
  44975. private _mainTexture;
  44976. private _depthTexture;
  44977. private _mainTextureExtends;
  44978. private _depthTextureFormat;
  44979. private _colorFormat;
  44980. private _uploadEncoder;
  44981. private _renderEncoder;
  44982. private _renderTargetEncoder;
  44983. private _commandBuffers;
  44984. private _currentRenderPass;
  44985. private _mainRenderPassWrapper;
  44986. private _rttRenderPassWrapper;
  44987. private _pendingDebugCommands;
  44988. private _currentVertexBuffers;
  44989. private _currentIndexBuffer;
  44990. private __colorWrite;
  44991. private _uniformsBuffers;
  44992. private _forceEnableEffect;
  44993. /** @hidden */
  44994. dbgShowShaderCode: boolean;
  44995. /** @hidden */
  44996. dbgSanityChecks: boolean;
  44997. /** @hidden */
  44998. dbgGenerateLogs: boolean;
  44999. /** @hidden */
  45000. dbgVerboseLogsForFirstFrames: boolean;
  45001. /** @hidden */
  45002. dbgVerboseLogsNumFrames: number;
  45003. /** @hidden */
  45004. dbgShowWarningsNotImplemented: boolean;
  45005. /**
  45006. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  45007. */
  45008. get disableCacheSamplers(): boolean;
  45009. set disableCacheSamplers(disable: boolean);
  45010. /**
  45011. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  45012. */
  45013. get disableCacheRenderPipelines(): boolean;
  45014. set disableCacheRenderPipelines(disable: boolean);
  45015. /**
  45016. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  45017. * @returns true if the engine can be created
  45018. */
  45019. static get IsSupported(): boolean;
  45020. /**
  45021. * Gets a boolean indicating that the engine supports uniform buffers
  45022. */
  45023. get supportsUniformBuffers(): boolean;
  45024. /** Gets the supported extensions by the WebGPU adapter */
  45025. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  45026. /** Gets the currently enabled extensions on the WebGPU device */
  45027. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  45028. /**
  45029. * Returns the name of the engine
  45030. */
  45031. get name(): string;
  45032. /**
  45033. * Returns a string describing the current engine
  45034. */
  45035. get description(): string;
  45036. /**
  45037. * Returns the version of the engine
  45038. */
  45039. get version(): number;
  45040. /**
  45041. * Create a new instance of the gpu engine asynchronously
  45042. * @param canvas Defines the canvas to use to display the result
  45043. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45044. * @returns a promise that resolves with the created engine
  45045. */
  45046. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45047. /**
  45048. * Create a new instance of the gpu engine.
  45049. * @param canvas Defines the canvas to use to display the result
  45050. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45051. */
  45052. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45053. /**
  45054. * Initializes the WebGPU context and dependencies.
  45055. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45056. * @returns a promise notifying the readiness of the engine.
  45057. */
  45058. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45059. private _initGlslang;
  45060. private _initializeLimits;
  45061. private _initializeContextAndSwapChain;
  45062. private _initializeMainAttachments;
  45063. /**
  45064. * Force a specific size of the canvas
  45065. * @param width defines the new canvas' width
  45066. * @param height defines the new canvas' height
  45067. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45068. * @returns true if the size was changed
  45069. */
  45070. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45071. /**
  45072. * Gets a shader processor implementation fitting with the current engine type.
  45073. * @returns The shader processor implementation.
  45074. */
  45075. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45076. /** @hidden */
  45077. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45078. /**
  45079. * Force the entire cache to be cleared
  45080. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45081. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45082. */
  45083. wipeCaches(bruteForce?: boolean): void;
  45084. /**
  45085. * Enable or disable color writing
  45086. * @param enable defines the state to set
  45087. */
  45088. setColorWrite(enable: boolean): void;
  45089. /**
  45090. * Gets a boolean indicating if color writing is enabled
  45091. * @returns the current color writing state
  45092. */
  45093. getColorWrite(): boolean;
  45094. private _viewportsCurrent;
  45095. private _resetCurrentViewport;
  45096. private _applyViewport;
  45097. /** @hidden */
  45098. _viewport(x: number, y: number, width: number, height: number): void;
  45099. private _scissorsCurrent;
  45100. protected _scissorCached: {
  45101. x: number;
  45102. y: number;
  45103. z: number;
  45104. w: number;
  45105. };
  45106. private _resetCurrentScissor;
  45107. private _applyScissor;
  45108. private _scissorIsActive;
  45109. enableScissor(x: number, y: number, width: number, height: number): void;
  45110. disableScissor(): void;
  45111. /**
  45112. * Clear the current render buffer or the current render target (if any is set up)
  45113. * @param color defines the color to use
  45114. * @param backBuffer defines if the back buffer must be cleared
  45115. * @param depth defines if the depth buffer must be cleared
  45116. * @param stencil defines if the stencil buffer must be cleared
  45117. */
  45118. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45119. /**
  45120. * Clears a list of attachments
  45121. * @param attachments list of the attachments
  45122. * @param colorMain clear color for the main attachment (the first one)
  45123. * @param colorOthers clear color for the other attachments
  45124. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45125. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45126. */
  45127. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45128. /**
  45129. * Creates a vertex buffer
  45130. * @param data the data for the vertex buffer
  45131. * @returns the new buffer
  45132. */
  45133. createVertexBuffer(data: DataArray): DataBuffer;
  45134. /**
  45135. * Creates a vertex buffer
  45136. * @param data the data for the dynamic vertex buffer
  45137. * @returns the new buffer
  45138. */
  45139. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45140. /**
  45141. * Updates a vertex buffer.
  45142. * @param vertexBuffer the vertex buffer to update
  45143. * @param data the data used to update the vertex buffer
  45144. * @param byteOffset the byte offset of the data
  45145. * @param byteLength the byte length of the data
  45146. */
  45147. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45148. /**
  45149. * Creates a new index buffer
  45150. * @param indices defines the content of the index buffer
  45151. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45152. * @returns a new buffer
  45153. */
  45154. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45155. /**
  45156. * Update an index buffer
  45157. * @param indexBuffer defines the target index buffer
  45158. * @param indices defines the data to update
  45159. * @param offset defines the offset in the target index buffer where update should start
  45160. */
  45161. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45162. /** @hidden */
  45163. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45164. /** @hidden */
  45165. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45166. /**
  45167. * Bind a list of vertex buffers with the engine
  45168. * @param vertexBuffers defines the list of vertex buffers to bind
  45169. * @param indexBuffer defines the index buffer to bind
  45170. * @param effect defines the effect associated with the vertex buffers
  45171. */
  45172. bindBuffers(vertexBuffers: {
  45173. [key: string]: Nullable<VertexBuffer>;
  45174. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  45175. /** @hidden */
  45176. _releaseBuffer(buffer: DataBuffer): boolean;
  45177. createUniformBuffer(elements: FloatArray): DataBuffer;
  45178. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45179. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45180. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45181. /**
  45182. * Create a new effect (used to store vertex/fragment shaders)
  45183. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45184. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45185. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45186. * @param samplers defines an array of string used to represent textures
  45187. * @param defines defines the string containing the defines to use to compile the shaders
  45188. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  45189. * @param onCompiled defines a function to call when the effect creation is successful
  45190. * @param onError defines a function to call when the effect creation has failed
  45191. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45192. * @returns the new Effect
  45193. */
  45194. 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;
  45195. private _compileRawShaderToSpirV;
  45196. private _compileShaderToSpirV;
  45197. private _createPipelineStageDescriptor;
  45198. private _compileRawPipelineStageDescriptor;
  45199. private _compilePipelineStageDescriptor;
  45200. /** @hidden */
  45201. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45202. /** @hidden */
  45203. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45204. /**
  45205. * Creates a new pipeline context
  45206. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45207. * @returns the new pipeline
  45208. */
  45209. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45210. /** @hidden */
  45211. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45212. /**
  45213. * Gets the list of active attributes for a given WebGPU program
  45214. * @param pipelineContext defines the pipeline context to use
  45215. * @param attributesNames defines the list of attribute names to get
  45216. * @returns an array of indices indicating the offset of each attribute
  45217. */
  45218. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45219. /**
  45220. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45221. * @param effect defines the effect to activate
  45222. */
  45223. enableEffect(effect: Nullable<Effect>): void;
  45224. /** @hidden */
  45225. _releaseEffect(effect: Effect): void;
  45226. /**
  45227. * 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
  45228. */
  45229. releaseEffects(): void;
  45230. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45231. /**
  45232. * Gets a boolean indicating that only power of 2 textures are supported
  45233. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45234. */
  45235. get needPOTTextures(): boolean;
  45236. /** @hidden */
  45237. _createHardwareTexture(): HardwareTextureWrapper;
  45238. /** @hidden */
  45239. _releaseTexture(texture: InternalTexture): void;
  45240. /** @hidden */
  45241. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45242. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45243. /**
  45244. * Usually called from Texture.ts.
  45245. * Passed information to create a hardware texture
  45246. * @param url defines a value which contains one of the following:
  45247. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45248. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45249. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45250. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45251. * @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)
  45252. * @param scene needed for loading to the correct scene
  45253. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45254. * @param onLoad optional callback to be called upon successful completion
  45255. * @param onError optional callback to be called upon failure
  45256. * @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
  45257. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45258. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45259. * @param forcedExtension defines the extension to use to pick the right loader
  45260. * @param mimeType defines an optional mime type
  45261. * @param loaderOptions options to be passed to the loader
  45262. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45263. */
  45264. 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;
  45265. /** @hidden */
  45266. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45267. /**
  45268. * Creates a cube texture
  45269. * @param rootUrl defines the url where the files to load is located
  45270. * @param scene defines the current scene
  45271. * @param files defines the list of files to load (1 per face)
  45272. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45273. * @param onLoad defines an optional callback raised when the texture is loaded
  45274. * @param onError defines an optional callback raised if there is an issue to load the texture
  45275. * @param format defines the format of the data
  45276. * @param forcedExtension defines the extension to use to pick the right loader
  45277. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45278. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45279. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45280. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45281. * @param loaderOptions options to be passed to the loader
  45282. * @returns the cube texture as an InternalTexture
  45283. */
  45284. 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;
  45285. /**
  45286. * Creates a raw texture
  45287. * @param data defines the data to store in the texture
  45288. * @param width defines the width of the texture
  45289. * @param height defines the height of the texture
  45290. * @param format defines the format of the data
  45291. * @param generateMipMaps defines if the engine should generate the mip levels
  45292. * @param invertY defines if data must be stored with Y axis inverted
  45293. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45294. * @param compression defines the compression used (null by default)
  45295. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45296. * @returns the raw texture inside an InternalTexture
  45297. */
  45298. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45299. /**
  45300. * Creates a new raw cube texture
  45301. * @param data defines the array of data to use to create each face
  45302. * @param size defines the size of the textures
  45303. * @param format defines the format of the data
  45304. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45305. * @param generateMipMaps defines if the engine should generate the mip levels
  45306. * @param invertY defines if data must be stored with Y axis inverted
  45307. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45308. * @param compression defines the compression used (null by default)
  45309. * @returns the cube texture as an InternalTexture
  45310. */
  45311. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45312. /**
  45313. * Creates a new raw cube texture from a specified url
  45314. * @param url defines the url where the data is located
  45315. * @param scene defines the current scene
  45316. * @param size defines the size of the textures
  45317. * @param format defines the format of the data
  45318. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45319. * @param noMipmap defines if the engine should avoid generating the mip levels
  45320. * @param callback defines a callback used to extract texture data from loaded data
  45321. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45322. * @param onLoad defines a callback called when texture is loaded
  45323. * @param onError defines a callback called if there is an error
  45324. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45325. * @param invertY defines if data must be stored with Y axis inverted
  45326. * @returns the cube texture as an InternalTexture
  45327. */
  45328. 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;
  45329. /**
  45330. * Creates a new raw 2D array texture
  45331. * @param data defines the data used to create the texture
  45332. * @param width defines the width of the texture
  45333. * @param height defines the height of the texture
  45334. * @param depth defines the number of layers of the texture
  45335. * @param format defines the format of the texture
  45336. * @param generateMipMaps defines if the engine must generate mip levels
  45337. * @param invertY defines if data must be stored with Y axis inverted
  45338. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45339. * @param compression defines the compressed used (can be null)
  45340. * @param textureType defines the compressed used (can be null)
  45341. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45342. */
  45343. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45344. /**
  45345. * Creates a new raw 3D texture
  45346. * @param data defines the data used to create the texture
  45347. * @param width defines the width of the texture
  45348. * @param height defines the height of the texture
  45349. * @param depth defines the depth of the texture
  45350. * @param format defines the format of the texture
  45351. * @param generateMipMaps defines if the engine must generate mip levels
  45352. * @param invertY defines if data must be stored with Y axis inverted
  45353. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45354. * @param compression defines the compressed used (can be null)
  45355. * @param textureType defines the compressed used (can be null)
  45356. * @returns a new raw 3D texture (stored in an InternalTexture)
  45357. */
  45358. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45359. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45360. /**
  45361. * Update the sampling mode of a given texture
  45362. * @param samplingMode defines the required sampling mode
  45363. * @param texture defines the texture to update
  45364. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45365. */
  45366. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45367. /**
  45368. * Update the sampling mode of a given texture
  45369. * @param texture defines the texture to update
  45370. * @param wrapU defines the texture wrap mode of the u coordinates
  45371. * @param wrapV defines the texture wrap mode of the v coordinates
  45372. * @param wrapR defines the texture wrap mode of the r coordinates
  45373. */
  45374. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45375. /**
  45376. * Update the dimensions of a texture
  45377. * @param texture texture to update
  45378. * @param width new width of the texture
  45379. * @param height new height of the texture
  45380. * @param depth new depth of the texture
  45381. */
  45382. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45383. private _setInternalTexture;
  45384. /**
  45385. * Sets a texture to the according uniform.
  45386. * @param channel The texture channel
  45387. * @param unused unused parameter
  45388. * @param texture The texture to apply
  45389. * @param name The name of the uniform in the effect
  45390. */
  45391. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45392. /**
  45393. * Sets an array of texture to the WebGPU context
  45394. * @param channel defines the channel where the texture array must be set
  45395. * @param unused unused parameter
  45396. * @param textures defines the array of textures to bind
  45397. * @param name name of the channel
  45398. */
  45399. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45400. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45401. /** @hidden */
  45402. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45403. /** @hidden */
  45404. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45405. private _generateMipmaps;
  45406. /**
  45407. * Update the content of a texture
  45408. * @param texture defines the texture to update
  45409. * @param canvas defines the source containing the data
  45410. * @param invertY defines if data must be stored with Y axis inverted
  45411. * @param premulAlpha defines if alpha is stored as premultiplied
  45412. * @param format defines the format of the data
  45413. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45414. */
  45415. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45416. /**
  45417. * Update a portion of an internal texture
  45418. * @param texture defines the texture to update
  45419. * @param imageData defines the data to store into the texture
  45420. * @param xOffset defines the x coordinates of the update rectangle
  45421. * @param yOffset defines the y coordinates of the update rectangle
  45422. * @param width defines the width of the update rectangle
  45423. * @param height defines the height of the update rectangle
  45424. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45425. * @param lod defines the lod level to update (0 by default)
  45426. */
  45427. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45428. /**
  45429. * Update a video texture
  45430. * @param texture defines the texture to update
  45431. * @param video defines the video element to use
  45432. * @param invertY defines if data must be stored with Y axis inverted
  45433. */
  45434. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45435. /** @hidden */
  45436. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45437. /** @hidden */
  45438. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45439. /** @hidden */
  45440. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45441. /** @hidden */
  45442. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45443. /**
  45444. * Update a raw texture
  45445. * @param texture defines the texture to update
  45446. * @param bufferView defines the data to store in the texture
  45447. * @param format defines the format of the data
  45448. * @param invertY defines if data must be stored with Y axis inverted
  45449. * @param compression defines the compression used (null by default)
  45450. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45451. */
  45452. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45453. /**
  45454. * Update a raw cube texture
  45455. * @param texture defines the texture to udpdate
  45456. * @param bufferView defines the data to store
  45457. * @param format defines the data format
  45458. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45459. * @param invertY defines if data must be stored with Y axis inverted
  45460. * @param compression defines the compression used (null by default)
  45461. * @param level defines which level of the texture to update
  45462. */
  45463. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45464. /**
  45465. * Update a raw 2D array texture
  45466. * @param texture defines the texture to update
  45467. * @param bufferView defines the data to store
  45468. * @param format defines the data format
  45469. * @param invertY defines if data must be stored with Y axis inverted
  45470. * @param compression defines the used compression (can be null)
  45471. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45472. */
  45473. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45474. /**
  45475. * Update a raw 3D texture
  45476. * @param texture defines the texture to update
  45477. * @param bufferView defines the data to store
  45478. * @param format defines the data format
  45479. * @param invertY defines if data must be stored with Y axis inverted
  45480. * @param compression defines the used compression (can be null)
  45481. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45482. */
  45483. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45484. /**
  45485. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45486. * @param x defines the x coordinate of the rectangle where pixels must be read
  45487. * @param y defines the y coordinate of the rectangle where pixels must be read
  45488. * @param width defines the width of the rectangle where pixels must be read
  45489. * @param height defines the height of the rectangle where pixels must be read
  45490. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45491. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45492. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45493. */
  45494. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45495. /** @hidden */
  45496. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45497. /**
  45498. * Creates a new render target texture
  45499. * @param size defines the size of the texture
  45500. * @param options defines the options used to create the texture
  45501. * @returns a new render target texture stored in an InternalTexture
  45502. */
  45503. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45504. /**
  45505. * Create a multi render target texture
  45506. * @param size defines the size of the texture
  45507. * @param options defines the creation options
  45508. * @returns the cube texture as an InternalTexture
  45509. */
  45510. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45511. /**
  45512. * Creates a new render target cube texture
  45513. * @param size defines the size of the texture
  45514. * @param options defines the options used to create the texture
  45515. * @returns a new render target cube texture stored in an InternalTexture
  45516. */
  45517. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45518. /** @hidden */
  45519. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45520. width: number;
  45521. height: number;
  45522. layers?: number;
  45523. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45524. /** @hidden */
  45525. _createDepthStencilTexture(size: number | {
  45526. width: number;
  45527. height: number;
  45528. layers?: number;
  45529. }, options: DepthTextureCreationOptions): InternalTexture;
  45530. /** @hidden */
  45531. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45532. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45533. /**
  45534. * Update the sample count for a given multiple render target texture
  45535. * @param textures defines the textures to update
  45536. * @param samples defines the sample count to set
  45537. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45538. */
  45539. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45540. /**
  45541. * Begin a new frame
  45542. */
  45543. beginFrame(): void;
  45544. /**
  45545. * End the current frame
  45546. */
  45547. endFrame(): void;
  45548. /**
  45549. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45550. */
  45551. flushFramebuffer(): void;
  45552. private _startRenderTargetRenderPass;
  45553. private _endRenderTargetRenderPass;
  45554. private _getCurrentRenderPass;
  45555. private _startMainRenderPass;
  45556. private _endMainRenderPass;
  45557. /**
  45558. * Restores the WebGPU state to only draw on the main color attachment
  45559. */
  45560. restoreSingleAttachment(): void;
  45561. /**
  45562. * Creates a layout object to draw/clear on specific textures in a MRT
  45563. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45564. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45565. */
  45566. buildTextureLayout(textureStatus: boolean[]): number[];
  45567. /**
  45568. * Select a subsets of attachments to draw to.
  45569. * @param attachments index of attachments
  45570. */
  45571. bindAttachments(attachments: number[]): void;
  45572. /**
  45573. * Binds the frame buffer to the specified texture.
  45574. * @param texture The texture to render to or null for the default canvas
  45575. * @param faceIndex The face of the texture to render to in case of cube texture
  45576. * @param requiredWidth The width of the target to render to
  45577. * @param requiredHeight The height of the target to render to
  45578. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45579. * @param lodLevel defines the lod level to bind to the frame buffer
  45580. * @param layer defines the 2d array index to bind to frame buffer to
  45581. */
  45582. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45583. /**
  45584. * Unbind the current render target texture from the WebGPU context
  45585. * @param texture defines the render target texture to unbind
  45586. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45587. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45588. */
  45589. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45590. /**
  45591. * Unbind a list of render target textures from the WebGPU context
  45592. * @param textures defines the render target textures to unbind
  45593. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45594. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45595. */
  45596. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45597. /**
  45598. * Unbind the current render target and bind the default framebuffer
  45599. */
  45600. restoreDefaultFramebuffer(): void;
  45601. setZOffset(value: number): void;
  45602. private _setColorFormat;
  45603. private _setDepthTextureFormat;
  45604. setDepthBuffer(enable: boolean): void;
  45605. setDepthWrite(enable: boolean): void;
  45606. setStencilBuffer(enable: boolean): void;
  45607. setStencilMask(mask: number): void;
  45608. setStencilFunction(stencilFunc: number): void;
  45609. setStencilFunctionReference(reference: number): void;
  45610. setStencilFunctionMask(mask: number): void;
  45611. setStencilOperationFail(operation: number): void;
  45612. setStencilOperationDepthFail(operation: number): void;
  45613. setStencilOperationPass(operation: number): void;
  45614. setDitheringState(value: boolean): void;
  45615. setRasterizerState(value: boolean): void;
  45616. setDepthFunction(depthFunc: number): void;
  45617. setDepthFunctionToGreater(): void;
  45618. setDepthFunctionToGreaterOrEqual(): void;
  45619. setDepthFunctionToLess(): void;
  45620. setDepthFunctionToLessOrEqual(): void;
  45621. /**
  45622. * Set various states to the context
  45623. * @param culling defines backface culling state
  45624. * @param zOffset defines the value to apply to zOffset (0 by default)
  45625. * @param force defines if states must be applied even if cache is up to date
  45626. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45627. */
  45628. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45629. /**
  45630. * Sets the current alpha mode
  45631. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45632. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45633. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45634. */
  45635. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45636. /**
  45637. * Sets the current alpha equation
  45638. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  45639. */
  45640. setAlphaEquation(equation: number): void;
  45641. private _getBindGroupsToRender;
  45642. private _bindVertexInputs;
  45643. private _setRenderBindGroups;
  45644. private _setRenderPipeline;
  45645. /**
  45646. * Draw a list of indexed primitives
  45647. * @param fillMode defines the primitive to use
  45648. * @param indexStart defines the starting index
  45649. * @param indexCount defines the number of index to draw
  45650. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45651. */
  45652. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45653. /**
  45654. * Draw a list of unindexed primitives
  45655. * @param fillMode defines the primitive to use
  45656. * @param verticesStart defines the index of first vertex to draw
  45657. * @param verticesCount defines the count of vertices to draw
  45658. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45659. */
  45660. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45661. private _bundleEncoder;
  45662. /**
  45663. * Start recording all the gpu calls into a bundle.
  45664. */
  45665. startRecordBundle(): void;
  45666. /**
  45667. * Stops recording the bundle.
  45668. * @returns the recorded bundle
  45669. */
  45670. stopRecordBundle(): GPURenderBundle;
  45671. /**
  45672. * Execute the previously recorded bundle.
  45673. * @param bundles defines the bundle to replay
  45674. */
  45675. executeBundles(bundles: GPURenderBundle[]): void;
  45676. /**
  45677. * Dispose and release all associated resources
  45678. */
  45679. dispose(): void;
  45680. /**
  45681. * Gets the current render width
  45682. * @param useScreen defines if screen size must be used (or the current render target if any)
  45683. * @returns a number defining the current render width
  45684. */
  45685. getRenderWidth(useScreen?: boolean): number;
  45686. /**
  45687. * Gets the current render height
  45688. * @param useScreen defines if screen size must be used (or the current render target if any)
  45689. * @returns a number defining the current render height
  45690. */
  45691. getRenderHeight(useScreen?: boolean): number;
  45692. /**
  45693. * Gets the HTML canvas attached with the current WebGPU context
  45694. * @returns a HTML canvas
  45695. */
  45696. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45697. /** @hidden */
  45698. _debugPushGroup(groupName: string, targetObject?: number): void;
  45699. /** @hidden */
  45700. _debugPopGroup(targetObject?: number): void;
  45701. /** @hidden */
  45702. _debugInsertMarker(text: string, targetObject?: number): void;
  45703. private _debugFlushPendingCommands;
  45704. /**
  45705. * Get the current error code of the WebGPU context
  45706. * @returns the error code
  45707. */
  45708. getError(): number;
  45709. /** @hidden */
  45710. bindSamplers(effect: Effect): void;
  45711. /** @hidden */
  45712. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45713. /** @hidden */
  45714. _releaseFramebufferObjects(texture: InternalTexture): void;
  45715. /** @hidden */
  45716. applyStates(): void;
  45717. /**
  45718. * Gets a boolean indicating if all created effects are ready
  45719. * @returns always true - No parallel shader compilation
  45720. */
  45721. areAllEffectsReady(): boolean;
  45722. /** @hidden */
  45723. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45724. /** @hidden */
  45725. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45726. /** @hidden */
  45727. _getUnpackAlignement(): number;
  45728. /** @hidden */
  45729. _unpackFlipY(value: boolean): void;
  45730. /** @hidden */
  45731. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  45732. min: number;
  45733. mag: number;
  45734. };
  45735. /** @hidden */
  45736. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45737. /** @hidden */
  45738. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45739. /** @hidden */
  45740. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45741. /** @hidden */
  45742. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45743. /** @hidden */
  45744. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45745. /** @hidden */
  45746. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45747. /** @hidden */
  45748. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  45749. /** @hidden */
  45750. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  45751. /** @hidden */
  45752. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  45753. /** @hidden */
  45754. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  45755. /** @hidden */
  45756. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  45757. /** @hidden */
  45758. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45759. /** @hidden */
  45760. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45761. /** @hidden */
  45762. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  45763. /** @hidden */
  45764. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  45765. /** @hidden */
  45766. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  45767. /** @hidden */
  45768. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  45769. }
  45770. }
  45771. declare module BABYLON {
  45772. /**
  45773. * Define an interface for all classes that will hold resources
  45774. */
  45775. export interface IDisposable {
  45776. /**
  45777. * Releases all held resources
  45778. */
  45779. dispose(): void;
  45780. }
  45781. /** Interface defining initialization parameters for Scene class */
  45782. export interface SceneOptions {
  45783. /**
  45784. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  45785. * It will improve performance when the number of geometries becomes important.
  45786. */
  45787. useGeometryUniqueIdsMap?: boolean;
  45788. /**
  45789. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  45790. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45791. */
  45792. useMaterialMeshMap?: boolean;
  45793. /**
  45794. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  45795. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45796. */
  45797. useClonedMeshMap?: boolean;
  45798. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  45799. virtual?: boolean;
  45800. }
  45801. /**
  45802. * Represents a scene to be rendered by the engine.
  45803. * @see https://doc.babylonjs.com/features/scene
  45804. */
  45805. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  45806. /** The fog is deactivated */
  45807. static readonly FOGMODE_NONE: number;
  45808. /** The fog density is following an exponential function */
  45809. static readonly FOGMODE_EXP: number;
  45810. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  45811. static readonly FOGMODE_EXP2: number;
  45812. /** The fog density is following a linear function. */
  45813. static readonly FOGMODE_LINEAR: number;
  45814. /**
  45815. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  45816. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45817. */
  45818. static MinDeltaTime: number;
  45819. /**
  45820. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  45821. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45822. */
  45823. static MaxDeltaTime: number;
  45824. /**
  45825. * Factory used to create the default material.
  45826. * @param name The name of the material to create
  45827. * @param scene The scene to create the material for
  45828. * @returns The default material
  45829. */
  45830. static DefaultMaterialFactory(scene: Scene): Material;
  45831. /**
  45832. * Factory used to create the a collision coordinator.
  45833. * @returns The collision coordinator
  45834. */
  45835. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  45836. /** @hidden */
  45837. _inputManager: InputManager;
  45838. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  45839. cameraToUseForPointers: Nullable<Camera>;
  45840. /** @hidden */
  45841. readonly _isScene: boolean;
  45842. /** @hidden */
  45843. _blockEntityCollection: boolean;
  45844. /**
  45845. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  45846. */
  45847. autoClear: boolean;
  45848. /**
  45849. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  45850. */
  45851. autoClearDepthAndStencil: boolean;
  45852. /**
  45853. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  45854. */
  45855. clearColor: Color4;
  45856. /**
  45857. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  45858. */
  45859. ambientColor: Color3;
  45860. /**
  45861. * This is use to store the default BRDF lookup for PBR materials in your scene.
  45862. * It should only be one of the following (if not the default embedded one):
  45863. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45864. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  45865. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45866. * The material properties need to be setup according to the type of texture in use.
  45867. */
  45868. environmentBRDFTexture: BaseTexture;
  45869. /**
  45870. * Texture used in all pbr material as the reflection texture.
  45871. * As in the majority of the scene they are the same (exception for multi room and so on),
  45872. * this is easier to reference from here than from all the materials.
  45873. */
  45874. get environmentTexture(): Nullable<BaseTexture>;
  45875. /**
  45876. * Texture used in all pbr material as the reflection texture.
  45877. * As in the majority of the scene they are the same (exception for multi room and so on),
  45878. * this is easier to set here than in all the materials.
  45879. */
  45880. set environmentTexture(value: Nullable<BaseTexture>);
  45881. /** @hidden */
  45882. protected _environmentIntensity: number;
  45883. /**
  45884. * Intensity of the environment in all pbr material.
  45885. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45886. * As in the majority of the scene they are the same (exception for multi room and so on),
  45887. * this is easier to reference from here than from all the materials.
  45888. */
  45889. get environmentIntensity(): number;
  45890. /**
  45891. * Intensity of the environment in all pbr material.
  45892. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45893. * As in the majority of the scene they are the same (exception for multi room and so on),
  45894. * this is easier to set here than in all the materials.
  45895. */
  45896. set environmentIntensity(value: number);
  45897. /** @hidden */
  45898. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45899. /**
  45900. * Default image processing configuration used either in the rendering
  45901. * Forward main pass or through the imageProcessingPostProcess if present.
  45902. * As in the majority of the scene they are the same (exception for multi camera),
  45903. * this is easier to reference from here than from all the materials and post process.
  45904. *
  45905. * No setter as we it is a shared configuration, you can set the values instead.
  45906. */
  45907. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45908. private _forceWireframe;
  45909. /**
  45910. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  45911. */
  45912. set forceWireframe(value: boolean);
  45913. get forceWireframe(): boolean;
  45914. private _skipFrustumClipping;
  45915. /**
  45916. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  45917. */
  45918. set skipFrustumClipping(value: boolean);
  45919. get skipFrustumClipping(): boolean;
  45920. private _forcePointsCloud;
  45921. /**
  45922. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  45923. */
  45924. set forcePointsCloud(value: boolean);
  45925. get forcePointsCloud(): boolean;
  45926. /**
  45927. * Gets or sets the active clipplane 1
  45928. */
  45929. clipPlane: Nullable<Plane>;
  45930. /**
  45931. * Gets or sets the active clipplane 2
  45932. */
  45933. clipPlane2: Nullable<Plane>;
  45934. /**
  45935. * Gets or sets the active clipplane 3
  45936. */
  45937. clipPlane3: Nullable<Plane>;
  45938. /**
  45939. * Gets or sets the active clipplane 4
  45940. */
  45941. clipPlane4: Nullable<Plane>;
  45942. /**
  45943. * Gets or sets the active clipplane 5
  45944. */
  45945. clipPlane5: Nullable<Plane>;
  45946. /**
  45947. * Gets or sets the active clipplane 6
  45948. */
  45949. clipPlane6: Nullable<Plane>;
  45950. /**
  45951. * Gets or sets a boolean indicating if animations are enabled
  45952. */
  45953. animationsEnabled: boolean;
  45954. private _animationPropertiesOverride;
  45955. /**
  45956. * Gets or sets the animation properties override
  45957. */
  45958. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  45959. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  45960. /**
  45961. * Gets or sets a boolean indicating if a constant deltatime has to be used
  45962. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  45963. */
  45964. useConstantAnimationDeltaTime: boolean;
  45965. /**
  45966. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  45967. * Please note that it requires to run a ray cast through the scene on every frame
  45968. */
  45969. constantlyUpdateMeshUnderPointer: boolean;
  45970. /**
  45971. * Defines the HTML cursor to use when hovering over interactive elements
  45972. */
  45973. hoverCursor: string;
  45974. /**
  45975. * Defines the HTML default cursor to use (empty by default)
  45976. */
  45977. defaultCursor: string;
  45978. /**
  45979. * Defines whether cursors are handled by the scene.
  45980. */
  45981. doNotHandleCursors: boolean;
  45982. /**
  45983. * This is used to call preventDefault() on pointer down
  45984. * in order to block unwanted artifacts like system double clicks
  45985. */
  45986. preventDefaultOnPointerDown: boolean;
  45987. /**
  45988. * This is used to call preventDefault() on pointer up
  45989. * in order to block unwanted artifacts like system double clicks
  45990. */
  45991. preventDefaultOnPointerUp: boolean;
  45992. /**
  45993. * Gets or sets user defined metadata
  45994. */
  45995. metadata: any;
  45996. /**
  45997. * For internal use only. Please do not use.
  45998. */
  45999. reservedDataStore: any;
  46000. /**
  46001. * Gets the name of the plugin used to load this scene (null by default)
  46002. */
  46003. loadingPluginName: string;
  46004. /**
  46005. * Use this array to add regular expressions used to disable offline support for specific urls
  46006. */
  46007. disableOfflineSupportExceptionRules: RegExp[];
  46008. /**
  46009. * An event triggered when the scene is disposed.
  46010. */
  46011. onDisposeObservable: Observable<Scene>;
  46012. private _onDisposeObserver;
  46013. /** Sets a function to be executed when this scene is disposed. */
  46014. set onDispose(callback: () => void);
  46015. /**
  46016. * An event triggered before rendering the scene (right after animations and physics)
  46017. */
  46018. onBeforeRenderObservable: Observable<Scene>;
  46019. private _onBeforeRenderObserver;
  46020. /** Sets a function to be executed before rendering this scene */
  46021. set beforeRender(callback: Nullable<() => void>);
  46022. /**
  46023. * An event triggered after rendering the scene
  46024. */
  46025. onAfterRenderObservable: Observable<Scene>;
  46026. /**
  46027. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  46028. */
  46029. onAfterRenderCameraObservable: Observable<Camera>;
  46030. private _onAfterRenderObserver;
  46031. /** Sets a function to be executed after rendering this scene */
  46032. set afterRender(callback: Nullable<() => void>);
  46033. /**
  46034. * An event triggered before animating the scene
  46035. */
  46036. onBeforeAnimationsObservable: Observable<Scene>;
  46037. /**
  46038. * An event triggered after animations processing
  46039. */
  46040. onAfterAnimationsObservable: Observable<Scene>;
  46041. /**
  46042. * An event triggered before draw calls are ready to be sent
  46043. */
  46044. onBeforeDrawPhaseObservable: Observable<Scene>;
  46045. /**
  46046. * An event triggered after draw calls have been sent
  46047. */
  46048. onAfterDrawPhaseObservable: Observable<Scene>;
  46049. /**
  46050. * An event triggered when the scene is ready
  46051. */
  46052. onReadyObservable: Observable<Scene>;
  46053. /**
  46054. * An event triggered before rendering a camera
  46055. */
  46056. onBeforeCameraRenderObservable: Observable<Camera>;
  46057. private _onBeforeCameraRenderObserver;
  46058. /** Sets a function to be executed before rendering a camera*/
  46059. set beforeCameraRender(callback: () => void);
  46060. /**
  46061. * An event triggered after rendering a camera
  46062. */
  46063. onAfterCameraRenderObservable: Observable<Camera>;
  46064. private _onAfterCameraRenderObserver;
  46065. /** Sets a function to be executed after rendering a camera*/
  46066. set afterCameraRender(callback: () => void);
  46067. /**
  46068. * An event triggered when active meshes evaluation is about to start
  46069. */
  46070. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46071. /**
  46072. * An event triggered when active meshes evaluation is done
  46073. */
  46074. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46075. /**
  46076. * An event triggered when particles rendering is about to start
  46077. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46078. */
  46079. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46080. /**
  46081. * An event triggered when particles rendering is done
  46082. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46083. */
  46084. onAfterParticlesRenderingObservable: Observable<Scene>;
  46085. /**
  46086. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46087. */
  46088. onDataLoadedObservable: Observable<Scene>;
  46089. /**
  46090. * An event triggered when a camera is created
  46091. */
  46092. onNewCameraAddedObservable: Observable<Camera>;
  46093. /**
  46094. * An event triggered when a camera is removed
  46095. */
  46096. onCameraRemovedObservable: Observable<Camera>;
  46097. /**
  46098. * An event triggered when a light is created
  46099. */
  46100. onNewLightAddedObservable: Observable<Light>;
  46101. /**
  46102. * An event triggered when a light is removed
  46103. */
  46104. onLightRemovedObservable: Observable<Light>;
  46105. /**
  46106. * An event triggered when a geometry is created
  46107. */
  46108. onNewGeometryAddedObservable: Observable<Geometry>;
  46109. /**
  46110. * An event triggered when a geometry is removed
  46111. */
  46112. onGeometryRemovedObservable: Observable<Geometry>;
  46113. /**
  46114. * An event triggered when a transform node is created
  46115. */
  46116. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46117. /**
  46118. * An event triggered when a transform node is removed
  46119. */
  46120. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46121. /**
  46122. * An event triggered when a mesh is created
  46123. */
  46124. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46125. /**
  46126. * An event triggered when a mesh is removed
  46127. */
  46128. onMeshRemovedObservable: Observable<AbstractMesh>;
  46129. /**
  46130. * An event triggered when a skeleton is created
  46131. */
  46132. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46133. /**
  46134. * An event triggered when a skeleton is removed
  46135. */
  46136. onSkeletonRemovedObservable: Observable<Skeleton>;
  46137. /**
  46138. * An event triggered when a material is created
  46139. */
  46140. onNewMaterialAddedObservable: Observable<Material>;
  46141. /**
  46142. * An event triggered when a multi material is created
  46143. */
  46144. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46145. /**
  46146. * An event triggered when a material is removed
  46147. */
  46148. onMaterialRemovedObservable: Observable<Material>;
  46149. /**
  46150. * An event triggered when a multi material is removed
  46151. */
  46152. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46153. /**
  46154. * An event triggered when a texture is created
  46155. */
  46156. onNewTextureAddedObservable: Observable<BaseTexture>;
  46157. /**
  46158. * An event triggered when a texture is removed
  46159. */
  46160. onTextureRemovedObservable: Observable<BaseTexture>;
  46161. /**
  46162. * An event triggered when render targets are about to be rendered
  46163. * Can happen multiple times per frame.
  46164. */
  46165. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46166. /**
  46167. * An event triggered when render targets were rendered.
  46168. * Can happen multiple times per frame.
  46169. */
  46170. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46171. /**
  46172. * An event triggered before calculating deterministic simulation step
  46173. */
  46174. onBeforeStepObservable: Observable<Scene>;
  46175. /**
  46176. * An event triggered after calculating deterministic simulation step
  46177. */
  46178. onAfterStepObservable: Observable<Scene>;
  46179. /**
  46180. * An event triggered when the activeCamera property is updated
  46181. */
  46182. onActiveCameraChanged: Observable<Scene>;
  46183. /**
  46184. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46185. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46186. * 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)
  46187. */
  46188. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46189. /**
  46190. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46191. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46192. * 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)
  46193. */
  46194. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46195. /**
  46196. * This Observable will when a mesh has been imported into the scene.
  46197. */
  46198. onMeshImportedObservable: Observable<AbstractMesh>;
  46199. /**
  46200. * This Observable will when an animation file has been imported into the scene.
  46201. */
  46202. onAnimationFileImportedObservable: Observable<Scene>;
  46203. /**
  46204. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46205. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46206. */
  46207. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46208. /** @hidden */
  46209. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46210. /**
  46211. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46212. */
  46213. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46214. /**
  46215. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46216. */
  46217. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46218. /**
  46219. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46220. */
  46221. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46222. /** Callback called when a pointer move is detected */
  46223. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46224. /** Callback called when a pointer down is detected */
  46225. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46226. /** Callback called when a pointer up is detected */
  46227. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46228. /** Callback called when a pointer pick is detected */
  46229. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46230. /**
  46231. * 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).
  46232. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46233. */
  46234. onPrePointerObservable: Observable<PointerInfoPre>;
  46235. /**
  46236. * Observable event triggered each time an input event is received from the rendering canvas
  46237. */
  46238. onPointerObservable: Observable<PointerInfo>;
  46239. /**
  46240. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46241. */
  46242. get unTranslatedPointer(): Vector2;
  46243. /**
  46244. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46245. */
  46246. static get DragMovementThreshold(): number;
  46247. static set DragMovementThreshold(value: number);
  46248. /**
  46249. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46250. */
  46251. static get LongPressDelay(): number;
  46252. static set LongPressDelay(value: number);
  46253. /**
  46254. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46255. */
  46256. static get DoubleClickDelay(): number;
  46257. static set DoubleClickDelay(value: number);
  46258. /** If you need to check double click without raising a single click at first click, enable this flag */
  46259. static get ExclusiveDoubleClickMode(): boolean;
  46260. static set ExclusiveDoubleClickMode(value: boolean);
  46261. /** @hidden */
  46262. _mirroredCameraPosition: Nullable<Vector3>;
  46263. /**
  46264. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46265. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46266. */
  46267. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46268. /**
  46269. * Observable event triggered each time an keyboard event is received from the hosting window
  46270. */
  46271. onKeyboardObservable: Observable<KeyboardInfo>;
  46272. private _useRightHandedSystem;
  46273. /**
  46274. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46275. */
  46276. set useRightHandedSystem(value: boolean);
  46277. get useRightHandedSystem(): boolean;
  46278. private _timeAccumulator;
  46279. private _currentStepId;
  46280. private _currentInternalStep;
  46281. /**
  46282. * Sets the step Id used by deterministic lock step
  46283. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46284. * @param newStepId defines the step Id
  46285. */
  46286. setStepId(newStepId: number): void;
  46287. /**
  46288. * Gets the step Id used by deterministic lock step
  46289. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46290. * @returns the step Id
  46291. */
  46292. getStepId(): number;
  46293. /**
  46294. * Gets the internal step used by deterministic lock step
  46295. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46296. * @returns the internal step
  46297. */
  46298. getInternalStep(): number;
  46299. private _fogEnabled;
  46300. /**
  46301. * Gets or sets a boolean indicating if fog is enabled on this scene
  46302. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46303. * (Default is true)
  46304. */
  46305. set fogEnabled(value: boolean);
  46306. get fogEnabled(): boolean;
  46307. private _fogMode;
  46308. /**
  46309. * Gets or sets the fog mode to use
  46310. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46311. * | mode | value |
  46312. * | --- | --- |
  46313. * | FOGMODE_NONE | 0 |
  46314. * | FOGMODE_EXP | 1 |
  46315. * | FOGMODE_EXP2 | 2 |
  46316. * | FOGMODE_LINEAR | 3 |
  46317. */
  46318. set fogMode(value: number);
  46319. get fogMode(): number;
  46320. /**
  46321. * Gets or sets the fog color to use
  46322. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46323. * (Default is Color3(0.2, 0.2, 0.3))
  46324. */
  46325. fogColor: Color3;
  46326. /**
  46327. * Gets or sets the fog density to use
  46328. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46329. * (Default is 0.1)
  46330. */
  46331. fogDensity: number;
  46332. /**
  46333. * Gets or sets the fog start distance to use
  46334. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46335. * (Default is 0)
  46336. */
  46337. fogStart: number;
  46338. /**
  46339. * Gets or sets the fog end distance to use
  46340. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46341. * (Default is 1000)
  46342. */
  46343. fogEnd: number;
  46344. /**
  46345. * Flag indicating that the frame buffer binding is handled by another component
  46346. */
  46347. prePass: boolean;
  46348. private _shadowsEnabled;
  46349. /**
  46350. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46351. */
  46352. set shadowsEnabled(value: boolean);
  46353. get shadowsEnabled(): boolean;
  46354. private _lightsEnabled;
  46355. /**
  46356. * Gets or sets a boolean indicating if lights are enabled on this scene
  46357. */
  46358. set lightsEnabled(value: boolean);
  46359. get lightsEnabled(): boolean;
  46360. /** All of the active cameras added to this scene. */
  46361. activeCameras: Nullable<Camera[]>;
  46362. /** @hidden */
  46363. _activeCamera: Nullable<Camera>;
  46364. /** Gets or sets the current active camera */
  46365. get activeCamera(): Nullable<Camera>;
  46366. set activeCamera(value: Nullable<Camera>);
  46367. private _defaultMaterial;
  46368. /** The default material used on meshes when no material is affected */
  46369. get defaultMaterial(): Material;
  46370. /** The default material used on meshes when no material is affected */
  46371. set defaultMaterial(value: Material);
  46372. private _texturesEnabled;
  46373. /**
  46374. * Gets or sets a boolean indicating if textures are enabled on this scene
  46375. */
  46376. set texturesEnabled(value: boolean);
  46377. get texturesEnabled(): boolean;
  46378. /**
  46379. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46380. */
  46381. physicsEnabled: boolean;
  46382. /**
  46383. * Gets or sets a boolean indicating if particles are enabled on this scene
  46384. */
  46385. particlesEnabled: boolean;
  46386. /**
  46387. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46388. */
  46389. spritesEnabled: boolean;
  46390. private _skeletonsEnabled;
  46391. /**
  46392. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46393. */
  46394. set skeletonsEnabled(value: boolean);
  46395. get skeletonsEnabled(): boolean;
  46396. /**
  46397. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46398. */
  46399. lensFlaresEnabled: boolean;
  46400. /**
  46401. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46402. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46403. */
  46404. collisionsEnabled: boolean;
  46405. private _collisionCoordinator;
  46406. /** @hidden */
  46407. get collisionCoordinator(): ICollisionCoordinator;
  46408. /**
  46409. * Defines the gravity applied to this scene (used only for collisions)
  46410. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46411. */
  46412. gravity: Vector3;
  46413. /**
  46414. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46415. */
  46416. postProcessesEnabled: boolean;
  46417. /**
  46418. * Gets the current postprocess manager
  46419. */
  46420. postProcessManager: PostProcessManager;
  46421. /**
  46422. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46423. */
  46424. renderTargetsEnabled: boolean;
  46425. /**
  46426. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46427. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46428. */
  46429. dumpNextRenderTargets: boolean;
  46430. /**
  46431. * The list of user defined render targets added to the scene
  46432. */
  46433. customRenderTargets: RenderTargetTexture[];
  46434. /**
  46435. * Defines if texture loading must be delayed
  46436. * If true, textures will only be loaded when they need to be rendered
  46437. */
  46438. useDelayedTextureLoading: boolean;
  46439. /**
  46440. * Gets the list of meshes imported to the scene through SceneLoader
  46441. */
  46442. importedMeshesFiles: String[];
  46443. /**
  46444. * Gets or sets a boolean indicating if probes are enabled on this scene
  46445. */
  46446. probesEnabled: boolean;
  46447. /**
  46448. * Gets or sets the current offline provider to use to store scene data
  46449. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46450. */
  46451. offlineProvider: IOfflineProvider;
  46452. /**
  46453. * Gets or sets the action manager associated with the scene
  46454. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46455. */
  46456. actionManager: AbstractActionManager;
  46457. private _meshesForIntersections;
  46458. /**
  46459. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46460. */
  46461. proceduralTexturesEnabled: boolean;
  46462. private _engine;
  46463. private _totalVertices;
  46464. /** @hidden */
  46465. _activeIndices: PerfCounter;
  46466. /** @hidden */
  46467. _activeParticles: PerfCounter;
  46468. /** @hidden */
  46469. _activeBones: PerfCounter;
  46470. private _animationRatio;
  46471. /** @hidden */
  46472. _animationTimeLast: number;
  46473. /** @hidden */
  46474. _animationTime: number;
  46475. /**
  46476. * Gets or sets a general scale for animation speed
  46477. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46478. */
  46479. animationTimeScale: number;
  46480. /** @hidden */
  46481. _cachedMaterial: Nullable<Material>;
  46482. /** @hidden */
  46483. _cachedEffect: Nullable<Effect>;
  46484. /** @hidden */
  46485. _cachedVisibility: Nullable<number>;
  46486. private _renderId;
  46487. private _frameId;
  46488. private _executeWhenReadyTimeoutId;
  46489. private _intermediateRendering;
  46490. private _viewUpdateFlag;
  46491. private _projectionUpdateFlag;
  46492. /** @hidden */
  46493. _toBeDisposed: Nullable<IDisposable>[];
  46494. private _activeRequests;
  46495. /** @hidden */
  46496. _pendingData: any[];
  46497. private _isDisposed;
  46498. /**
  46499. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46500. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46501. */
  46502. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46503. private _activeMeshes;
  46504. private _processedMaterials;
  46505. private _renderTargets;
  46506. /** @hidden */
  46507. _activeParticleSystems: SmartArray<IParticleSystem>;
  46508. private _activeSkeletons;
  46509. private _softwareSkinnedMeshes;
  46510. private _renderingManager;
  46511. /** @hidden */
  46512. _activeAnimatables: Animatable[];
  46513. private _transformMatrix;
  46514. private _sceneUbo;
  46515. /** @hidden */
  46516. _viewMatrix: Matrix;
  46517. /** @hidden */
  46518. _projectionMatrix: Matrix;
  46519. /** @hidden */
  46520. _forcedViewPosition: Nullable<Vector3>;
  46521. /** @hidden */
  46522. _frustumPlanes: Plane[];
  46523. /**
  46524. * Gets the list of frustum planes (built from the active camera)
  46525. */
  46526. get frustumPlanes(): Plane[];
  46527. /**
  46528. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46529. * This is useful if there are more lights that the maximum simulteanous authorized
  46530. */
  46531. requireLightSorting: boolean;
  46532. /** @hidden */
  46533. readonly useMaterialMeshMap: boolean;
  46534. /** @hidden */
  46535. readonly useClonedMeshMap: boolean;
  46536. private _externalData;
  46537. private _uid;
  46538. /**
  46539. * @hidden
  46540. * Backing store of defined scene components.
  46541. */
  46542. _components: ISceneComponent[];
  46543. /**
  46544. * @hidden
  46545. * Backing store of defined scene components.
  46546. */
  46547. _serializableComponents: ISceneSerializableComponent[];
  46548. /**
  46549. * List of components to register on the next registration step.
  46550. */
  46551. private _transientComponents;
  46552. /**
  46553. * Registers the transient components if needed.
  46554. */
  46555. private _registerTransientComponents;
  46556. /**
  46557. * @hidden
  46558. * Add a component to the scene.
  46559. * Note that the ccomponent could be registered on th next frame if this is called after
  46560. * the register component stage.
  46561. * @param component Defines the component to add to the scene
  46562. */
  46563. _addComponent(component: ISceneComponent): void;
  46564. /**
  46565. * @hidden
  46566. * Gets a component from the scene.
  46567. * @param name defines the name of the component to retrieve
  46568. * @returns the component or null if not present
  46569. */
  46570. _getComponent(name: string): Nullable<ISceneComponent>;
  46571. /**
  46572. * @hidden
  46573. * Defines the actions happening before camera updates.
  46574. */
  46575. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46576. /**
  46577. * @hidden
  46578. * Defines the actions happening before clear the canvas.
  46579. */
  46580. _beforeClearStage: Stage<SimpleStageAction>;
  46581. /**
  46582. * @hidden
  46583. * Defines the actions when collecting render targets for the frame.
  46584. */
  46585. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46586. /**
  46587. * @hidden
  46588. * Defines the actions happening for one camera in the frame.
  46589. */
  46590. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46591. /**
  46592. * @hidden
  46593. * Defines the actions happening during the per mesh ready checks.
  46594. */
  46595. _isReadyForMeshStage: Stage<MeshStageAction>;
  46596. /**
  46597. * @hidden
  46598. * Defines the actions happening before evaluate active mesh checks.
  46599. */
  46600. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46601. /**
  46602. * @hidden
  46603. * Defines the actions happening during the evaluate sub mesh checks.
  46604. */
  46605. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46606. /**
  46607. * @hidden
  46608. * Defines the actions happening during the active mesh stage.
  46609. */
  46610. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46611. /**
  46612. * @hidden
  46613. * Defines the actions happening during the per camera render target step.
  46614. */
  46615. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46616. /**
  46617. * @hidden
  46618. * Defines the actions happening just before the active camera is drawing.
  46619. */
  46620. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46621. /**
  46622. * @hidden
  46623. * Defines the actions happening just before a render target is drawing.
  46624. */
  46625. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46626. /**
  46627. * @hidden
  46628. * Defines the actions happening just before a rendering group is drawing.
  46629. */
  46630. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46631. /**
  46632. * @hidden
  46633. * Defines the actions happening just before a mesh is drawing.
  46634. */
  46635. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46636. /**
  46637. * @hidden
  46638. * Defines the actions happening just after a mesh has been drawn.
  46639. */
  46640. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46641. /**
  46642. * @hidden
  46643. * Defines the actions happening just after a rendering group has been drawn.
  46644. */
  46645. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46646. /**
  46647. * @hidden
  46648. * Defines the actions happening just after the active camera has been drawn.
  46649. */
  46650. _afterCameraDrawStage: Stage<CameraStageAction>;
  46651. /**
  46652. * @hidden
  46653. * Defines the actions happening just after a render target has been drawn.
  46654. */
  46655. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46656. /**
  46657. * @hidden
  46658. * Defines the actions happening just after rendering all cameras and computing intersections.
  46659. */
  46660. _afterRenderStage: Stage<SimpleStageAction>;
  46661. /**
  46662. * @hidden
  46663. * Defines the actions happening when a pointer move event happens.
  46664. */
  46665. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46666. /**
  46667. * @hidden
  46668. * Defines the actions happening when a pointer down event happens.
  46669. */
  46670. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46671. /**
  46672. * @hidden
  46673. * Defines the actions happening when a pointer up event happens.
  46674. */
  46675. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46676. /**
  46677. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46678. */
  46679. private geometriesByUniqueId;
  46680. private _renderBundles;
  46681. /**
  46682. * Creates a new Scene
  46683. * @param engine defines the engine to use to render this scene
  46684. * @param options defines the scene options
  46685. */
  46686. constructor(engine: Engine, options?: SceneOptions);
  46687. /**
  46688. * Gets a string identifying the name of the class
  46689. * @returns "Scene" string
  46690. */
  46691. getClassName(): string;
  46692. private _defaultMeshCandidates;
  46693. /**
  46694. * @hidden
  46695. */
  46696. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46697. private _defaultSubMeshCandidates;
  46698. /**
  46699. * @hidden
  46700. */
  46701. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46702. /**
  46703. * Sets the default candidate providers for the scene.
  46704. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46705. * and getCollidingSubMeshCandidates to their default function
  46706. */
  46707. setDefaultCandidateProviders(): void;
  46708. /**
  46709. * Gets the mesh that is currently under the pointer
  46710. */
  46711. get meshUnderPointer(): Nullable<AbstractMesh>;
  46712. /**
  46713. * Gets or sets the current on-screen X position of the pointer
  46714. */
  46715. get pointerX(): number;
  46716. set pointerX(value: number);
  46717. /**
  46718. * Gets or sets the current on-screen Y position of the pointer
  46719. */
  46720. get pointerY(): number;
  46721. set pointerY(value: number);
  46722. /**
  46723. * Gets the cached material (ie. the latest rendered one)
  46724. * @returns the cached material
  46725. */
  46726. getCachedMaterial(): Nullable<Material>;
  46727. /**
  46728. * Gets the cached effect (ie. the latest rendered one)
  46729. * @returns the cached effect
  46730. */
  46731. getCachedEffect(): Nullable<Effect>;
  46732. /**
  46733. * Gets the cached visibility state (ie. the latest rendered one)
  46734. * @returns the cached visibility state
  46735. */
  46736. getCachedVisibility(): Nullable<number>;
  46737. /**
  46738. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  46739. * @param material defines the current material
  46740. * @param effect defines the current effect
  46741. * @param visibility defines the current visibility state
  46742. * @returns true if one parameter is not cached
  46743. */
  46744. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  46745. /**
  46746. * Gets the engine associated with the scene
  46747. * @returns an Engine
  46748. */
  46749. getEngine(): Engine;
  46750. /**
  46751. * Gets the total number of vertices rendered per frame
  46752. * @returns the total number of vertices rendered per frame
  46753. */
  46754. getTotalVertices(): number;
  46755. /**
  46756. * Gets the performance counter for total vertices
  46757. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46758. */
  46759. get totalVerticesPerfCounter(): PerfCounter;
  46760. /**
  46761. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  46762. * @returns the total number of active indices rendered per frame
  46763. */
  46764. getActiveIndices(): number;
  46765. /**
  46766. * Gets the performance counter for active indices
  46767. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46768. */
  46769. get totalActiveIndicesPerfCounter(): PerfCounter;
  46770. /**
  46771. * Gets the total number of active particles rendered per frame
  46772. * @returns the total number of active particles rendered per frame
  46773. */
  46774. getActiveParticles(): number;
  46775. /**
  46776. * Gets the performance counter for active particles
  46777. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46778. */
  46779. get activeParticlesPerfCounter(): PerfCounter;
  46780. /**
  46781. * Gets the total number of active bones rendered per frame
  46782. * @returns the total number of active bones rendered per frame
  46783. */
  46784. getActiveBones(): number;
  46785. /**
  46786. * Gets the performance counter for active bones
  46787. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46788. */
  46789. get activeBonesPerfCounter(): PerfCounter;
  46790. /**
  46791. * Gets the array of active meshes
  46792. * @returns an array of AbstractMesh
  46793. */
  46794. getActiveMeshes(): SmartArray<AbstractMesh>;
  46795. /**
  46796. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  46797. * @returns a number
  46798. */
  46799. getAnimationRatio(): number;
  46800. /**
  46801. * Gets an unique Id for the current render phase
  46802. * @returns a number
  46803. */
  46804. getRenderId(): number;
  46805. /**
  46806. * Gets an unique Id for the current frame
  46807. * @returns a number
  46808. */
  46809. getFrameId(): number;
  46810. /** Call this function if you want to manually increment the render Id*/
  46811. incrementRenderId(): void;
  46812. private _createUbo;
  46813. /**
  46814. * Use this method to simulate a pointer move on a mesh
  46815. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46816. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46817. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46818. * @returns the current scene
  46819. */
  46820. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46821. /**
  46822. * Use this method to simulate a pointer down on a mesh
  46823. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46824. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46825. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46826. * @returns the current scene
  46827. */
  46828. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46829. /**
  46830. * Use this method to simulate a pointer up on a mesh
  46831. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46832. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46833. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46834. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  46835. * @returns the current scene
  46836. */
  46837. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  46838. /**
  46839. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  46840. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  46841. * @returns true if the pointer was captured
  46842. */
  46843. isPointerCaptured(pointerId?: number): boolean;
  46844. /**
  46845. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  46846. * @param attachUp defines if you want to attach events to pointerup
  46847. * @param attachDown defines if you want to attach events to pointerdown
  46848. * @param attachMove defines if you want to attach events to pointermove
  46849. */
  46850. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  46851. /** Detaches all event handlers*/
  46852. detachControl(): void;
  46853. /**
  46854. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  46855. * Delay loaded resources are not taking in account
  46856. * @return true if all required resources are ready
  46857. */
  46858. isReady(): boolean;
  46859. /** Resets all cached information relative to material (including effect and visibility) */
  46860. resetCachedMaterial(): void;
  46861. /**
  46862. * Registers a function to be called before every frame render
  46863. * @param func defines the function to register
  46864. */
  46865. registerBeforeRender(func: () => void): void;
  46866. /**
  46867. * Unregisters a function called before every frame render
  46868. * @param func defines the function to unregister
  46869. */
  46870. unregisterBeforeRender(func: () => void): void;
  46871. /**
  46872. * Registers a function to be called after every frame render
  46873. * @param func defines the function to register
  46874. */
  46875. registerAfterRender(func: () => void): void;
  46876. /**
  46877. * Unregisters a function called after every frame render
  46878. * @param func defines the function to unregister
  46879. */
  46880. unregisterAfterRender(func: () => void): void;
  46881. private _executeOnceBeforeRender;
  46882. /**
  46883. * The provided function will run before render once and will be disposed afterwards.
  46884. * A timeout delay can be provided so that the function will be executed in N ms.
  46885. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  46886. * @param func The function to be executed.
  46887. * @param timeout optional delay in ms
  46888. */
  46889. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  46890. /** @hidden */
  46891. _addPendingData(data: any): void;
  46892. /** @hidden */
  46893. _removePendingData(data: any): void;
  46894. /**
  46895. * Returns the number of items waiting to be loaded
  46896. * @returns the number of items waiting to be loaded
  46897. */
  46898. getWaitingItemsCount(): number;
  46899. /**
  46900. * Returns a boolean indicating if the scene is still loading data
  46901. */
  46902. get isLoading(): boolean;
  46903. /**
  46904. * Registers a function to be executed when the scene is ready
  46905. * @param {Function} func - the function to be executed
  46906. */
  46907. executeWhenReady(func: () => void): void;
  46908. /**
  46909. * Returns a promise that resolves when the scene is ready
  46910. * @returns A promise that resolves when the scene is ready
  46911. */
  46912. whenReadyAsync(): Promise<void>;
  46913. /** @hidden */
  46914. _checkIsReady(): void;
  46915. /**
  46916. * Gets all animatable attached to the scene
  46917. */
  46918. get animatables(): Animatable[];
  46919. /**
  46920. * Resets the last animation time frame.
  46921. * Useful to override when animations start running when loading a scene for the first time.
  46922. */
  46923. resetLastAnimationTimeFrame(): void;
  46924. /**
  46925. * Gets the current view matrix
  46926. * @returns a Matrix
  46927. */
  46928. getViewMatrix(): Matrix;
  46929. /**
  46930. * Gets the current projection matrix
  46931. * @returns a Matrix
  46932. */
  46933. getProjectionMatrix(): Matrix;
  46934. /**
  46935. * Gets the current transform matrix
  46936. * @returns a Matrix made of View * Projection
  46937. */
  46938. getTransformMatrix(): Matrix;
  46939. /**
  46940. * Sets the current transform matrix
  46941. * @param viewL defines the View matrix to use
  46942. * @param projectionL defines the Projection matrix to use
  46943. * @param viewR defines the right View matrix to use (if provided)
  46944. * @param projectionR defines the right Projection matrix to use (if provided)
  46945. */
  46946. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  46947. /**
  46948. * Gets the uniform buffer used to store scene data
  46949. * @returns a UniformBuffer
  46950. */
  46951. getSceneUniformBuffer(): UniformBuffer;
  46952. /**
  46953. * Gets an unique (relatively to the current scene) Id
  46954. * @returns an unique number for the scene
  46955. */
  46956. getUniqueId(): number;
  46957. /**
  46958. * Add a mesh to the list of scene's meshes
  46959. * @param newMesh defines the mesh to add
  46960. * @param recursive if all child meshes should also be added to the scene
  46961. */
  46962. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  46963. /**
  46964. * Remove a mesh for the list of scene's meshes
  46965. * @param toRemove defines the mesh to remove
  46966. * @param recursive if all child meshes should also be removed from the scene
  46967. * @returns the index where the mesh was in the mesh list
  46968. */
  46969. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  46970. /**
  46971. * Add a transform node to the list of scene's transform nodes
  46972. * @param newTransformNode defines the transform node to add
  46973. */
  46974. addTransformNode(newTransformNode: TransformNode): void;
  46975. /**
  46976. * Remove a transform node for the list of scene's transform nodes
  46977. * @param toRemove defines the transform node to remove
  46978. * @returns the index where the transform node was in the transform node list
  46979. */
  46980. removeTransformNode(toRemove: TransformNode): number;
  46981. /**
  46982. * Remove a skeleton for the list of scene's skeletons
  46983. * @param toRemove defines the skeleton to remove
  46984. * @returns the index where the skeleton was in the skeleton list
  46985. */
  46986. removeSkeleton(toRemove: Skeleton): number;
  46987. /**
  46988. * Remove a morph target for the list of scene's morph targets
  46989. * @param toRemove defines the morph target to remove
  46990. * @returns the index where the morph target was in the morph target list
  46991. */
  46992. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  46993. /**
  46994. * Remove a light for the list of scene's lights
  46995. * @param toRemove defines the light to remove
  46996. * @returns the index where the light was in the light list
  46997. */
  46998. removeLight(toRemove: Light): number;
  46999. /**
  47000. * Remove a camera for the list of scene's cameras
  47001. * @param toRemove defines the camera to remove
  47002. * @returns the index where the camera was in the camera list
  47003. */
  47004. removeCamera(toRemove: Camera): number;
  47005. /**
  47006. * Remove a particle system for the list of scene's particle systems
  47007. * @param toRemove defines the particle system to remove
  47008. * @returns the index where the particle system was in the particle system list
  47009. */
  47010. removeParticleSystem(toRemove: IParticleSystem): number;
  47011. /**
  47012. * Remove a animation for the list of scene's animations
  47013. * @param toRemove defines the animation to remove
  47014. * @returns the index where the animation was in the animation list
  47015. */
  47016. removeAnimation(toRemove: Animation): number;
  47017. /**
  47018. * Will stop the animation of the given target
  47019. * @param target - the target
  47020. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  47021. * @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)
  47022. */
  47023. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  47024. /**
  47025. * Removes the given animation group from this scene.
  47026. * @param toRemove The animation group to remove
  47027. * @returns The index of the removed animation group
  47028. */
  47029. removeAnimationGroup(toRemove: AnimationGroup): number;
  47030. /**
  47031. * Removes the given multi-material from this scene.
  47032. * @param toRemove The multi-material to remove
  47033. * @returns The index of the removed multi-material
  47034. */
  47035. removeMultiMaterial(toRemove: MultiMaterial): number;
  47036. /**
  47037. * Removes the given material from this scene.
  47038. * @param toRemove The material to remove
  47039. * @returns The index of the removed material
  47040. */
  47041. removeMaterial(toRemove: Material): number;
  47042. /**
  47043. * Removes the given action manager from this scene.
  47044. * @param toRemove The action manager to remove
  47045. * @returns The index of the removed action manager
  47046. */
  47047. removeActionManager(toRemove: AbstractActionManager): number;
  47048. /**
  47049. * Removes the given texture from this scene.
  47050. * @param toRemove The texture to remove
  47051. * @returns The index of the removed texture
  47052. */
  47053. removeTexture(toRemove: BaseTexture): number;
  47054. /**
  47055. * Adds the given light to this scene
  47056. * @param newLight The light to add
  47057. */
  47058. addLight(newLight: Light): void;
  47059. /**
  47060. * Sorts the list list based on light priorities
  47061. */
  47062. sortLightsByPriority(): void;
  47063. /**
  47064. * Adds the given camera to this scene
  47065. * @param newCamera The camera to add
  47066. */
  47067. addCamera(newCamera: Camera): void;
  47068. /**
  47069. * Adds the given skeleton to this scene
  47070. * @param newSkeleton The skeleton to add
  47071. */
  47072. addSkeleton(newSkeleton: Skeleton): void;
  47073. /**
  47074. * Adds the given particle system to this scene
  47075. * @param newParticleSystem The particle system to add
  47076. */
  47077. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47078. /**
  47079. * Adds the given animation to this scene
  47080. * @param newAnimation The animation to add
  47081. */
  47082. addAnimation(newAnimation: Animation): void;
  47083. /**
  47084. * Adds the given animation group to this scene.
  47085. * @param newAnimationGroup The animation group to add
  47086. */
  47087. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47088. /**
  47089. * Adds the given multi-material to this scene
  47090. * @param newMultiMaterial The multi-material to add
  47091. */
  47092. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47093. /**
  47094. * Adds the given material to this scene
  47095. * @param newMaterial The material to add
  47096. */
  47097. addMaterial(newMaterial: Material): void;
  47098. /**
  47099. * Adds the given morph target to this scene
  47100. * @param newMorphTargetManager The morph target to add
  47101. */
  47102. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47103. /**
  47104. * Adds the given geometry to this scene
  47105. * @param newGeometry The geometry to add
  47106. */
  47107. addGeometry(newGeometry: Geometry): void;
  47108. /**
  47109. * Adds the given action manager to this scene
  47110. * @param newActionManager The action manager to add
  47111. */
  47112. addActionManager(newActionManager: AbstractActionManager): void;
  47113. /**
  47114. * Adds the given texture to this scene.
  47115. * @param newTexture The texture to add
  47116. */
  47117. addTexture(newTexture: BaseTexture): void;
  47118. /**
  47119. * Switch active camera
  47120. * @param newCamera defines the new active camera
  47121. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47122. */
  47123. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47124. /**
  47125. * sets the active camera of the scene using its ID
  47126. * @param id defines the camera's ID
  47127. * @return the new active camera or null if none found.
  47128. */
  47129. setActiveCameraByID(id: string): Nullable<Camera>;
  47130. /**
  47131. * sets the active camera of the scene using its name
  47132. * @param name defines the camera's name
  47133. * @returns the new active camera or null if none found.
  47134. */
  47135. setActiveCameraByName(name: string): Nullable<Camera>;
  47136. /**
  47137. * get an animation group using its name
  47138. * @param name defines the material's name
  47139. * @return the animation group or null if none found.
  47140. */
  47141. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47142. /**
  47143. * Get a material using its unique id
  47144. * @param uniqueId defines the material's unique id
  47145. * @return the material or null if none found.
  47146. */
  47147. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47148. /**
  47149. * get a material using its id
  47150. * @param id defines the material's ID
  47151. * @return the material or null if none found.
  47152. */
  47153. getMaterialByID(id: string): Nullable<Material>;
  47154. /**
  47155. * Gets a the last added material using a given id
  47156. * @param id defines the material's ID
  47157. * @return the last material with the given id or null if none found.
  47158. */
  47159. getLastMaterialByID(id: string): Nullable<Material>;
  47160. /**
  47161. * Gets a material using its name
  47162. * @param name defines the material's name
  47163. * @return the material or null if none found.
  47164. */
  47165. getMaterialByName(name: string): Nullable<Material>;
  47166. /**
  47167. * Get a texture using its unique id
  47168. * @param uniqueId defines the texture's unique id
  47169. * @return the texture or null if none found.
  47170. */
  47171. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47172. /**
  47173. * Gets a camera using its id
  47174. * @param id defines the id to look for
  47175. * @returns the camera or null if not found
  47176. */
  47177. getCameraByID(id: string): Nullable<Camera>;
  47178. /**
  47179. * Gets a camera using its unique id
  47180. * @param uniqueId defines the unique id to look for
  47181. * @returns the camera or null if not found
  47182. */
  47183. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47184. /**
  47185. * Gets a camera using its name
  47186. * @param name defines the camera's name
  47187. * @return the camera or null if none found.
  47188. */
  47189. getCameraByName(name: string): Nullable<Camera>;
  47190. /**
  47191. * Gets a bone using its id
  47192. * @param id defines the bone's id
  47193. * @return the bone or null if not found
  47194. */
  47195. getBoneByID(id: string): Nullable<Bone>;
  47196. /**
  47197. * Gets a bone using its id
  47198. * @param name defines the bone's name
  47199. * @return the bone or null if not found
  47200. */
  47201. getBoneByName(name: string): Nullable<Bone>;
  47202. /**
  47203. * Gets a light node using its name
  47204. * @param name defines the the light's name
  47205. * @return the light or null if none found.
  47206. */
  47207. getLightByName(name: string): Nullable<Light>;
  47208. /**
  47209. * Gets a light node using its id
  47210. * @param id defines the light's id
  47211. * @return the light or null if none found.
  47212. */
  47213. getLightByID(id: string): Nullable<Light>;
  47214. /**
  47215. * Gets a light node using its scene-generated unique ID
  47216. * @param uniqueId defines the light's unique id
  47217. * @return the light or null if none found.
  47218. */
  47219. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47220. /**
  47221. * Gets a particle system by id
  47222. * @param id defines the particle system id
  47223. * @return the corresponding system or null if none found
  47224. */
  47225. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47226. /**
  47227. * Gets a geometry using its ID
  47228. * @param id defines the geometry's id
  47229. * @return the geometry or null if none found.
  47230. */
  47231. getGeometryByID(id: string): Nullable<Geometry>;
  47232. private _getGeometryByUniqueID;
  47233. /**
  47234. * Add a new geometry to this scene
  47235. * @param geometry defines the geometry to be added to the scene.
  47236. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47237. * @return a boolean defining if the geometry was added or not
  47238. */
  47239. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47240. /**
  47241. * Removes an existing geometry
  47242. * @param geometry defines the geometry to be removed from the scene
  47243. * @return a boolean defining if the geometry was removed or not
  47244. */
  47245. removeGeometry(geometry: Geometry): boolean;
  47246. /**
  47247. * Gets the list of geometries attached to the scene
  47248. * @returns an array of Geometry
  47249. */
  47250. getGeometries(): Geometry[];
  47251. /**
  47252. * Gets the first added mesh found of a given ID
  47253. * @param id defines the id to search for
  47254. * @return the mesh found or null if not found at all
  47255. */
  47256. getMeshByID(id: string): Nullable<AbstractMesh>;
  47257. /**
  47258. * Gets a list of meshes using their id
  47259. * @param id defines the id to search for
  47260. * @returns a list of meshes
  47261. */
  47262. getMeshesByID(id: string): Array<AbstractMesh>;
  47263. /**
  47264. * Gets the first added transform node found of a given ID
  47265. * @param id defines the id to search for
  47266. * @return the found transform node or null if not found at all.
  47267. */
  47268. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47269. /**
  47270. * Gets a transform node with its auto-generated unique id
  47271. * @param uniqueId efines the unique id to search for
  47272. * @return the found transform node or null if not found at all.
  47273. */
  47274. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47275. /**
  47276. * Gets a list of transform nodes using their id
  47277. * @param id defines the id to search for
  47278. * @returns a list of transform nodes
  47279. */
  47280. getTransformNodesByID(id: string): Array<TransformNode>;
  47281. /**
  47282. * Gets a mesh with its auto-generated unique id
  47283. * @param uniqueId defines the unique id to search for
  47284. * @return the found mesh or null if not found at all.
  47285. */
  47286. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47287. /**
  47288. * Gets a the last added mesh using a given id
  47289. * @param id defines the id to search for
  47290. * @return the found mesh or null if not found at all.
  47291. */
  47292. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47293. /**
  47294. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47295. * @param id defines the id to search for
  47296. * @return the found node or null if not found at all
  47297. */
  47298. getLastEntryByID(id: string): Nullable<Node>;
  47299. /**
  47300. * Gets a node (Mesh, Camera, Light) using a given id
  47301. * @param id defines the id to search for
  47302. * @return the found node or null if not found at all
  47303. */
  47304. getNodeByID(id: string): Nullable<Node>;
  47305. /**
  47306. * Gets a node (Mesh, Camera, Light) using a given name
  47307. * @param name defines the name to search for
  47308. * @return the found node or null if not found at all.
  47309. */
  47310. getNodeByName(name: string): Nullable<Node>;
  47311. /**
  47312. * Gets a mesh using a given name
  47313. * @param name defines the name to search for
  47314. * @return the found mesh or null if not found at all.
  47315. */
  47316. getMeshByName(name: string): Nullable<AbstractMesh>;
  47317. /**
  47318. * Gets a transform node using a given name
  47319. * @param name defines the name to search for
  47320. * @return the found transform node or null if not found at all.
  47321. */
  47322. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47323. /**
  47324. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47325. * @param id defines the id to search for
  47326. * @return the found skeleton or null if not found at all.
  47327. */
  47328. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47329. /**
  47330. * Gets a skeleton using a given auto generated unique id
  47331. * @param uniqueId defines the unique id to search for
  47332. * @return the found skeleton or null if not found at all.
  47333. */
  47334. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47335. /**
  47336. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47337. * @param id defines the id to search for
  47338. * @return the found skeleton or null if not found at all.
  47339. */
  47340. getSkeletonById(id: string): Nullable<Skeleton>;
  47341. /**
  47342. * Gets a skeleton using a given name
  47343. * @param name defines the name to search for
  47344. * @return the found skeleton or null if not found at all.
  47345. */
  47346. getSkeletonByName(name: string): Nullable<Skeleton>;
  47347. /**
  47348. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47349. * @param id defines the id to search for
  47350. * @return the found morph target manager or null if not found at all.
  47351. */
  47352. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47353. /**
  47354. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47355. * @param id defines the id to search for
  47356. * @return the found morph target or null if not found at all.
  47357. */
  47358. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47359. /**
  47360. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47361. * @param name defines the name to search for
  47362. * @return the found morph target or null if not found at all.
  47363. */
  47364. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47365. /**
  47366. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47367. * @param name defines the name to search for
  47368. * @return the found post process or null if not found at all.
  47369. */
  47370. getPostProcessByName(name: string): Nullable<PostProcess>;
  47371. /**
  47372. * Gets a boolean indicating if the given mesh is active
  47373. * @param mesh defines the mesh to look for
  47374. * @returns true if the mesh is in the active list
  47375. */
  47376. isActiveMesh(mesh: AbstractMesh): boolean;
  47377. /**
  47378. * Return a unique id as a string which can serve as an identifier for the scene
  47379. */
  47380. get uid(): string;
  47381. /**
  47382. * Add an externaly attached data from its key.
  47383. * This method call will fail and return false, if such key already exists.
  47384. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47385. * @param key the unique key that identifies the data
  47386. * @param data the data object to associate to the key for this Engine instance
  47387. * @return true if no such key were already present and the data was added successfully, false otherwise
  47388. */
  47389. addExternalData<T>(key: string, data: T): boolean;
  47390. /**
  47391. * Get an externaly attached data from its key
  47392. * @param key the unique key that identifies the data
  47393. * @return the associated data, if present (can be null), or undefined if not present
  47394. */
  47395. getExternalData<T>(key: string): Nullable<T>;
  47396. /**
  47397. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47398. * @param key the unique key that identifies the data
  47399. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47400. * @return the associated data, can be null if the factory returned null.
  47401. */
  47402. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47403. /**
  47404. * Remove an externaly attached data from the Engine instance
  47405. * @param key the unique key that identifies the data
  47406. * @return true if the data was successfully removed, false if it doesn't exist
  47407. */
  47408. removeExternalData(key: string): boolean;
  47409. private _evaluateSubMesh;
  47410. /**
  47411. * Clear the processed materials smart array preventing retention point in material dispose.
  47412. */
  47413. freeProcessedMaterials(): void;
  47414. private _preventFreeActiveMeshesAndRenderingGroups;
  47415. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47416. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47417. * when disposing several meshes in a row or a hierarchy of meshes.
  47418. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47419. */
  47420. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47421. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47422. /**
  47423. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47424. */
  47425. freeActiveMeshes(): void;
  47426. /**
  47427. * Clear the info related to rendering groups preventing retention points during dispose.
  47428. */
  47429. freeRenderingGroups(): void;
  47430. /** @hidden */
  47431. _isInIntermediateRendering(): boolean;
  47432. /**
  47433. * Lambda returning the list of potentially active meshes.
  47434. */
  47435. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47436. /**
  47437. * Lambda returning the list of potentially active sub meshes.
  47438. */
  47439. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47440. /**
  47441. * Lambda returning the list of potentially intersecting sub meshes.
  47442. */
  47443. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47444. /**
  47445. * Lambda returning the list of potentially colliding sub meshes.
  47446. */
  47447. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47448. /** @hidden */
  47449. _activeMeshesFrozen: boolean;
  47450. private _skipEvaluateActiveMeshesCompletely;
  47451. /**
  47452. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47453. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47454. * @param onSuccess optional success callback
  47455. * @param onError optional error callback
  47456. * @returns the current scene
  47457. */
  47458. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47459. /**
  47460. * Use this function to restart evaluating active meshes on every frame
  47461. * @returns the current scene
  47462. */
  47463. unfreezeActiveMeshes(): Scene;
  47464. private _evaluateActiveMeshes;
  47465. private _activeMesh;
  47466. /**
  47467. * Update the transform matrix to update from the current active camera
  47468. * @param force defines a boolean used to force the update even if cache is up to date
  47469. */
  47470. updateTransformMatrix(force?: boolean): void;
  47471. private _bindFrameBuffer;
  47472. /** @hidden */
  47473. _allowPostProcessClearColor: boolean;
  47474. /** @hidden */
  47475. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47476. private _processSubCameras;
  47477. private _checkIntersections;
  47478. /** @hidden */
  47479. _advancePhysicsEngineStep(step: number): void;
  47480. /**
  47481. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47482. */
  47483. getDeterministicFrameTime: () => number;
  47484. /** @hidden */
  47485. _animate(): void;
  47486. /** Execute all animations (for a frame) */
  47487. animate(): void;
  47488. /**
  47489. * Render the scene
  47490. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47491. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47492. */
  47493. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47494. /**
  47495. * Freeze all materials
  47496. * A frozen material will not be updatable but should be faster to render
  47497. */
  47498. freezeMaterials(): void;
  47499. /**
  47500. * Unfreeze all materials
  47501. * A frozen material will not be updatable but should be faster to render
  47502. */
  47503. unfreezeMaterials(): void;
  47504. /**
  47505. * Releases all held ressources
  47506. */
  47507. dispose(): void;
  47508. /**
  47509. * Gets if the scene is already disposed
  47510. */
  47511. get isDisposed(): boolean;
  47512. /**
  47513. * Call this function to reduce memory footprint of the scene.
  47514. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47515. */
  47516. clearCachedVertexData(): void;
  47517. /**
  47518. * This function will remove the local cached buffer data from texture.
  47519. * It will save memory but will prevent the texture from being rebuilt
  47520. */
  47521. cleanCachedTextureBuffer(): void;
  47522. /**
  47523. * Get the world extend vectors with an optional filter
  47524. *
  47525. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47526. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47527. */
  47528. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47529. min: Vector3;
  47530. max: Vector3;
  47531. };
  47532. /**
  47533. * Creates a ray that can be used to pick in the scene
  47534. * @param x defines the x coordinate of the origin (on-screen)
  47535. * @param y defines the y coordinate of the origin (on-screen)
  47536. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47537. * @param camera defines the camera to use for the picking
  47538. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47539. * @returns a Ray
  47540. */
  47541. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47542. /**
  47543. * Creates a ray that can be used to pick in the scene
  47544. * @param x defines the x coordinate of the origin (on-screen)
  47545. * @param y defines the y coordinate of the origin (on-screen)
  47546. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47547. * @param result defines the ray where to store the picking ray
  47548. * @param camera defines the camera to use for the picking
  47549. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47550. * @returns the current scene
  47551. */
  47552. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47553. /**
  47554. * Creates a ray that can be used to pick in the scene
  47555. * @param x defines the x coordinate of the origin (on-screen)
  47556. * @param y defines the y coordinate of the origin (on-screen)
  47557. * @param camera defines the camera to use for the picking
  47558. * @returns a Ray
  47559. */
  47560. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47561. /**
  47562. * Creates a ray that can be used to pick in the scene
  47563. * @param x defines the x coordinate of the origin (on-screen)
  47564. * @param y defines the y coordinate of the origin (on-screen)
  47565. * @param result defines the ray where to store the picking ray
  47566. * @param camera defines the camera to use for the picking
  47567. * @returns the current scene
  47568. */
  47569. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47570. /** Launch a ray to try to pick a mesh in the scene
  47571. * @param x position on screen
  47572. * @param y position on screen
  47573. * @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
  47574. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47575. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47576. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47577. * @returns a PickingInfo
  47578. */
  47579. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47580. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47581. * @param x position on screen
  47582. * @param y position on screen
  47583. * @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
  47584. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47585. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47586. * @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)
  47587. */
  47588. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47589. /** Use the given ray to pick a mesh in the scene
  47590. * @param ray The ray to use to pick meshes
  47591. * @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
  47592. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47593. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47594. * @returns a PickingInfo
  47595. */
  47596. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47597. /**
  47598. * Launch a ray to try to pick a mesh in the scene
  47599. * @param x X position on screen
  47600. * @param y Y position on screen
  47601. * @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
  47602. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47603. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47604. * @returns an array of PickingInfo
  47605. */
  47606. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47607. /**
  47608. * Launch a ray to try to pick a mesh in the scene
  47609. * @param ray Ray to use
  47610. * @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
  47611. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47612. * @returns an array of PickingInfo
  47613. */
  47614. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47615. /**
  47616. * Force the value of meshUnderPointer
  47617. * @param mesh defines the mesh to use
  47618. * @param pointerId optional pointer id when using more than one pointer
  47619. */
  47620. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47621. /**
  47622. * Gets the mesh under the pointer
  47623. * @returns a Mesh or null if no mesh is under the pointer
  47624. */
  47625. getPointerOverMesh(): Nullable<AbstractMesh>;
  47626. /** @hidden */
  47627. _rebuildGeometries(): void;
  47628. /** @hidden */
  47629. _rebuildTextures(): void;
  47630. private _getByTags;
  47631. /**
  47632. * Get a list of meshes by tags
  47633. * @param tagsQuery defines the tags query to use
  47634. * @param forEach defines a predicate used to filter results
  47635. * @returns an array of Mesh
  47636. */
  47637. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47638. /**
  47639. * Get a list of cameras by tags
  47640. * @param tagsQuery defines the tags query to use
  47641. * @param forEach defines a predicate used to filter results
  47642. * @returns an array of Camera
  47643. */
  47644. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47645. /**
  47646. * Get a list of lights by tags
  47647. * @param tagsQuery defines the tags query to use
  47648. * @param forEach defines a predicate used to filter results
  47649. * @returns an array of Light
  47650. */
  47651. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47652. /**
  47653. * Get a list of materials by tags
  47654. * @param tagsQuery defines the tags query to use
  47655. * @param forEach defines a predicate used to filter results
  47656. * @returns an array of Material
  47657. */
  47658. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47659. /**
  47660. * Get a list of transform nodes by tags
  47661. * @param tagsQuery defines the tags query to use
  47662. * @param forEach defines a predicate used to filter results
  47663. * @returns an array of TransformNode
  47664. */
  47665. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47666. /**
  47667. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47668. * This allowed control for front to back rendering or reversly depending of the special needs.
  47669. *
  47670. * @param renderingGroupId The rendering group id corresponding to its index
  47671. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47672. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47673. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47674. */
  47675. 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;
  47676. /**
  47677. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47678. *
  47679. * @param renderingGroupId The rendering group id corresponding to its index
  47680. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47681. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47682. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47683. */
  47684. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47685. /**
  47686. * Gets the current auto clear configuration for one rendering group of the rendering
  47687. * manager.
  47688. * @param index the rendering group index to get the information for
  47689. * @returns The auto clear setup for the requested rendering group
  47690. */
  47691. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47692. private _blockMaterialDirtyMechanism;
  47693. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47694. get blockMaterialDirtyMechanism(): boolean;
  47695. set blockMaterialDirtyMechanism(value: boolean);
  47696. /**
  47697. * Will flag all materials as dirty to trigger new shader compilation
  47698. * @param flag defines the flag used to specify which material part must be marked as dirty
  47699. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47700. */
  47701. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47702. /** @hidden */
  47703. _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;
  47704. /** @hidden */
  47705. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47706. /** @hidden */
  47707. _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;
  47708. /** @hidden */
  47709. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47710. /** @hidden */
  47711. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47712. /** @hidden */
  47713. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47714. }
  47715. }
  47716. declare module BABYLON {
  47717. /**
  47718. * Set of assets to keep when moving a scene into an asset container.
  47719. */
  47720. export class KeepAssets extends AbstractScene {
  47721. }
  47722. /**
  47723. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  47724. */
  47725. export class InstantiatedEntries {
  47726. /**
  47727. * List of new root nodes (eg. nodes with no parent)
  47728. */
  47729. rootNodes: TransformNode[];
  47730. /**
  47731. * List of new skeletons
  47732. */
  47733. skeletons: Skeleton[];
  47734. /**
  47735. * List of new animation groups
  47736. */
  47737. animationGroups: AnimationGroup[];
  47738. }
  47739. /**
  47740. * Container with a set of assets that can be added or removed from a scene.
  47741. */
  47742. export class AssetContainer extends AbstractScene {
  47743. private _wasAddedToScene;
  47744. /**
  47745. * The scene the AssetContainer belongs to.
  47746. */
  47747. scene: Scene;
  47748. /**
  47749. * Instantiates an AssetContainer.
  47750. * @param scene The scene the AssetContainer belongs to.
  47751. */
  47752. constructor(scene: Scene);
  47753. /**
  47754. * Instantiate or clone all meshes and add the new ones to the scene.
  47755. * Skeletons and animation groups will all be cloned
  47756. * @param nameFunction defines an optional function used to get new names for clones
  47757. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  47758. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  47759. */
  47760. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  47761. /**
  47762. * Adds all the assets from the container to the scene.
  47763. */
  47764. addAllToScene(): void;
  47765. /**
  47766. * Removes all the assets in the container from the scene
  47767. */
  47768. removeAllFromScene(): void;
  47769. /**
  47770. * Disposes all the assets in the container
  47771. */
  47772. dispose(): void;
  47773. private _moveAssets;
  47774. /**
  47775. * Removes all the assets contained in the scene and adds them to the container.
  47776. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  47777. */
  47778. moveAllFromScene(keepAssets?: KeepAssets): void;
  47779. /**
  47780. * 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.
  47781. * @returns the root mesh
  47782. */
  47783. createRootMesh(): Mesh;
  47784. /**
  47785. * Merge animations (direct and animation groups) from this asset container into a scene
  47786. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47787. * @param animatables set of animatables to retarget to a node from the scene
  47788. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  47789. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  47790. */
  47791. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  47792. }
  47793. }
  47794. declare module BABYLON {
  47795. /**
  47796. * Defines how the parser contract is defined.
  47797. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  47798. */
  47799. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  47800. /**
  47801. * Defines how the individual parser contract is defined.
  47802. * These parser can parse an individual asset
  47803. */
  47804. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  47805. /**
  47806. * Base class of the scene acting as a container for the different elements composing a scene.
  47807. * This class is dynamically extended by the different components of the scene increasing
  47808. * flexibility and reducing coupling
  47809. */
  47810. export abstract class AbstractScene {
  47811. /**
  47812. * Stores the list of available parsers in the application.
  47813. */
  47814. private static _BabylonFileParsers;
  47815. /**
  47816. * Stores the list of available individual parsers in the application.
  47817. */
  47818. private static _IndividualBabylonFileParsers;
  47819. /**
  47820. * Adds a parser in the list of available ones
  47821. * @param name Defines the name of the parser
  47822. * @param parser Defines the parser to add
  47823. */
  47824. static AddParser(name: string, parser: BabylonFileParser): void;
  47825. /**
  47826. * Gets a general parser from the list of avaialble ones
  47827. * @param name Defines the name of the parser
  47828. * @returns the requested parser or null
  47829. */
  47830. static GetParser(name: string): Nullable<BabylonFileParser>;
  47831. /**
  47832. * Adds n individual parser in the list of available ones
  47833. * @param name Defines the name of the parser
  47834. * @param parser Defines the parser to add
  47835. */
  47836. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47837. /**
  47838. * Gets an individual parser from the list of avaialble ones
  47839. * @param name Defines the name of the parser
  47840. * @returns the requested parser or null
  47841. */
  47842. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  47843. /**
  47844. * Parser json data and populate both a scene and its associated container object
  47845. * @param jsonData Defines the data to parse
  47846. * @param scene Defines the scene to parse the data for
  47847. * @param container Defines the container attached to the parsing sequence
  47848. * @param rootUrl Defines the root url of the data
  47849. */
  47850. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  47851. /**
  47852. * Gets the list of root nodes (ie. nodes with no parent)
  47853. */
  47854. rootNodes: Node[];
  47855. /** All of the cameras added to this scene
  47856. * @see https://doc.babylonjs.com/babylon101/cameras
  47857. */
  47858. cameras: Camera[];
  47859. /**
  47860. * All of the lights added to this scene
  47861. * @see https://doc.babylonjs.com/babylon101/lights
  47862. */
  47863. lights: Light[];
  47864. /**
  47865. * All of the (abstract) meshes added to this scene
  47866. */
  47867. meshes: AbstractMesh[];
  47868. /**
  47869. * The list of skeletons added to the scene
  47870. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  47871. */
  47872. skeletons: Skeleton[];
  47873. /**
  47874. * All of the particle systems added to this scene
  47875. * @see https://doc.babylonjs.com/babylon101/particles
  47876. */
  47877. particleSystems: IParticleSystem[];
  47878. /**
  47879. * Gets a list of Animations associated with the scene
  47880. */
  47881. animations: Animation[];
  47882. /**
  47883. * All of the animation groups added to this scene
  47884. * @see https://doc.babylonjs.com/how_to/group
  47885. */
  47886. animationGroups: AnimationGroup[];
  47887. /**
  47888. * All of the multi-materials added to this scene
  47889. * @see https://doc.babylonjs.com/how_to/multi_materials
  47890. */
  47891. multiMaterials: MultiMaterial[];
  47892. /**
  47893. * All of the materials added to this scene
  47894. * In the context of a Scene, it is not supposed to be modified manually.
  47895. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  47896. * Note also that the order of the Material within the array is not significant and might change.
  47897. * @see https://doc.babylonjs.com/babylon101/materials
  47898. */
  47899. materials: Material[];
  47900. /**
  47901. * The list of morph target managers added to the scene
  47902. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  47903. */
  47904. morphTargetManagers: MorphTargetManager[];
  47905. /**
  47906. * The list of geometries used in the scene.
  47907. */
  47908. geometries: Geometry[];
  47909. /**
  47910. * All of the tranform nodes added to this scene
  47911. * In the context of a Scene, it is not supposed to be modified manually.
  47912. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  47913. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  47914. * @see https://doc.babylonjs.com/how_to/transformnode
  47915. */
  47916. transformNodes: TransformNode[];
  47917. /**
  47918. * ActionManagers available on the scene.
  47919. */
  47920. actionManagers: AbstractActionManager[];
  47921. /**
  47922. * Textures to keep.
  47923. */
  47924. textures: BaseTexture[];
  47925. /** @hidden */
  47926. protected _environmentTexture: Nullable<BaseTexture>;
  47927. /**
  47928. * Texture used in all pbr material as the reflection texture.
  47929. * As in the majority of the scene they are the same (exception for multi room and so on),
  47930. * this is easier to reference from here than from all the materials.
  47931. */
  47932. get environmentTexture(): Nullable<BaseTexture>;
  47933. set environmentTexture(value: Nullable<BaseTexture>);
  47934. /**
  47935. * The list of postprocesses added to the scene
  47936. */
  47937. postProcesses: PostProcess[];
  47938. /**
  47939. * @returns all meshes, lights, cameras, transformNodes and bones
  47940. */
  47941. getNodes(): Array<Node>;
  47942. }
  47943. }
  47944. declare module BABYLON {
  47945. /**
  47946. * Interface used to define options for Sound class
  47947. */
  47948. export interface ISoundOptions {
  47949. /**
  47950. * Does the sound autoplay once loaded.
  47951. */
  47952. autoplay?: boolean;
  47953. /**
  47954. * Does the sound loop after it finishes playing once.
  47955. */
  47956. loop?: boolean;
  47957. /**
  47958. * Sound's volume
  47959. */
  47960. volume?: number;
  47961. /**
  47962. * Is it a spatial sound?
  47963. */
  47964. spatialSound?: boolean;
  47965. /**
  47966. * Maximum distance to hear that sound
  47967. */
  47968. maxDistance?: number;
  47969. /**
  47970. * Uses user defined attenuation function
  47971. */
  47972. useCustomAttenuation?: boolean;
  47973. /**
  47974. * Define the roll off factor of spatial sounds.
  47975. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47976. */
  47977. rolloffFactor?: number;
  47978. /**
  47979. * Define the reference distance the sound should be heard perfectly.
  47980. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47981. */
  47982. refDistance?: number;
  47983. /**
  47984. * Define the distance attenuation model the sound will follow.
  47985. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47986. */
  47987. distanceModel?: string;
  47988. /**
  47989. * Defines the playback speed (1 by default)
  47990. */
  47991. playbackRate?: number;
  47992. /**
  47993. * Defines if the sound is from a streaming source
  47994. */
  47995. streaming?: boolean;
  47996. /**
  47997. * Defines an optional length (in seconds) inside the sound file
  47998. */
  47999. length?: number;
  48000. /**
  48001. * Defines an optional offset (in seconds) inside the sound file
  48002. */
  48003. offset?: number;
  48004. /**
  48005. * If true, URLs will not be required to state the audio file codec to use.
  48006. */
  48007. skipCodecCheck?: boolean;
  48008. }
  48009. }
  48010. declare module BABYLON {
  48011. /**
  48012. * Defines a sound that can be played in the application.
  48013. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  48014. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48015. */
  48016. export class Sound {
  48017. /**
  48018. * The name of the sound in the scene.
  48019. */
  48020. name: string;
  48021. /**
  48022. * Does the sound autoplay once loaded.
  48023. */
  48024. autoplay: boolean;
  48025. private _loop;
  48026. /**
  48027. * Does the sound loop after it finishes playing once.
  48028. */
  48029. get loop(): boolean;
  48030. set loop(value: boolean);
  48031. /**
  48032. * Does the sound use a custom attenuation curve to simulate the falloff
  48033. * happening when the source gets further away from the camera.
  48034. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48035. */
  48036. useCustomAttenuation: boolean;
  48037. /**
  48038. * The sound track id this sound belongs to.
  48039. */
  48040. soundTrackId: number;
  48041. /**
  48042. * Is this sound currently played.
  48043. */
  48044. isPlaying: boolean;
  48045. /**
  48046. * Is this sound currently paused.
  48047. */
  48048. isPaused: boolean;
  48049. /**
  48050. * Does this sound enables spatial sound.
  48051. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48052. */
  48053. spatialSound: boolean;
  48054. /**
  48055. * Define the reference distance the sound should be heard perfectly.
  48056. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48057. */
  48058. refDistance: number;
  48059. /**
  48060. * Define the roll off factor of spatial sounds.
  48061. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48062. */
  48063. rolloffFactor: number;
  48064. /**
  48065. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48066. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48067. */
  48068. maxDistance: number;
  48069. /**
  48070. * Define the distance attenuation model the sound will follow.
  48071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48072. */
  48073. distanceModel: string;
  48074. /**
  48075. * @hidden
  48076. * Back Compat
  48077. **/
  48078. onended: () => any;
  48079. /**
  48080. * Gets or sets an object used to store user defined information for the sound.
  48081. */
  48082. metadata: any;
  48083. /**
  48084. * Observable event when the current playing sound finishes.
  48085. */
  48086. onEndedObservable: Observable<Sound>;
  48087. /**
  48088. * Gets the current time for the sound.
  48089. */
  48090. get currentTime(): number;
  48091. private _panningModel;
  48092. private _playbackRate;
  48093. private _streaming;
  48094. private _startTime;
  48095. private _startOffset;
  48096. private _position;
  48097. /** @hidden */
  48098. _positionInEmitterSpace: boolean;
  48099. private _localDirection;
  48100. private _volume;
  48101. private _isReadyToPlay;
  48102. private _isDirectional;
  48103. private _readyToPlayCallback;
  48104. private _audioBuffer;
  48105. private _soundSource;
  48106. private _streamingSource;
  48107. private _soundPanner;
  48108. private _soundGain;
  48109. private _inputAudioNode;
  48110. private _outputAudioNode;
  48111. private _coneInnerAngle;
  48112. private _coneOuterAngle;
  48113. private _coneOuterGain;
  48114. private _scene;
  48115. private _connectedTransformNode;
  48116. private _customAttenuationFunction;
  48117. private _registerFunc;
  48118. private _isOutputConnected;
  48119. private _htmlAudioElement;
  48120. private _urlType;
  48121. private _length?;
  48122. private _offset?;
  48123. /** @hidden */
  48124. static _SceneComponentInitialization: (scene: Scene) => void;
  48125. /**
  48126. * Create a sound and attach it to a scene
  48127. * @param name Name of your sound
  48128. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48129. * @param scene defines the scene the sound belongs to
  48130. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48131. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48132. */
  48133. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48134. /**
  48135. * Release the sound and its associated resources
  48136. */
  48137. dispose(): void;
  48138. /**
  48139. * Gets if the sounds is ready to be played or not.
  48140. * @returns true if ready, otherwise false
  48141. */
  48142. isReady(): boolean;
  48143. /**
  48144. * Get the current class name.
  48145. * @returns current class name
  48146. */
  48147. getClassName(): string;
  48148. private _soundLoaded;
  48149. /**
  48150. * Sets the data of the sound from an audiobuffer
  48151. * @param audioBuffer The audioBuffer containing the data
  48152. */
  48153. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48154. /**
  48155. * Updates the current sounds options such as maxdistance, loop...
  48156. * @param options A JSON object containing values named as the object properties
  48157. */
  48158. updateOptions(options: ISoundOptions): void;
  48159. private _createSpatialParameters;
  48160. private _updateSpatialParameters;
  48161. /**
  48162. * Switch the panning model to HRTF:
  48163. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48164. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48165. */
  48166. switchPanningModelToHRTF(): void;
  48167. /**
  48168. * Switch the panning model to Equal Power:
  48169. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48170. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48171. */
  48172. switchPanningModelToEqualPower(): void;
  48173. private _switchPanningModel;
  48174. /**
  48175. * Connect this sound to a sound track audio node like gain...
  48176. * @param soundTrackAudioNode the sound track audio node to connect to
  48177. */
  48178. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48179. /**
  48180. * Transform this sound into a directional source
  48181. * @param coneInnerAngle Size of the inner cone in degree
  48182. * @param coneOuterAngle Size of the outer cone in degree
  48183. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48184. */
  48185. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48186. /**
  48187. * Gets or sets the inner angle for the directional cone.
  48188. */
  48189. get directionalConeInnerAngle(): number;
  48190. /**
  48191. * Gets or sets the inner angle for the directional cone.
  48192. */
  48193. set directionalConeInnerAngle(value: number);
  48194. /**
  48195. * Gets or sets the outer angle for the directional cone.
  48196. */
  48197. get directionalConeOuterAngle(): number;
  48198. /**
  48199. * Gets or sets the outer angle for the directional cone.
  48200. */
  48201. set directionalConeOuterAngle(value: number);
  48202. /**
  48203. * Sets the position of the emitter if spatial sound is enabled
  48204. * @param newPosition Defines the new posisiton
  48205. */
  48206. setPosition(newPosition: Vector3): void;
  48207. /**
  48208. * Sets the local direction of the emitter if spatial sound is enabled
  48209. * @param newLocalDirection Defines the new local direction
  48210. */
  48211. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48212. private _updateDirection;
  48213. /** @hidden */
  48214. updateDistanceFromListener(): void;
  48215. /**
  48216. * Sets a new custom attenuation function for the sound.
  48217. * @param callback Defines the function used for the attenuation
  48218. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48219. */
  48220. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48221. /**
  48222. * Play the sound
  48223. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48224. * @param offset (optional) Start the sound at a specific time in seconds
  48225. * @param length (optional) Sound duration (in seconds)
  48226. */
  48227. play(time?: number, offset?: number, length?: number): void;
  48228. private _onended;
  48229. /**
  48230. * Stop the sound
  48231. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48232. */
  48233. stop(time?: number): void;
  48234. /**
  48235. * Put the sound in pause
  48236. */
  48237. pause(): void;
  48238. /**
  48239. * Sets a dedicated volume for this sounds
  48240. * @param newVolume Define the new volume of the sound
  48241. * @param time Define time for gradual change to new volume
  48242. */
  48243. setVolume(newVolume: number, time?: number): void;
  48244. /**
  48245. * Set the sound play back rate
  48246. * @param newPlaybackRate Define the playback rate the sound should be played at
  48247. */
  48248. setPlaybackRate(newPlaybackRate: number): void;
  48249. /**
  48250. * Gets the volume of the sound.
  48251. * @returns the volume of the sound
  48252. */
  48253. getVolume(): number;
  48254. /**
  48255. * Attach the sound to a dedicated mesh
  48256. * @param transformNode The transform node to connect the sound with
  48257. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48258. */
  48259. attachToMesh(transformNode: TransformNode): void;
  48260. /**
  48261. * Detach the sound from the previously attached mesh
  48262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48263. */
  48264. detachFromMesh(): void;
  48265. private _onRegisterAfterWorldMatrixUpdate;
  48266. /**
  48267. * Clone the current sound in the scene.
  48268. * @returns the new sound clone
  48269. */
  48270. clone(): Nullable<Sound>;
  48271. /**
  48272. * Gets the current underlying audio buffer containing the data
  48273. * @returns the audio buffer
  48274. */
  48275. getAudioBuffer(): Nullable<AudioBuffer>;
  48276. /**
  48277. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48278. * @returns the source node
  48279. */
  48280. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48281. /**
  48282. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48283. * @returns the gain node
  48284. */
  48285. getSoundGain(): Nullable<GainNode>;
  48286. /**
  48287. * Serializes the Sound in a JSON representation
  48288. * @returns the JSON representation of the sound
  48289. */
  48290. serialize(): any;
  48291. /**
  48292. * Parse a JSON representation of a sound to innstantiate in a given scene
  48293. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48294. * @param scene Define the scene the new parsed sound should be created in
  48295. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48296. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  48297. * @returns the newly parsed sound
  48298. */
  48299. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48300. }
  48301. }
  48302. declare module BABYLON {
  48303. /**
  48304. * This defines an action helpful to play a defined sound on a triggered action.
  48305. */
  48306. export class PlaySoundAction extends Action {
  48307. private _sound;
  48308. /**
  48309. * Instantiate the action
  48310. * @param triggerOptions defines the trigger options
  48311. * @param sound defines the sound to play
  48312. * @param condition defines the trigger related conditions
  48313. */
  48314. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48315. /** @hidden */
  48316. _prepare(): void;
  48317. /**
  48318. * Execute the action and play the sound.
  48319. */
  48320. execute(): void;
  48321. /**
  48322. * Serializes the actions and its related information.
  48323. * @param parent defines the object to serialize in
  48324. * @returns the serialized object
  48325. */
  48326. serialize(parent: any): any;
  48327. }
  48328. /**
  48329. * This defines an action helpful to stop a defined sound on a triggered action.
  48330. */
  48331. export class StopSoundAction extends Action {
  48332. private _sound;
  48333. /**
  48334. * Instantiate the action
  48335. * @param triggerOptions defines the trigger options
  48336. * @param sound defines the sound to stop
  48337. * @param condition defines the trigger related conditions
  48338. */
  48339. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48340. /** @hidden */
  48341. _prepare(): void;
  48342. /**
  48343. * Execute the action and stop the sound.
  48344. */
  48345. execute(): void;
  48346. /**
  48347. * Serializes the actions and its related information.
  48348. * @param parent defines the object to serialize in
  48349. * @returns the serialized object
  48350. */
  48351. serialize(parent: any): any;
  48352. }
  48353. }
  48354. declare module BABYLON {
  48355. /**
  48356. * This defines an action responsible to change the value of a property
  48357. * by interpolating between its current value and the newly set one once triggered.
  48358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48359. */
  48360. export class InterpolateValueAction extends Action {
  48361. /**
  48362. * Defines the path of the property where the value should be interpolated
  48363. */
  48364. propertyPath: string;
  48365. /**
  48366. * Defines the target value at the end of the interpolation.
  48367. */
  48368. value: any;
  48369. /**
  48370. * Defines the time it will take for the property to interpolate to the value.
  48371. */
  48372. duration: number;
  48373. /**
  48374. * Defines if the other scene animations should be stopped when the action has been triggered
  48375. */
  48376. stopOtherAnimations?: boolean;
  48377. /**
  48378. * Defines a callback raised once the interpolation animation has been done.
  48379. */
  48380. onInterpolationDone?: () => void;
  48381. /**
  48382. * Observable triggered once the interpolation animation has been done.
  48383. */
  48384. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48385. private _target;
  48386. private _effectiveTarget;
  48387. private _property;
  48388. /**
  48389. * Instantiate the action
  48390. * @param triggerOptions defines the trigger options
  48391. * @param target defines the object containing the value to interpolate
  48392. * @param propertyPath defines the path to the property in the target object
  48393. * @param value defines the target value at the end of the interpolation
  48394. * @param duration deines the time it will take for the property to interpolate to the value.
  48395. * @param condition defines the trigger related conditions
  48396. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48397. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48398. */
  48399. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48400. /** @hidden */
  48401. _prepare(): void;
  48402. /**
  48403. * Execute the action starts the value interpolation.
  48404. */
  48405. execute(): void;
  48406. /**
  48407. * Serializes the actions and its related information.
  48408. * @param parent defines the object to serialize in
  48409. * @returns the serialized object
  48410. */
  48411. serialize(parent: any): any;
  48412. }
  48413. }
  48414. declare module BABYLON {
  48415. /**
  48416. * This represents the default audio engine used in babylon.
  48417. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48418. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48419. */
  48420. export class AudioEngine implements IAudioEngine {
  48421. private _audioContext;
  48422. private _audioContextInitialized;
  48423. private _muteButton;
  48424. private _hostElement;
  48425. /**
  48426. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48427. */
  48428. canUseWebAudio: boolean;
  48429. /**
  48430. * The master gain node defines the global audio volume of your audio engine.
  48431. */
  48432. masterGain: GainNode;
  48433. /**
  48434. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48435. * @ignoreNaming
  48436. */
  48437. WarnedWebAudioUnsupported: boolean;
  48438. /**
  48439. * Gets whether or not mp3 are supported by your browser.
  48440. */
  48441. isMP3supported: boolean;
  48442. /**
  48443. * Gets whether or not ogg are supported by your browser.
  48444. */
  48445. isOGGsupported: boolean;
  48446. /**
  48447. * Gets whether audio has been unlocked on the device.
  48448. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48449. * a user interaction has happened.
  48450. */
  48451. unlocked: boolean;
  48452. /**
  48453. * Defines if the audio engine relies on a custom unlocked button.
  48454. * In this case, the embedded button will not be displayed.
  48455. */
  48456. useCustomUnlockedButton: boolean;
  48457. /**
  48458. * Event raised when audio has been unlocked on the browser.
  48459. */
  48460. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48461. /**
  48462. * Event raised when audio has been locked on the browser.
  48463. */
  48464. onAudioLockedObservable: Observable<IAudioEngine>;
  48465. /**
  48466. * Gets the current AudioContext if available.
  48467. */
  48468. get audioContext(): Nullable<AudioContext>;
  48469. private _connectedAnalyser;
  48470. /**
  48471. * Instantiates a new audio engine.
  48472. *
  48473. * There should be only one per page as some browsers restrict the number
  48474. * of audio contexts you can create.
  48475. * @param hostElement defines the host element where to display the mute icon if necessary
  48476. */
  48477. constructor(hostElement?: Nullable<HTMLElement>);
  48478. /**
  48479. * Flags the audio engine in Locked state.
  48480. * This happens due to new browser policies preventing audio to autoplay.
  48481. */
  48482. lock(): void;
  48483. /**
  48484. * Unlocks the audio engine once a user action has been done on the dom.
  48485. * This is helpful to resume play once browser policies have been satisfied.
  48486. */
  48487. unlock(): void;
  48488. private _resumeAudioContext;
  48489. private _initializeAudioContext;
  48490. private _tryToRun;
  48491. private _triggerRunningState;
  48492. private _triggerSuspendedState;
  48493. private _displayMuteButton;
  48494. private _moveButtonToTopLeft;
  48495. private _onResize;
  48496. private _hideMuteButton;
  48497. /**
  48498. * Destroy and release the resources associated with the audio ccontext.
  48499. */
  48500. dispose(): void;
  48501. /**
  48502. * Gets the global volume sets on the master gain.
  48503. * @returns the global volume if set or -1 otherwise
  48504. */
  48505. getGlobalVolume(): number;
  48506. /**
  48507. * Sets the global volume of your experience (sets on the master gain).
  48508. * @param newVolume Defines the new global volume of the application
  48509. */
  48510. setGlobalVolume(newVolume: number): void;
  48511. /**
  48512. * Connect the audio engine to an audio analyser allowing some amazing
  48513. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48514. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48515. * @param analyser The analyser to connect to the engine
  48516. */
  48517. connectToAnalyser(analyser: Analyser): void;
  48518. }
  48519. }
  48520. declare module BABYLON {
  48521. /**
  48522. * Options allowed during the creation of a sound track.
  48523. */
  48524. export interface ISoundTrackOptions {
  48525. /**
  48526. * The volume the sound track should take during creation
  48527. */
  48528. volume?: number;
  48529. /**
  48530. * Define if the sound track is the main sound track of the scene
  48531. */
  48532. mainTrack?: boolean;
  48533. }
  48534. /**
  48535. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48536. * It will be also used in a future release to apply effects on a specific track.
  48537. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48538. */
  48539. export class SoundTrack {
  48540. /**
  48541. * The unique identifier of the sound track in the scene.
  48542. */
  48543. id: number;
  48544. /**
  48545. * The list of sounds included in the sound track.
  48546. */
  48547. soundCollection: Array<Sound>;
  48548. private _outputAudioNode;
  48549. private _scene;
  48550. private _connectedAnalyser;
  48551. private _options;
  48552. private _isInitialized;
  48553. /**
  48554. * Creates a new sound track.
  48555. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48556. * @param scene Define the scene the sound track belongs to
  48557. * @param options
  48558. */
  48559. constructor(scene: Scene, options?: ISoundTrackOptions);
  48560. private _initializeSoundTrackAudioGraph;
  48561. /**
  48562. * Release the sound track and its associated resources
  48563. */
  48564. dispose(): void;
  48565. /**
  48566. * Adds a sound to this sound track
  48567. * @param sound define the cound to add
  48568. * @ignoreNaming
  48569. */
  48570. addSound(sound: Sound): void;
  48571. /**
  48572. * Removes a sound to this sound track
  48573. * @param sound define the cound to remove
  48574. * @ignoreNaming
  48575. */
  48576. removeSound(sound: Sound): void;
  48577. /**
  48578. * Set a global volume for the full sound track.
  48579. * @param newVolume Define the new volume of the sound track
  48580. */
  48581. setVolume(newVolume: number): void;
  48582. /**
  48583. * Switch the panning model to HRTF:
  48584. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48585. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48586. */
  48587. switchPanningModelToHRTF(): void;
  48588. /**
  48589. * Switch the panning model to Equal Power:
  48590. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48591. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48592. */
  48593. switchPanningModelToEqualPower(): void;
  48594. /**
  48595. * Connect the sound track to an audio analyser allowing some amazing
  48596. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48597. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48598. * @param analyser The analyser to connect to the engine
  48599. */
  48600. connectToAnalyser(analyser: Analyser): void;
  48601. }
  48602. }
  48603. declare module BABYLON {
  48604. interface AbstractScene {
  48605. /**
  48606. * The list of sounds used in the scene.
  48607. */
  48608. sounds: Nullable<Array<Sound>>;
  48609. }
  48610. interface Scene {
  48611. /**
  48612. * @hidden
  48613. * Backing field
  48614. */
  48615. _mainSoundTrack: SoundTrack;
  48616. /**
  48617. * The main sound track played by the scene.
  48618. * It cotains your primary collection of sounds.
  48619. */
  48620. mainSoundTrack: SoundTrack;
  48621. /**
  48622. * The list of sound tracks added to the scene
  48623. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48624. */
  48625. soundTracks: Nullable<Array<SoundTrack>>;
  48626. /**
  48627. * Gets a sound using a given name
  48628. * @param name defines the name to search for
  48629. * @return the found sound or null if not found at all.
  48630. */
  48631. getSoundByName(name: string): Nullable<Sound>;
  48632. /**
  48633. * Gets or sets if audio support is enabled
  48634. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48635. */
  48636. audioEnabled: boolean;
  48637. /**
  48638. * Gets or sets if audio will be output to headphones
  48639. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48640. */
  48641. headphone: boolean;
  48642. /**
  48643. * Gets or sets custom audio listener position provider
  48644. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48645. */
  48646. audioListenerPositionProvider: Nullable<() => Vector3>;
  48647. /**
  48648. * Gets or sets a refresh rate when using 3D audio positioning
  48649. */
  48650. audioPositioningRefreshRate: number;
  48651. }
  48652. /**
  48653. * Defines the sound scene component responsible to manage any sounds
  48654. * in a given scene.
  48655. */
  48656. export class AudioSceneComponent implements ISceneSerializableComponent {
  48657. private static _CameraDirectionLH;
  48658. private static _CameraDirectionRH;
  48659. /**
  48660. * The component name helpfull to identify the component in the list of scene components.
  48661. */
  48662. readonly name: string;
  48663. /**
  48664. * The scene the component belongs to.
  48665. */
  48666. scene: Scene;
  48667. private _audioEnabled;
  48668. /**
  48669. * Gets whether audio is enabled or not.
  48670. * Please use related enable/disable method to switch state.
  48671. */
  48672. get audioEnabled(): boolean;
  48673. private _headphone;
  48674. /**
  48675. * Gets whether audio is outputing to headphone or not.
  48676. * Please use the according Switch methods to change output.
  48677. */
  48678. get headphone(): boolean;
  48679. /**
  48680. * Gets or sets a refresh rate when using 3D audio positioning
  48681. */
  48682. audioPositioningRefreshRate: number;
  48683. private _audioListenerPositionProvider;
  48684. /**
  48685. * Gets the current audio listener position provider
  48686. */
  48687. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48688. /**
  48689. * Sets a custom listener position for all sounds in the scene
  48690. * By default, this is the position of the first active camera
  48691. */
  48692. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48693. /**
  48694. * Creates a new instance of the component for the given scene
  48695. * @param scene Defines the scene to register the component in
  48696. */
  48697. constructor(scene: Scene);
  48698. /**
  48699. * Registers the component in a given scene
  48700. */
  48701. register(): void;
  48702. /**
  48703. * Rebuilds the elements related to this component in case of
  48704. * context lost for instance.
  48705. */
  48706. rebuild(): void;
  48707. /**
  48708. * Serializes the component data to the specified json object
  48709. * @param serializationObject The object to serialize to
  48710. */
  48711. serialize(serializationObject: any): void;
  48712. /**
  48713. * Adds all the elements from the container to the scene
  48714. * @param container the container holding the elements
  48715. */
  48716. addFromContainer(container: AbstractScene): void;
  48717. /**
  48718. * Removes all the elements in the container from the scene
  48719. * @param container contains the elements to remove
  48720. * @param dispose if the removed element should be disposed (default: false)
  48721. */
  48722. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48723. /**
  48724. * Disposes the component and the associated ressources.
  48725. */
  48726. dispose(): void;
  48727. /**
  48728. * Disables audio in the associated scene.
  48729. */
  48730. disableAudio(): void;
  48731. /**
  48732. * Enables audio in the associated scene.
  48733. */
  48734. enableAudio(): void;
  48735. /**
  48736. * Switch audio to headphone output.
  48737. */
  48738. switchAudioModeForHeadphones(): void;
  48739. /**
  48740. * Switch audio to normal speakers.
  48741. */
  48742. switchAudioModeForNormalSpeakers(): void;
  48743. private _cachedCameraDirection;
  48744. private _cachedCameraPosition;
  48745. private _lastCheck;
  48746. private _afterRender;
  48747. }
  48748. }
  48749. declare module BABYLON {
  48750. /**
  48751. * Wraps one or more Sound objects and selects one with random weight for playback.
  48752. */
  48753. export class WeightedSound {
  48754. /** When true a Sound will be selected and played when the current playing Sound completes. */
  48755. loop: boolean;
  48756. private _coneInnerAngle;
  48757. private _coneOuterAngle;
  48758. private _volume;
  48759. /** A Sound is currently playing. */
  48760. isPlaying: boolean;
  48761. /** A Sound is currently paused. */
  48762. isPaused: boolean;
  48763. private _sounds;
  48764. private _weights;
  48765. private _currentIndex?;
  48766. /**
  48767. * Creates a new WeightedSound from the list of sounds given.
  48768. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  48769. * @param sounds Array of Sounds that will be selected from.
  48770. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  48771. */
  48772. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  48773. /**
  48774. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  48775. */
  48776. get directionalConeInnerAngle(): number;
  48777. /**
  48778. * The size of cone in degress for a directional sound in which there will be no attenuation.
  48779. */
  48780. set directionalConeInnerAngle(value: number);
  48781. /**
  48782. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48783. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48784. */
  48785. get directionalConeOuterAngle(): number;
  48786. /**
  48787. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48788. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48789. */
  48790. set directionalConeOuterAngle(value: number);
  48791. /**
  48792. * Playback volume.
  48793. */
  48794. get volume(): number;
  48795. /**
  48796. * Playback volume.
  48797. */
  48798. set volume(value: number);
  48799. private _onended;
  48800. /**
  48801. * Suspend playback
  48802. */
  48803. pause(): void;
  48804. /**
  48805. * Stop playback
  48806. */
  48807. stop(): void;
  48808. /**
  48809. * Start playback.
  48810. * @param startOffset Position the clip head at a specific time in seconds.
  48811. */
  48812. play(startOffset?: number): void;
  48813. }
  48814. }
  48815. declare module BABYLON {
  48816. /**
  48817. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  48818. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48819. */
  48820. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  48821. /**
  48822. * Gets the name of the behavior.
  48823. */
  48824. get name(): string;
  48825. /**
  48826. * The easing function used by animations
  48827. */
  48828. static EasingFunction: BackEase;
  48829. /**
  48830. * The easing mode used by animations
  48831. */
  48832. static EasingMode: number;
  48833. /**
  48834. * The duration of the animation, in milliseconds
  48835. */
  48836. transitionDuration: number;
  48837. /**
  48838. * Length of the distance animated by the transition when lower radius is reached
  48839. */
  48840. lowerRadiusTransitionRange: number;
  48841. /**
  48842. * Length of the distance animated by the transition when upper radius is reached
  48843. */
  48844. upperRadiusTransitionRange: number;
  48845. private _autoTransitionRange;
  48846. /**
  48847. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48848. */
  48849. get autoTransitionRange(): boolean;
  48850. /**
  48851. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48852. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  48853. */
  48854. set autoTransitionRange(value: boolean);
  48855. private _attachedCamera;
  48856. private _onAfterCheckInputsObserver;
  48857. private _onMeshTargetChangedObserver;
  48858. /**
  48859. * Initializes the behavior.
  48860. */
  48861. init(): void;
  48862. /**
  48863. * Attaches the behavior to its arc rotate camera.
  48864. * @param camera Defines the camera to attach the behavior to
  48865. */
  48866. attach(camera: ArcRotateCamera): void;
  48867. /**
  48868. * Detaches the behavior from its current arc rotate camera.
  48869. */
  48870. detach(): void;
  48871. private _radiusIsAnimating;
  48872. private _radiusBounceTransition;
  48873. private _animatables;
  48874. private _cachedWheelPrecision;
  48875. /**
  48876. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  48877. * @param radiusLimit The limit to check against.
  48878. * @return Bool to indicate if at limit.
  48879. */
  48880. private _isRadiusAtLimit;
  48881. /**
  48882. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  48883. * @param radiusDelta The delta by which to animate to. Can be negative.
  48884. */
  48885. private _applyBoundRadiusAnimation;
  48886. /**
  48887. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  48888. */
  48889. protected _clearAnimationLocks(): void;
  48890. /**
  48891. * Stops and removes all animations that have been applied to the camera
  48892. */
  48893. stopAllAnimations(): void;
  48894. }
  48895. }
  48896. declare module BABYLON {
  48897. /**
  48898. * 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.
  48899. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48900. */
  48901. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  48902. /**
  48903. * Gets the name of the behavior.
  48904. */
  48905. get name(): string;
  48906. private _mode;
  48907. private _radiusScale;
  48908. private _positionScale;
  48909. private _defaultElevation;
  48910. private _elevationReturnTime;
  48911. private _elevationReturnWaitTime;
  48912. private _zoomStopsAnimation;
  48913. private _framingTime;
  48914. /**
  48915. * The easing function used by animations
  48916. */
  48917. static EasingFunction: ExponentialEase;
  48918. /**
  48919. * The easing mode used by animations
  48920. */
  48921. static EasingMode: number;
  48922. /**
  48923. * Sets the current mode used by the behavior
  48924. */
  48925. set mode(mode: number);
  48926. /**
  48927. * Gets current mode used by the behavior.
  48928. */
  48929. get mode(): number;
  48930. /**
  48931. * Sets the scale applied to the radius (1 by default)
  48932. */
  48933. set radiusScale(radius: number);
  48934. /**
  48935. * Gets the scale applied to the radius
  48936. */
  48937. get radiusScale(): number;
  48938. /**
  48939. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48940. */
  48941. set positionScale(scale: number);
  48942. /**
  48943. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48944. */
  48945. get positionScale(): number;
  48946. /**
  48947. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48948. * behaviour is triggered, in radians.
  48949. */
  48950. set defaultElevation(elevation: number);
  48951. /**
  48952. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48953. * behaviour is triggered, in radians.
  48954. */
  48955. get defaultElevation(): number;
  48956. /**
  48957. * Sets the time (in milliseconds) taken to return to the default beta position.
  48958. * Negative value indicates camera should not return to default.
  48959. */
  48960. set elevationReturnTime(speed: number);
  48961. /**
  48962. * Gets the time (in milliseconds) taken to return to the default beta position.
  48963. * Negative value indicates camera should not return to default.
  48964. */
  48965. get elevationReturnTime(): number;
  48966. /**
  48967. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48968. */
  48969. set elevationReturnWaitTime(time: number);
  48970. /**
  48971. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48972. */
  48973. get elevationReturnWaitTime(): number;
  48974. /**
  48975. * Sets the flag that indicates if user zooming should stop animation.
  48976. */
  48977. set zoomStopsAnimation(flag: boolean);
  48978. /**
  48979. * Gets the flag that indicates if user zooming should stop animation.
  48980. */
  48981. get zoomStopsAnimation(): boolean;
  48982. /**
  48983. * Sets the transition time when framing the mesh, in milliseconds
  48984. */
  48985. set framingTime(time: number);
  48986. /**
  48987. * Gets the transition time when framing the mesh, in milliseconds
  48988. */
  48989. get framingTime(): number;
  48990. /**
  48991. * Define if the behavior should automatically change the configured
  48992. * camera limits and sensibilities.
  48993. */
  48994. autoCorrectCameraLimitsAndSensibility: boolean;
  48995. private _onPrePointerObservableObserver;
  48996. private _onAfterCheckInputsObserver;
  48997. private _onMeshTargetChangedObserver;
  48998. private _attachedCamera;
  48999. private _isPointerDown;
  49000. private _lastInteractionTime;
  49001. /**
  49002. * Initializes the behavior.
  49003. */
  49004. init(): void;
  49005. /**
  49006. * Attaches the behavior to its arc rotate camera.
  49007. * @param camera Defines the camera to attach the behavior to
  49008. */
  49009. attach(camera: ArcRotateCamera): void;
  49010. /**
  49011. * Detaches the behavior from its current arc rotate camera.
  49012. */
  49013. detach(): void;
  49014. private _animatables;
  49015. private _betaIsAnimating;
  49016. private _betaTransition;
  49017. private _radiusTransition;
  49018. private _vectorTransition;
  49019. /**
  49020. * Targets the given mesh and updates zoom level accordingly.
  49021. * @param mesh The mesh to target.
  49022. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49023. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49024. */
  49025. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49026. /**
  49027. * Targets the given mesh with its children and updates zoom level accordingly.
  49028. * @param mesh The mesh to target.
  49029. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49030. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49031. */
  49032. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49033. /**
  49034. * Targets the given meshes with their children and updates zoom level accordingly.
  49035. * @param meshes The mesh to target.
  49036. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49037. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49038. */
  49039. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49040. /**
  49041. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49042. * @param minimumWorld Determines the smaller position of the bounding box extend
  49043. * @param maximumWorld Determines the bigger position of the bounding box extend
  49044. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49045. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49046. */
  49047. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49048. /**
  49049. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49050. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49051. * frustum width.
  49052. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49053. * to fully enclose the mesh in the viewing frustum.
  49054. */
  49055. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49056. /**
  49057. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49058. * is automatically returned to its default position (expected to be above ground plane).
  49059. */
  49060. private _maintainCameraAboveGround;
  49061. /**
  49062. * Returns the frustum slope based on the canvas ratio and camera FOV
  49063. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49064. */
  49065. private _getFrustumSlope;
  49066. /**
  49067. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49068. */
  49069. private _clearAnimationLocks;
  49070. /**
  49071. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49072. */
  49073. private _applyUserInteraction;
  49074. /**
  49075. * Stops and removes all animations that have been applied to the camera
  49076. */
  49077. stopAllAnimations(): void;
  49078. /**
  49079. * Gets a value indicating if the user is moving the camera
  49080. */
  49081. get isUserIsMoving(): boolean;
  49082. /**
  49083. * The camera can move all the way towards the mesh.
  49084. */
  49085. static IgnoreBoundsSizeMode: number;
  49086. /**
  49087. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49088. */
  49089. static FitFrustumSidesMode: number;
  49090. }
  49091. }
  49092. declare module BABYLON {
  49093. /**
  49094. * Base class for Camera Pointer Inputs.
  49095. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49096. * for example usage.
  49097. */
  49098. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49099. /**
  49100. * Defines the camera the input is attached to.
  49101. */
  49102. abstract camera: Camera;
  49103. /**
  49104. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49105. */
  49106. protected _altKey: boolean;
  49107. protected _ctrlKey: boolean;
  49108. protected _metaKey: boolean;
  49109. protected _shiftKey: boolean;
  49110. /**
  49111. * Which mouse buttons were pressed at time of last mouse event.
  49112. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49113. */
  49114. protected _buttonsPressed: number;
  49115. /**
  49116. * Defines the buttons associated with the input to handle camera move.
  49117. */
  49118. buttons: number[];
  49119. /**
  49120. * Attach the input controls to a specific dom element to get the input from.
  49121. * @param element Defines the element the controls should be listened from
  49122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49123. */
  49124. attachControl(noPreventDefault?: boolean): void;
  49125. /**
  49126. * Detach the current controls from the specified dom element.
  49127. */
  49128. detachControl(): void;
  49129. /**
  49130. * Gets the class name of the current input.
  49131. * @returns the class name
  49132. */
  49133. getClassName(): string;
  49134. /**
  49135. * Get the friendly name associated with the input class.
  49136. * @returns the input friendly name
  49137. */
  49138. getSimpleName(): string;
  49139. /**
  49140. * Called on pointer POINTERDOUBLETAP event.
  49141. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49142. */
  49143. protected onDoubleTap(type: string): void;
  49144. /**
  49145. * Called on pointer POINTERMOVE event if only a single touch is active.
  49146. * Override this method to provide functionality.
  49147. */
  49148. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49149. /**
  49150. * Called on pointer POINTERMOVE event if multiple touches are active.
  49151. * Override this method to provide functionality.
  49152. */
  49153. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49154. /**
  49155. * Called on JS contextmenu event.
  49156. * Override this method to provide functionality.
  49157. */
  49158. protected onContextMenu(evt: PointerEvent): void;
  49159. /**
  49160. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49161. * press.
  49162. * Override this method to provide functionality.
  49163. */
  49164. protected onButtonDown(evt: PointerEvent): void;
  49165. /**
  49166. * Called each time a new POINTERUP event occurs. Ie, for each button
  49167. * release.
  49168. * Override this method to provide functionality.
  49169. */
  49170. protected onButtonUp(evt: PointerEvent): void;
  49171. /**
  49172. * Called when window becomes inactive.
  49173. * Override this method to provide functionality.
  49174. */
  49175. protected onLostFocus(): void;
  49176. private _pointerInput;
  49177. private _observer;
  49178. private _onLostFocus;
  49179. private pointA;
  49180. private pointB;
  49181. }
  49182. }
  49183. declare module BABYLON {
  49184. /**
  49185. * Manage the pointers inputs to control an arc rotate camera.
  49186. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49187. */
  49188. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49189. /**
  49190. * Defines the camera the input is attached to.
  49191. */
  49192. camera: ArcRotateCamera;
  49193. /**
  49194. * Gets the class name of the current input.
  49195. * @returns the class name
  49196. */
  49197. getClassName(): string;
  49198. /**
  49199. * Defines the buttons associated with the input to handle camera move.
  49200. */
  49201. buttons: number[];
  49202. /**
  49203. * Defines the pointer angular sensibility along the X axis or how fast is
  49204. * the camera rotating.
  49205. */
  49206. angularSensibilityX: number;
  49207. /**
  49208. * Defines the pointer angular sensibility along the Y axis or how fast is
  49209. * the camera rotating.
  49210. */
  49211. angularSensibilityY: number;
  49212. /**
  49213. * Defines the pointer pinch precision or how fast is the camera zooming.
  49214. */
  49215. pinchPrecision: number;
  49216. /**
  49217. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49218. * from 0.
  49219. * It defines the percentage of current camera.radius to use as delta when
  49220. * pinch zoom is used.
  49221. */
  49222. pinchDeltaPercentage: number;
  49223. /**
  49224. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49225. * that any object in the plane at the camera's target point will scale
  49226. * perfectly with finger motion.
  49227. * Overrides pinchDeltaPercentage and pinchPrecision.
  49228. */
  49229. useNaturalPinchZoom: boolean;
  49230. /**
  49231. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49232. */
  49233. pinchZoom: boolean;
  49234. /**
  49235. * Defines the pointer panning sensibility or how fast is the camera moving.
  49236. */
  49237. panningSensibility: number;
  49238. /**
  49239. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49240. */
  49241. multiTouchPanning: boolean;
  49242. /**
  49243. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49244. * zoom (pinch) through multitouch.
  49245. */
  49246. multiTouchPanAndZoom: boolean;
  49247. /**
  49248. * Revers pinch action direction.
  49249. */
  49250. pinchInwards: boolean;
  49251. private _isPanClick;
  49252. private _twoFingerActivityCount;
  49253. private _isPinching;
  49254. /**
  49255. * Move camera from multi touch panning positions.
  49256. */
  49257. private _computeMultiTouchPanning;
  49258. /**
  49259. * Move camera from pinch zoom distances.
  49260. */
  49261. private _computePinchZoom;
  49262. /**
  49263. * Called on pointer POINTERMOVE event if only a single touch is active.
  49264. */
  49265. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49266. /**
  49267. * Called on pointer POINTERDOUBLETAP event.
  49268. */
  49269. protected onDoubleTap(type: string): void;
  49270. /**
  49271. * Called on pointer POINTERMOVE event if multiple touches are active.
  49272. */
  49273. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49274. /**
  49275. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49276. * press.
  49277. */
  49278. protected onButtonDown(evt: PointerEvent): void;
  49279. /**
  49280. * Called each time a new POINTERUP event occurs. Ie, for each button
  49281. * release.
  49282. */
  49283. protected onButtonUp(evt: PointerEvent): void;
  49284. /**
  49285. * Called when window becomes inactive.
  49286. */
  49287. protected onLostFocus(): void;
  49288. }
  49289. }
  49290. declare module BABYLON {
  49291. /**
  49292. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49293. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49294. */
  49295. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49296. /**
  49297. * Defines the camera the input is attached to.
  49298. */
  49299. camera: ArcRotateCamera;
  49300. /**
  49301. * Defines the list of key codes associated with the up action (increase alpha)
  49302. */
  49303. keysUp: number[];
  49304. /**
  49305. * Defines the list of key codes associated with the down action (decrease alpha)
  49306. */
  49307. keysDown: number[];
  49308. /**
  49309. * Defines the list of key codes associated with the left action (increase beta)
  49310. */
  49311. keysLeft: number[];
  49312. /**
  49313. * Defines the list of key codes associated with the right action (decrease beta)
  49314. */
  49315. keysRight: number[];
  49316. /**
  49317. * Defines the list of key codes associated with the reset action.
  49318. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49319. */
  49320. keysReset: number[];
  49321. /**
  49322. * Defines the panning sensibility of the inputs.
  49323. * (How fast is the camera panning)
  49324. */
  49325. panningSensibility: number;
  49326. /**
  49327. * Defines the zooming sensibility of the inputs.
  49328. * (How fast is the camera zooming)
  49329. */
  49330. zoomingSensibility: number;
  49331. /**
  49332. * Defines whether maintaining the alt key down switch the movement mode from
  49333. * orientation to zoom.
  49334. */
  49335. useAltToZoom: boolean;
  49336. /**
  49337. * Rotation speed of the camera
  49338. */
  49339. angularSpeed: number;
  49340. private _keys;
  49341. private _ctrlPressed;
  49342. private _altPressed;
  49343. private _onCanvasBlurObserver;
  49344. private _onKeyboardObserver;
  49345. private _engine;
  49346. private _scene;
  49347. /**
  49348. * Attach the input controls to a specific dom element to get the input from.
  49349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49350. */
  49351. attachControl(noPreventDefault?: boolean): void;
  49352. /**
  49353. * Detach the current controls from the specified dom element.
  49354. */
  49355. detachControl(): void;
  49356. /**
  49357. * Update the current camera state depending on the inputs that have been used this frame.
  49358. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49359. */
  49360. checkInputs(): void;
  49361. /**
  49362. * Gets the class name of the current intput.
  49363. * @returns the class name
  49364. */
  49365. getClassName(): string;
  49366. /**
  49367. * Get the friendly name associated with the input class.
  49368. * @returns the input friendly name
  49369. */
  49370. getSimpleName(): string;
  49371. }
  49372. }
  49373. declare module BABYLON {
  49374. /**
  49375. * Manage the mouse wheel inputs to control an arc rotate camera.
  49376. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49377. */
  49378. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49379. /**
  49380. * Defines the camera the input is attached to.
  49381. */
  49382. camera: ArcRotateCamera;
  49383. /**
  49384. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49385. */
  49386. wheelPrecision: number;
  49387. /**
  49388. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49389. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49390. */
  49391. wheelDeltaPercentage: number;
  49392. private _wheel;
  49393. private _observer;
  49394. private computeDeltaFromMouseWheelLegacyEvent;
  49395. /**
  49396. * Attach the input controls to a specific dom element to get the input from.
  49397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49398. */
  49399. attachControl(noPreventDefault?: boolean): void;
  49400. /**
  49401. * Detach the current controls from the specified dom element.
  49402. */
  49403. detachControl(): void;
  49404. /**
  49405. * Gets the class name of the current intput.
  49406. * @returns the class name
  49407. */
  49408. getClassName(): string;
  49409. /**
  49410. * Get the friendly name associated with the input class.
  49411. * @returns the input friendly name
  49412. */
  49413. getSimpleName(): string;
  49414. }
  49415. }
  49416. declare module BABYLON {
  49417. /**
  49418. * Default Inputs manager for the ArcRotateCamera.
  49419. * It groups all the default supported inputs for ease of use.
  49420. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49421. */
  49422. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49423. /**
  49424. * Instantiates a new ArcRotateCameraInputsManager.
  49425. * @param camera Defines the camera the inputs belong to
  49426. */
  49427. constructor(camera: ArcRotateCamera);
  49428. /**
  49429. * Add mouse wheel input support to the input manager.
  49430. * @returns the current input manager
  49431. */
  49432. addMouseWheel(): ArcRotateCameraInputsManager;
  49433. /**
  49434. * Add pointers input support to the input manager.
  49435. * @returns the current input manager
  49436. */
  49437. addPointers(): ArcRotateCameraInputsManager;
  49438. /**
  49439. * Add keyboard input support to the input manager.
  49440. * @returns the current input manager
  49441. */
  49442. addKeyboard(): ArcRotateCameraInputsManager;
  49443. }
  49444. }
  49445. declare module BABYLON {
  49446. /**
  49447. * This represents an orbital type of camera.
  49448. *
  49449. * 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.
  49450. * 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.
  49451. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49452. */
  49453. export class ArcRotateCamera extends TargetCamera {
  49454. /**
  49455. * Defines the rotation angle of the camera along the longitudinal axis.
  49456. */
  49457. alpha: number;
  49458. /**
  49459. * Defines the rotation angle of the camera along the latitudinal axis.
  49460. */
  49461. beta: number;
  49462. /**
  49463. * Defines the radius of the camera from it s target point.
  49464. */
  49465. radius: number;
  49466. protected _target: Vector3;
  49467. protected _targetHost: Nullable<AbstractMesh>;
  49468. /**
  49469. * Defines the target point of the camera.
  49470. * The camera looks towards it form the radius distance.
  49471. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49472. */
  49473. get target(): Vector3;
  49474. set target(value: Vector3);
  49475. /**
  49476. * Define the current local position of the camera in the scene
  49477. */
  49478. get position(): Vector3;
  49479. set position(newPosition: Vector3);
  49480. protected _upToYMatrix: Matrix;
  49481. protected _YToUpMatrix: Matrix;
  49482. /**
  49483. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49484. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49485. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49486. */
  49487. set upVector(vec: Vector3);
  49488. get upVector(): Vector3;
  49489. /**
  49490. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49491. */
  49492. setMatUp(): void;
  49493. /**
  49494. * Current inertia value on the longitudinal axis.
  49495. * The bigger this number the longer it will take for the camera to stop.
  49496. */
  49497. inertialAlphaOffset: number;
  49498. /**
  49499. * Current inertia value on the latitudinal axis.
  49500. * The bigger this number the longer it will take for the camera to stop.
  49501. */
  49502. inertialBetaOffset: number;
  49503. /**
  49504. * Current inertia value on the radius axis.
  49505. * The bigger this number the longer it will take for the camera to stop.
  49506. */
  49507. inertialRadiusOffset: number;
  49508. /**
  49509. * Minimum allowed angle on the longitudinal axis.
  49510. * This can help limiting how the Camera is able to move in the scene.
  49511. */
  49512. lowerAlphaLimit: Nullable<number>;
  49513. /**
  49514. * Maximum allowed angle on the longitudinal axis.
  49515. * This can help limiting how the Camera is able to move in the scene.
  49516. */
  49517. upperAlphaLimit: Nullable<number>;
  49518. /**
  49519. * Minimum allowed angle on the latitudinal axis.
  49520. * This can help limiting how the Camera is able to move in the scene.
  49521. */
  49522. lowerBetaLimit: number;
  49523. /**
  49524. * Maximum allowed angle on the latitudinal axis.
  49525. * This can help limiting how the Camera is able to move in the scene.
  49526. */
  49527. upperBetaLimit: number;
  49528. /**
  49529. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49530. * This can help limiting how the Camera is able to move in the scene.
  49531. */
  49532. lowerRadiusLimit: Nullable<number>;
  49533. /**
  49534. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49535. * This can help limiting how the Camera is able to move in the scene.
  49536. */
  49537. upperRadiusLimit: Nullable<number>;
  49538. /**
  49539. * Defines the current inertia value used during panning of the camera along the X axis.
  49540. */
  49541. inertialPanningX: number;
  49542. /**
  49543. * Defines the current inertia value used during panning of the camera along the Y axis.
  49544. */
  49545. inertialPanningY: number;
  49546. /**
  49547. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49548. * Basically if your fingers moves away from more than this distance you will be considered
  49549. * in pinch mode.
  49550. */
  49551. pinchToPanMaxDistance: number;
  49552. /**
  49553. * Defines the maximum distance the camera can pan.
  49554. * This could help keeping the cammera always in your scene.
  49555. */
  49556. panningDistanceLimit: Nullable<number>;
  49557. /**
  49558. * Defines the target of the camera before paning.
  49559. */
  49560. panningOriginTarget: Vector3;
  49561. /**
  49562. * Defines the value of the inertia used during panning.
  49563. * 0 would mean stop inertia and one would mean no decelleration at all.
  49564. */
  49565. panningInertia: number;
  49566. /**
  49567. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49568. */
  49569. get angularSensibilityX(): number;
  49570. set angularSensibilityX(value: number);
  49571. /**
  49572. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49573. */
  49574. get angularSensibilityY(): number;
  49575. set angularSensibilityY(value: number);
  49576. /**
  49577. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49578. */
  49579. get pinchPrecision(): number;
  49580. set pinchPrecision(value: number);
  49581. /**
  49582. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49583. * It will be used instead of pinchDeltaPrecision if different from 0.
  49584. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49585. */
  49586. get pinchDeltaPercentage(): number;
  49587. set pinchDeltaPercentage(value: number);
  49588. /**
  49589. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49590. * and pinch delta percentage.
  49591. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49592. * that any object in the plane at the camera's target point will scale
  49593. * perfectly with finger motion.
  49594. */
  49595. get useNaturalPinchZoom(): boolean;
  49596. set useNaturalPinchZoom(value: boolean);
  49597. /**
  49598. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49599. */
  49600. get panningSensibility(): number;
  49601. set panningSensibility(value: number);
  49602. /**
  49603. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49604. */
  49605. get keysUp(): number[];
  49606. set keysUp(value: number[]);
  49607. /**
  49608. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49609. */
  49610. get keysDown(): number[];
  49611. set keysDown(value: number[]);
  49612. /**
  49613. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49614. */
  49615. get keysLeft(): number[];
  49616. set keysLeft(value: number[]);
  49617. /**
  49618. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49619. */
  49620. get keysRight(): number[];
  49621. set keysRight(value: number[]);
  49622. /**
  49623. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49624. */
  49625. get wheelPrecision(): number;
  49626. set wheelPrecision(value: number);
  49627. /**
  49628. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49629. * It will be used instead of pinchDeltaPrecision if different from 0.
  49630. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49631. */
  49632. get wheelDeltaPercentage(): number;
  49633. set wheelDeltaPercentage(value: number);
  49634. /**
  49635. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  49636. */
  49637. zoomOnFactor: number;
  49638. /**
  49639. * Defines a screen offset for the camera position.
  49640. */
  49641. targetScreenOffset: Vector2;
  49642. /**
  49643. * Allows the camera to be completely reversed.
  49644. * If false the camera can not arrive upside down.
  49645. */
  49646. allowUpsideDown: boolean;
  49647. /**
  49648. * Define if double tap/click is used to restore the previously saved state of the camera.
  49649. */
  49650. useInputToRestoreState: boolean;
  49651. /** @hidden */
  49652. _viewMatrix: Matrix;
  49653. /** @hidden */
  49654. _useCtrlForPanning: boolean;
  49655. /** @hidden */
  49656. _panningMouseButton: number;
  49657. /**
  49658. * Defines the input associated to the camera.
  49659. */
  49660. inputs: ArcRotateCameraInputsManager;
  49661. /** @hidden */
  49662. _reset: () => void;
  49663. /**
  49664. * Defines the allowed panning axis.
  49665. */
  49666. panningAxis: Vector3;
  49667. protected _transformedDirection: Vector3;
  49668. private _bouncingBehavior;
  49669. /**
  49670. * Gets the bouncing behavior of the camera if it has been enabled.
  49671. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49672. */
  49673. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49674. /**
  49675. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49676. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49677. */
  49678. get useBouncingBehavior(): boolean;
  49679. set useBouncingBehavior(value: boolean);
  49680. private _framingBehavior;
  49681. /**
  49682. * Gets the framing behavior of the camera if it has been enabled.
  49683. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49684. */
  49685. get framingBehavior(): Nullable<FramingBehavior>;
  49686. /**
  49687. * Defines if the framing behavior of the camera is enabled on the camera.
  49688. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49689. */
  49690. get useFramingBehavior(): boolean;
  49691. set useFramingBehavior(value: boolean);
  49692. private _autoRotationBehavior;
  49693. /**
  49694. * Gets the auto rotation behavior of the camera if it has been enabled.
  49695. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49696. */
  49697. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49698. /**
  49699. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49700. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49701. */
  49702. get useAutoRotationBehavior(): boolean;
  49703. set useAutoRotationBehavior(value: boolean);
  49704. /**
  49705. * Observable triggered when the mesh target has been changed on the camera.
  49706. */
  49707. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49708. /**
  49709. * Event raised when the camera is colliding with a mesh.
  49710. */
  49711. onCollide: (collidedMesh: AbstractMesh) => void;
  49712. /**
  49713. * Defines whether the camera should check collision with the objects oh the scene.
  49714. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49715. */
  49716. checkCollisions: boolean;
  49717. /**
  49718. * Defines the collision radius of the camera.
  49719. * This simulates a sphere around the camera.
  49720. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49721. */
  49722. collisionRadius: Vector3;
  49723. protected _collider: Collider;
  49724. protected _previousPosition: Vector3;
  49725. protected _collisionVelocity: Vector3;
  49726. protected _newPosition: Vector3;
  49727. protected _previousAlpha: number;
  49728. protected _previousBeta: number;
  49729. protected _previousRadius: number;
  49730. protected _collisionTriggered: boolean;
  49731. protected _targetBoundingCenter: Nullable<Vector3>;
  49732. private _computationVector;
  49733. /**
  49734. * Instantiates a new ArcRotateCamera in a given scene
  49735. * @param name Defines the name of the camera
  49736. * @param alpha Defines the camera rotation along the logitudinal axis
  49737. * @param beta Defines the camera rotation along the latitudinal axis
  49738. * @param radius Defines the camera distance from its target
  49739. * @param target Defines the camera target
  49740. * @param scene Defines the scene the camera belongs to
  49741. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  49742. */
  49743. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49744. /** @hidden */
  49745. _initCache(): void;
  49746. /** @hidden */
  49747. _updateCache(ignoreParentClass?: boolean): void;
  49748. protected _getTargetPosition(): Vector3;
  49749. private _storedAlpha;
  49750. private _storedBeta;
  49751. private _storedRadius;
  49752. private _storedTarget;
  49753. private _storedTargetScreenOffset;
  49754. /**
  49755. * Stores the current state of the camera (alpha, beta, radius and target)
  49756. * @returns the camera itself
  49757. */
  49758. storeState(): Camera;
  49759. /**
  49760. * @hidden
  49761. * Restored camera state. You must call storeState() first
  49762. */
  49763. _restoreStateValues(): boolean;
  49764. /** @hidden */
  49765. _isSynchronizedViewMatrix(): boolean;
  49766. /**
  49767. * Attach the input controls to a specific dom element to get the input from.
  49768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49769. */
  49770. attachControl(noPreventDefault?: boolean): void;
  49771. /**
  49772. * Attach the input controls to a specific dom element to get the input from.
  49773. * @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
  49774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49775. */
  49776. attachControl(ignored: any, noPreventDefault?: boolean): void;
  49777. /**
  49778. * Attached controls to the current camera.
  49779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49780. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49781. */
  49782. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49783. /**
  49784. * Attached controls to the current camera.
  49785. * @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
  49786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49787. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49788. */
  49789. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49790. /**
  49791. * Attached controls to the current camera.
  49792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49793. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49794. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  49795. */
  49796. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  49797. /**
  49798. * Detach the current controls from the specified dom element.
  49799. */
  49800. detachControl(): void;
  49801. /**
  49802. * Detach the current controls from the specified dom element.
  49803. * @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
  49804. */
  49805. detachControl(ignored: any): void;
  49806. /** @hidden */
  49807. _checkInputs(): void;
  49808. protected _checkLimits(): void;
  49809. /**
  49810. * Rebuilds angles (alpha, beta) and radius from the give position and target
  49811. */
  49812. rebuildAnglesAndRadius(): void;
  49813. /**
  49814. * Use a position to define the current camera related information like alpha, beta and radius
  49815. * @param position Defines the position to set the camera at
  49816. */
  49817. setPosition(position: Vector3): void;
  49818. /**
  49819. * Defines the target the camera should look at.
  49820. * This will automatically adapt alpha beta and radius to fit within the new target.
  49821. * @param target Defines the new target as a Vector or a mesh
  49822. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  49823. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  49824. */
  49825. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  49826. /** @hidden */
  49827. _getViewMatrix(): Matrix;
  49828. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  49829. /**
  49830. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  49831. * @param meshes Defines the mesh to zoom on
  49832. * @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)
  49833. */
  49834. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  49835. /**
  49836. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  49837. * The target will be changed but the radius
  49838. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  49839. * @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)
  49840. */
  49841. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  49842. min: Vector3;
  49843. max: Vector3;
  49844. distance: number;
  49845. }, doNotUpdateMaxZ?: boolean): void;
  49846. /**
  49847. * @override
  49848. * Override Camera.createRigCamera
  49849. */
  49850. createRigCamera(name: string, cameraIndex: number): Camera;
  49851. /**
  49852. * @hidden
  49853. * @override
  49854. * Override Camera._updateRigCameras
  49855. */
  49856. _updateRigCameras(): void;
  49857. /**
  49858. * Destroy the camera and release the current resources hold by it.
  49859. */
  49860. dispose(): void;
  49861. /**
  49862. * Gets the current object class name.
  49863. * @return the class name
  49864. */
  49865. getClassName(): string;
  49866. }
  49867. }
  49868. declare module BABYLON {
  49869. /**
  49870. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  49871. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49872. */
  49873. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  49874. /**
  49875. * Gets the name of the behavior.
  49876. */
  49877. get name(): string;
  49878. private _zoomStopsAnimation;
  49879. private _idleRotationSpeed;
  49880. private _idleRotationWaitTime;
  49881. private _idleRotationSpinupTime;
  49882. /**
  49883. * Sets the flag that indicates if user zooming should stop animation.
  49884. */
  49885. set zoomStopsAnimation(flag: boolean);
  49886. /**
  49887. * Gets the flag that indicates if user zooming should stop animation.
  49888. */
  49889. get zoomStopsAnimation(): boolean;
  49890. /**
  49891. * Sets the default speed at which the camera rotates around the model.
  49892. */
  49893. set idleRotationSpeed(speed: number);
  49894. /**
  49895. * Gets the default speed at which the camera rotates around the model.
  49896. */
  49897. get idleRotationSpeed(): number;
  49898. /**
  49899. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  49900. */
  49901. set idleRotationWaitTime(time: number);
  49902. /**
  49903. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  49904. */
  49905. get idleRotationWaitTime(): number;
  49906. /**
  49907. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49908. */
  49909. set idleRotationSpinupTime(time: number);
  49910. /**
  49911. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49912. */
  49913. get idleRotationSpinupTime(): number;
  49914. /**
  49915. * Gets a value indicating if the camera is currently rotating because of this behavior
  49916. */
  49917. get rotationInProgress(): boolean;
  49918. private _onPrePointerObservableObserver;
  49919. private _onAfterCheckInputsObserver;
  49920. private _attachedCamera;
  49921. private _isPointerDown;
  49922. private _lastFrameTime;
  49923. private _lastInteractionTime;
  49924. private _cameraRotationSpeed;
  49925. /**
  49926. * Initializes the behavior.
  49927. */
  49928. init(): void;
  49929. /**
  49930. * Attaches the behavior to its arc rotate camera.
  49931. * @param camera Defines the camera to attach the behavior to
  49932. */
  49933. attach(camera: ArcRotateCamera): void;
  49934. /**
  49935. * Detaches the behavior from its current arc rotate camera.
  49936. */
  49937. detach(): void;
  49938. /**
  49939. * Returns true if user is scrolling.
  49940. * @return true if user is scrolling.
  49941. */
  49942. private _userIsZooming;
  49943. private _lastFrameRadius;
  49944. private _shouldAnimationStopForInteraction;
  49945. /**
  49946. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49947. */
  49948. private _applyUserInteraction;
  49949. private _userIsMoving;
  49950. }
  49951. }
  49952. declare module BABYLON {
  49953. /**
  49954. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  49955. */
  49956. export class AttachToBoxBehavior implements Behavior<Mesh> {
  49957. private ui;
  49958. /**
  49959. * The name of the behavior
  49960. */
  49961. name: string;
  49962. /**
  49963. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  49964. */
  49965. distanceAwayFromFace: number;
  49966. /**
  49967. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  49968. */
  49969. distanceAwayFromBottomOfFace: number;
  49970. private _faceVectors;
  49971. private _target;
  49972. private _scene;
  49973. private _onRenderObserver;
  49974. private _tmpMatrix;
  49975. private _tmpVector;
  49976. /**
  49977. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  49978. * @param ui The transform node that should be attched to the mesh
  49979. */
  49980. constructor(ui: TransformNode);
  49981. /**
  49982. * Initializes the behavior
  49983. */
  49984. init(): void;
  49985. private _closestFace;
  49986. private _zeroVector;
  49987. private _lookAtTmpMatrix;
  49988. private _lookAtToRef;
  49989. /**
  49990. * Attaches the AttachToBoxBehavior to the passed in mesh
  49991. * @param target The mesh that the specified node will be attached to
  49992. */
  49993. attach(target: Mesh): void;
  49994. /**
  49995. * Detaches the behavior from the mesh
  49996. */
  49997. detach(): void;
  49998. }
  49999. }
  50000. declare module BABYLON {
  50001. /**
  50002. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  50003. */
  50004. export class FadeInOutBehavior implements Behavior<Mesh> {
  50005. /**
  50006. * Time in milliseconds to delay before fading in (Default: 0)
  50007. */
  50008. delay: number;
  50009. /**
  50010. * Time in milliseconds for the mesh to fade in (Default: 300)
  50011. */
  50012. fadeInTime: number;
  50013. private _millisecondsPerFrame;
  50014. private _hovered;
  50015. private _hoverValue;
  50016. private _ownerNode;
  50017. /**
  50018. * Instatiates the FadeInOutBehavior
  50019. */
  50020. constructor();
  50021. /**
  50022. * The name of the behavior
  50023. */
  50024. get name(): string;
  50025. /**
  50026. * Initializes the behavior
  50027. */
  50028. init(): void;
  50029. /**
  50030. * Attaches the fade behavior on the passed in mesh
  50031. * @param ownerNode The mesh that will be faded in/out once attached
  50032. */
  50033. attach(ownerNode: Mesh): void;
  50034. /**
  50035. * Detaches the behavior from the mesh
  50036. */
  50037. detach(): void;
  50038. /**
  50039. * Triggers the mesh to begin fading in or out
  50040. * @param value if the object should fade in or out (true to fade in)
  50041. */
  50042. fadeIn(value: boolean): void;
  50043. private _update;
  50044. private _setAllVisibility;
  50045. }
  50046. }
  50047. declare module BABYLON {
  50048. /**
  50049. * Class containing a set of static utilities functions for managing Pivots
  50050. * @hidden
  50051. */
  50052. export class PivotTools {
  50053. private static _PivotCached;
  50054. private static _OldPivotPoint;
  50055. private static _PivotTranslation;
  50056. private static _PivotTmpVector;
  50057. private static _PivotPostMultiplyPivotMatrix;
  50058. /** @hidden */
  50059. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50060. /** @hidden */
  50061. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50062. }
  50063. }
  50064. declare module BABYLON {
  50065. /**
  50066. * Class containing static functions to help procedurally build meshes
  50067. */
  50068. export class PlaneBuilder {
  50069. /**
  50070. * Creates a plane mesh
  50071. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50072. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50073. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50075. * * 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
  50076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50077. * @param name defines the name of the mesh
  50078. * @param options defines the options used to create the mesh
  50079. * @param scene defines the hosting scene
  50080. * @returns the plane mesh
  50081. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50082. */
  50083. static CreatePlane(name: string, options: {
  50084. size?: number;
  50085. width?: number;
  50086. height?: number;
  50087. sideOrientation?: number;
  50088. frontUVs?: Vector4;
  50089. backUVs?: Vector4;
  50090. updatable?: boolean;
  50091. sourcePlane?: Plane;
  50092. }, scene?: Nullable<Scene>): Mesh;
  50093. }
  50094. }
  50095. declare module BABYLON {
  50096. /**
  50097. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50098. */
  50099. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50100. private static _AnyMouseID;
  50101. /**
  50102. * Abstract mesh the behavior is set on
  50103. */
  50104. attachedNode: AbstractMesh;
  50105. private _dragPlane;
  50106. private _scene;
  50107. private _pointerObserver;
  50108. private _beforeRenderObserver;
  50109. private static _planeScene;
  50110. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50111. /**
  50112. * 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)
  50113. */
  50114. maxDragAngle: number;
  50115. /**
  50116. * @hidden
  50117. */
  50118. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50119. /**
  50120. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50121. */
  50122. currentDraggingPointerID: number;
  50123. /**
  50124. * The last position where the pointer hit the drag plane in world space
  50125. */
  50126. lastDragPosition: Vector3;
  50127. /**
  50128. * If the behavior is currently in a dragging state
  50129. */
  50130. dragging: boolean;
  50131. /**
  50132. * 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)
  50133. */
  50134. dragDeltaRatio: number;
  50135. /**
  50136. * If the drag plane orientation should be updated during the dragging (Default: true)
  50137. */
  50138. updateDragPlane: boolean;
  50139. private _debugMode;
  50140. private _moving;
  50141. /**
  50142. * Fires each time the attached mesh is dragged with the pointer
  50143. * * delta between last drag position and current drag position in world space
  50144. * * dragDistance along the drag axis
  50145. * * dragPlaneNormal normal of the current drag plane used during the drag
  50146. * * dragPlanePoint in world space where the drag intersects the drag plane
  50147. */
  50148. onDragObservable: Observable<{
  50149. delta: Vector3;
  50150. dragPlanePoint: Vector3;
  50151. dragPlaneNormal: Vector3;
  50152. dragDistance: number;
  50153. pointerId: number;
  50154. }>;
  50155. /**
  50156. * Fires each time a drag begins (eg. mouse down on mesh)
  50157. */
  50158. onDragStartObservable: Observable<{
  50159. dragPlanePoint: Vector3;
  50160. pointerId: number;
  50161. }>;
  50162. /**
  50163. * Fires each time a drag ends (eg. mouse release after drag)
  50164. */
  50165. onDragEndObservable: Observable<{
  50166. dragPlanePoint: Vector3;
  50167. pointerId: number;
  50168. }>;
  50169. /**
  50170. * If the attached mesh should be moved when dragged
  50171. */
  50172. moveAttached: boolean;
  50173. /**
  50174. * If the drag behavior will react to drag events (Default: true)
  50175. */
  50176. enabled: boolean;
  50177. /**
  50178. * If pointer events should start and release the drag (Default: true)
  50179. */
  50180. startAndReleaseDragOnPointerEvents: boolean;
  50181. /**
  50182. * If camera controls should be detached during the drag
  50183. */
  50184. detachCameraControls: boolean;
  50185. /**
  50186. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50187. */
  50188. useObjectOrientationForDragging: boolean;
  50189. private _options;
  50190. /**
  50191. * Gets the options used by the behavior
  50192. */
  50193. get options(): {
  50194. dragAxis?: Vector3;
  50195. dragPlaneNormal?: Vector3;
  50196. };
  50197. /**
  50198. * Sets the options used by the behavior
  50199. */
  50200. set options(options: {
  50201. dragAxis?: Vector3;
  50202. dragPlaneNormal?: Vector3;
  50203. });
  50204. /**
  50205. * Creates a pointer drag behavior that can be attached to a mesh
  50206. * @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)
  50207. */
  50208. constructor(options?: {
  50209. dragAxis?: Vector3;
  50210. dragPlaneNormal?: Vector3;
  50211. });
  50212. /**
  50213. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50214. */
  50215. validateDrag: (targetPosition: Vector3) => boolean;
  50216. /**
  50217. * The name of the behavior
  50218. */
  50219. get name(): string;
  50220. /**
  50221. * Initializes the behavior
  50222. */
  50223. init(): void;
  50224. private _tmpVector;
  50225. private _alternatePickedPoint;
  50226. private _worldDragAxis;
  50227. private _targetPosition;
  50228. private _attachedToElement;
  50229. /**
  50230. * Attaches the drag behavior the passed in mesh
  50231. * @param ownerNode The mesh that will be dragged around once attached
  50232. * @param predicate Predicate to use for pick filtering
  50233. */
  50234. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50235. /**
  50236. * Force relase the drag action by code.
  50237. */
  50238. releaseDrag(): void;
  50239. private _startDragRay;
  50240. private _lastPointerRay;
  50241. /**
  50242. * Simulates the start of a pointer drag event on the behavior
  50243. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50244. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50245. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50246. */
  50247. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50248. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50249. private _dragDelta;
  50250. protected _moveDrag(ray: Ray): void;
  50251. private _pickWithRayOnDragPlane;
  50252. private _pointA;
  50253. private _pointC;
  50254. private _localAxis;
  50255. private _lookAt;
  50256. private _updateDragPlanePosition;
  50257. /**
  50258. * Detaches the behavior from the mesh
  50259. */
  50260. detach(): void;
  50261. }
  50262. }
  50263. declare module BABYLON {
  50264. /**
  50265. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50266. */
  50267. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50268. private _dragBehaviorA;
  50269. private _dragBehaviorB;
  50270. private _startDistance;
  50271. private _initialScale;
  50272. private _targetScale;
  50273. private _ownerNode;
  50274. private _sceneRenderObserver;
  50275. /**
  50276. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50277. */
  50278. constructor();
  50279. /**
  50280. * The name of the behavior
  50281. */
  50282. get name(): string;
  50283. /**
  50284. * Initializes the behavior
  50285. */
  50286. init(): void;
  50287. private _getCurrentDistance;
  50288. /**
  50289. * Attaches the scale behavior the passed in mesh
  50290. * @param ownerNode The mesh that will be scaled around once attached
  50291. */
  50292. attach(ownerNode: Mesh): void;
  50293. /**
  50294. * Detaches the behavior from the mesh
  50295. */
  50296. detach(): void;
  50297. }
  50298. }
  50299. declare module BABYLON {
  50300. /**
  50301. * 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
  50302. */
  50303. export class SixDofDragBehavior implements Behavior<Mesh> {
  50304. private static _virtualScene;
  50305. private _ownerNode;
  50306. private _sceneRenderObserver;
  50307. private _scene;
  50308. private _targetPosition;
  50309. private _virtualOriginMesh;
  50310. private _virtualDragMesh;
  50311. private _pointerObserver;
  50312. private _moving;
  50313. private _startingOrientation;
  50314. private _attachedToElement;
  50315. /**
  50316. * 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)
  50317. */
  50318. private zDragFactor;
  50319. /**
  50320. * If the object should rotate to face the drag origin
  50321. */
  50322. rotateDraggedObject: boolean;
  50323. /**
  50324. * If the behavior is currently in a dragging state
  50325. */
  50326. dragging: boolean;
  50327. /**
  50328. * 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)
  50329. */
  50330. dragDeltaRatio: number;
  50331. /**
  50332. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50333. */
  50334. currentDraggingPointerID: number;
  50335. /**
  50336. * If camera controls should be detached during the drag
  50337. */
  50338. detachCameraControls: boolean;
  50339. /**
  50340. * Fires each time a drag starts
  50341. */
  50342. onDragStartObservable: Observable<{}>;
  50343. /**
  50344. * Fires each time a drag happens
  50345. */
  50346. onDragObservable: Observable<void>;
  50347. /**
  50348. * Fires each time a drag ends (eg. mouse release after drag)
  50349. */
  50350. onDragEndObservable: Observable<{}>;
  50351. /**
  50352. * 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
  50353. */
  50354. constructor();
  50355. /**
  50356. * The name of the behavior
  50357. */
  50358. get name(): string;
  50359. /**
  50360. * Initializes the behavior
  50361. */
  50362. init(): void;
  50363. /**
  50364. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50365. */
  50366. private get _pointerCamera();
  50367. /**
  50368. * Attaches the scale behavior the passed in mesh
  50369. * @param ownerNode The mesh that will be scaled around once attached
  50370. */
  50371. attach(ownerNode: Mesh): void;
  50372. /**
  50373. * Detaches the behavior from the mesh
  50374. */
  50375. detach(): void;
  50376. }
  50377. }
  50378. declare module BABYLON {
  50379. /**
  50380. * Class used to apply inverse kinematics to bones
  50381. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50382. */
  50383. export class BoneIKController {
  50384. private static _tmpVecs;
  50385. private static _tmpQuat;
  50386. private static _tmpMats;
  50387. /**
  50388. * Gets or sets the target mesh
  50389. */
  50390. targetMesh: AbstractMesh;
  50391. /** Gets or sets the mesh used as pole */
  50392. poleTargetMesh: AbstractMesh;
  50393. /**
  50394. * Gets or sets the bone used as pole
  50395. */
  50396. poleTargetBone: Nullable<Bone>;
  50397. /**
  50398. * Gets or sets the target position
  50399. */
  50400. targetPosition: Vector3;
  50401. /**
  50402. * Gets or sets the pole target position
  50403. */
  50404. poleTargetPosition: Vector3;
  50405. /**
  50406. * Gets or sets the pole target local offset
  50407. */
  50408. poleTargetLocalOffset: Vector3;
  50409. /**
  50410. * Gets or sets the pole angle
  50411. */
  50412. poleAngle: number;
  50413. /**
  50414. * Gets or sets the mesh associated with the controller
  50415. */
  50416. mesh: AbstractMesh;
  50417. /**
  50418. * 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)
  50419. */
  50420. slerpAmount: number;
  50421. private _bone1Quat;
  50422. private _bone1Mat;
  50423. private _bone2Ang;
  50424. private _bone1;
  50425. private _bone2;
  50426. private _bone1Length;
  50427. private _bone2Length;
  50428. private _maxAngle;
  50429. private _maxReach;
  50430. private _rightHandedSystem;
  50431. private _bendAxis;
  50432. private _slerping;
  50433. private _adjustRoll;
  50434. /**
  50435. * Gets or sets maximum allowed angle
  50436. */
  50437. get maxAngle(): number;
  50438. set maxAngle(value: number);
  50439. /**
  50440. * Creates a new BoneIKController
  50441. * @param mesh defines the mesh to control
  50442. * @param bone defines the bone to control
  50443. * @param options defines options to set up the controller
  50444. */
  50445. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50446. targetMesh?: AbstractMesh;
  50447. poleTargetMesh?: AbstractMesh;
  50448. poleTargetBone?: Bone;
  50449. poleTargetLocalOffset?: Vector3;
  50450. poleAngle?: number;
  50451. bendAxis?: Vector3;
  50452. maxAngle?: number;
  50453. slerpAmount?: number;
  50454. });
  50455. private _setMaxAngle;
  50456. /**
  50457. * Force the controller to update the bones
  50458. */
  50459. update(): void;
  50460. }
  50461. }
  50462. declare module BABYLON {
  50463. /**
  50464. * Class used to make a bone look toward a point in space
  50465. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50466. */
  50467. export class BoneLookController {
  50468. private static _tmpVecs;
  50469. private static _tmpQuat;
  50470. private static _tmpMats;
  50471. /**
  50472. * The target Vector3 that the bone will look at
  50473. */
  50474. target: Vector3;
  50475. /**
  50476. * The mesh that the bone is attached to
  50477. */
  50478. mesh: AbstractMesh;
  50479. /**
  50480. * The bone that will be looking to the target
  50481. */
  50482. bone: Bone;
  50483. /**
  50484. * The up axis of the coordinate system that is used when the bone is rotated
  50485. */
  50486. upAxis: Vector3;
  50487. /**
  50488. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50489. */
  50490. upAxisSpace: Space;
  50491. /**
  50492. * Used to make an adjustment to the yaw of the bone
  50493. */
  50494. adjustYaw: number;
  50495. /**
  50496. * Used to make an adjustment to the pitch of the bone
  50497. */
  50498. adjustPitch: number;
  50499. /**
  50500. * Used to make an adjustment to the roll of the bone
  50501. */
  50502. adjustRoll: number;
  50503. /**
  50504. * 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)
  50505. */
  50506. slerpAmount: number;
  50507. private _minYaw;
  50508. private _maxYaw;
  50509. private _minPitch;
  50510. private _maxPitch;
  50511. private _minYawSin;
  50512. private _minYawCos;
  50513. private _maxYawSin;
  50514. private _maxYawCos;
  50515. private _midYawConstraint;
  50516. private _minPitchTan;
  50517. private _maxPitchTan;
  50518. private _boneQuat;
  50519. private _slerping;
  50520. private _transformYawPitch;
  50521. private _transformYawPitchInv;
  50522. private _firstFrameSkipped;
  50523. private _yawRange;
  50524. private _fowardAxis;
  50525. /**
  50526. * Gets or sets the minimum yaw angle that the bone can look to
  50527. */
  50528. get minYaw(): number;
  50529. set minYaw(value: number);
  50530. /**
  50531. * Gets or sets the maximum yaw angle that the bone can look to
  50532. */
  50533. get maxYaw(): number;
  50534. set maxYaw(value: number);
  50535. /**
  50536. * Gets or sets the minimum pitch angle that the bone can look to
  50537. */
  50538. get minPitch(): number;
  50539. set minPitch(value: number);
  50540. /**
  50541. * Gets or sets the maximum pitch angle that the bone can look to
  50542. */
  50543. get maxPitch(): number;
  50544. set maxPitch(value: number);
  50545. /**
  50546. * Create a BoneLookController
  50547. * @param mesh the mesh that the bone belongs to
  50548. * @param bone the bone that will be looking to the target
  50549. * @param target the target Vector3 to look at
  50550. * @param options optional settings:
  50551. * * maxYaw: the maximum angle the bone will yaw to
  50552. * * minYaw: the minimum angle the bone will yaw to
  50553. * * maxPitch: the maximum angle the bone will pitch to
  50554. * * minPitch: the minimum angle the bone will yaw to
  50555. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50556. * * upAxis: the up axis of the coordinate system
  50557. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50558. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50559. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50560. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50561. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50562. * * adjustRoll: used to make an adjustment to the roll of the bone
  50563. **/
  50564. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50565. maxYaw?: number;
  50566. minYaw?: number;
  50567. maxPitch?: number;
  50568. minPitch?: number;
  50569. slerpAmount?: number;
  50570. upAxis?: Vector3;
  50571. upAxisSpace?: Space;
  50572. yawAxis?: Vector3;
  50573. pitchAxis?: Vector3;
  50574. adjustYaw?: number;
  50575. adjustPitch?: number;
  50576. adjustRoll?: number;
  50577. });
  50578. /**
  50579. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50580. */
  50581. update(): void;
  50582. private _getAngleDiff;
  50583. private _getAngleBetween;
  50584. private _isAngleBetween;
  50585. }
  50586. }
  50587. declare module BABYLON {
  50588. /**
  50589. * Manage the gamepad inputs to control an arc rotate camera.
  50590. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50591. */
  50592. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50593. /**
  50594. * Defines the camera the input is attached to.
  50595. */
  50596. camera: ArcRotateCamera;
  50597. /**
  50598. * Defines the gamepad the input is gathering event from.
  50599. */
  50600. gamepad: Nullable<Gamepad>;
  50601. /**
  50602. * Defines the gamepad rotation sensiblity.
  50603. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50604. */
  50605. gamepadRotationSensibility: number;
  50606. /**
  50607. * Defines the gamepad move sensiblity.
  50608. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50609. */
  50610. gamepadMoveSensibility: number;
  50611. private _yAxisScale;
  50612. /**
  50613. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50614. */
  50615. get invertYAxis(): boolean;
  50616. set invertYAxis(value: boolean);
  50617. private _onGamepadConnectedObserver;
  50618. private _onGamepadDisconnectedObserver;
  50619. /**
  50620. * Attach the input controls to a specific dom element to get the input from.
  50621. */
  50622. attachControl(): void;
  50623. /**
  50624. * Detach the current controls from the specified dom element.
  50625. */
  50626. detachControl(): void;
  50627. /**
  50628. * Update the current camera state depending on the inputs that have been used this frame.
  50629. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50630. */
  50631. checkInputs(): void;
  50632. /**
  50633. * Gets the class name of the current intput.
  50634. * @returns the class name
  50635. */
  50636. getClassName(): string;
  50637. /**
  50638. * Get the friendly name associated with the input class.
  50639. * @returns the input friendly name
  50640. */
  50641. getSimpleName(): string;
  50642. }
  50643. }
  50644. declare module BABYLON {
  50645. interface ArcRotateCameraInputsManager {
  50646. /**
  50647. * Add orientation input support to the input manager.
  50648. * @returns the current input manager
  50649. */
  50650. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50651. }
  50652. /**
  50653. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50654. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50655. */
  50656. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50657. /**
  50658. * Defines the camera the input is attached to.
  50659. */
  50660. camera: ArcRotateCamera;
  50661. /**
  50662. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50663. */
  50664. alphaCorrection: number;
  50665. /**
  50666. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50667. */
  50668. gammaCorrection: number;
  50669. private _alpha;
  50670. private _gamma;
  50671. private _dirty;
  50672. private _deviceOrientationHandler;
  50673. /**
  50674. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50675. */
  50676. constructor();
  50677. /**
  50678. * Attach the input controls to a specific dom element to get the input from.
  50679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50680. */
  50681. attachControl(noPreventDefault?: boolean): void;
  50682. /** @hidden */
  50683. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50684. /**
  50685. * Update the current camera state depending on the inputs that have been used this frame.
  50686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50687. */
  50688. checkInputs(): void;
  50689. /**
  50690. * Detach the current controls from the specified dom element.
  50691. */
  50692. detachControl(): void;
  50693. /**
  50694. * Gets the class name of the current intput.
  50695. * @returns the class name
  50696. */
  50697. getClassName(): string;
  50698. /**
  50699. * Get the friendly name associated with the input class.
  50700. * @returns the input friendly name
  50701. */
  50702. getSimpleName(): string;
  50703. }
  50704. }
  50705. declare module BABYLON {
  50706. /**
  50707. * Listen to mouse events to control the camera.
  50708. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50709. */
  50710. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50711. /**
  50712. * Defines the camera the input is attached to.
  50713. */
  50714. camera: FlyCamera;
  50715. /**
  50716. * Defines if touch is enabled. (Default is true.)
  50717. */
  50718. touchEnabled: boolean;
  50719. /**
  50720. * Defines the buttons associated with the input to handle camera rotation.
  50721. */
  50722. buttons: number[];
  50723. /**
  50724. * Assign buttons for Yaw control.
  50725. */
  50726. buttonsYaw: number[];
  50727. /**
  50728. * Assign buttons for Pitch control.
  50729. */
  50730. buttonsPitch: number[];
  50731. /**
  50732. * Assign buttons for Roll control.
  50733. */
  50734. buttonsRoll: number[];
  50735. /**
  50736. * Detect if any button is being pressed while mouse is moved.
  50737. * -1 = Mouse locked.
  50738. * 0 = Left button.
  50739. * 1 = Middle Button.
  50740. * 2 = Right Button.
  50741. */
  50742. activeButton: number;
  50743. /**
  50744. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  50745. * Higher values reduce its sensitivity.
  50746. */
  50747. angularSensibility: number;
  50748. private _observer;
  50749. private _rollObserver;
  50750. private previousPosition;
  50751. private noPreventDefault;
  50752. private element;
  50753. /**
  50754. * Listen to mouse events to control the camera.
  50755. * @param touchEnabled Define if touch is enabled. (Default is true.)
  50756. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50757. */
  50758. constructor(touchEnabled?: boolean);
  50759. /**
  50760. * Attach the mouse control to the HTML DOM element.
  50761. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  50762. */
  50763. attachControl(noPreventDefault?: boolean): void;
  50764. /**
  50765. * Detach the current controls from the specified dom element.
  50766. */
  50767. detachControl(): void;
  50768. /**
  50769. * Gets the class name of the current input.
  50770. * @returns the class name.
  50771. */
  50772. getClassName(): string;
  50773. /**
  50774. * Get the friendly name associated with the input class.
  50775. * @returns the input's friendly name.
  50776. */
  50777. getSimpleName(): string;
  50778. private _pointerInput;
  50779. private _onMouseMove;
  50780. /**
  50781. * Rotate camera by mouse offset.
  50782. */
  50783. private rotateCamera;
  50784. }
  50785. }
  50786. declare module BABYLON {
  50787. /**
  50788. * Default Inputs manager for the FlyCamera.
  50789. * It groups all the default supported inputs for ease of use.
  50790. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50791. */
  50792. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  50793. /**
  50794. * Instantiates a new FlyCameraInputsManager.
  50795. * @param camera Defines the camera the inputs belong to.
  50796. */
  50797. constructor(camera: FlyCamera);
  50798. /**
  50799. * Add keyboard input support to the input manager.
  50800. * @returns the new FlyCameraKeyboardMoveInput().
  50801. */
  50802. addKeyboard(): FlyCameraInputsManager;
  50803. /**
  50804. * Add mouse input support to the input manager.
  50805. * @param touchEnabled Enable touch screen support.
  50806. * @returns the new FlyCameraMouseInput().
  50807. */
  50808. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  50809. }
  50810. }
  50811. declare module BABYLON {
  50812. /**
  50813. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50814. * such as in a 3D Space Shooter or a Flight Simulator.
  50815. */
  50816. export class FlyCamera extends TargetCamera {
  50817. /**
  50818. * Define the collision ellipsoid of the camera.
  50819. * This is helpful for simulating a camera body, like a player's body.
  50820. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50821. */
  50822. ellipsoid: Vector3;
  50823. /**
  50824. * Define an offset for the position of the ellipsoid around the camera.
  50825. * This can be helpful if the camera is attached away from the player's body center,
  50826. * such as at its head.
  50827. */
  50828. ellipsoidOffset: Vector3;
  50829. /**
  50830. * Enable or disable collisions of the camera with the rest of the scene objects.
  50831. */
  50832. checkCollisions: boolean;
  50833. /**
  50834. * Enable or disable gravity on the camera.
  50835. */
  50836. applyGravity: boolean;
  50837. /**
  50838. * Define the current direction the camera is moving to.
  50839. */
  50840. cameraDirection: Vector3;
  50841. /**
  50842. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  50843. * This overrides and empties cameraRotation.
  50844. */
  50845. rotationQuaternion: Quaternion;
  50846. /**
  50847. * Track Roll to maintain the wanted Rolling when looking around.
  50848. */
  50849. _trackRoll: number;
  50850. /**
  50851. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  50852. */
  50853. rollCorrect: number;
  50854. /**
  50855. * Mimic a banked turn, Rolling the camera when Yawing.
  50856. * It's recommended to use rollCorrect = 10 for faster banking correction.
  50857. */
  50858. bankedTurn: boolean;
  50859. /**
  50860. * Limit in radians for how much Roll banking will add. (Default: 90°)
  50861. */
  50862. bankedTurnLimit: number;
  50863. /**
  50864. * Value of 0 disables the banked Roll.
  50865. * Value of 1 is equal to the Yaw angle in radians.
  50866. */
  50867. bankedTurnMultiplier: number;
  50868. /**
  50869. * The inputs manager loads all the input sources, such as keyboard and mouse.
  50870. */
  50871. inputs: FlyCameraInputsManager;
  50872. /**
  50873. * Gets the input sensibility for mouse input.
  50874. * Higher values reduce sensitivity.
  50875. */
  50876. get angularSensibility(): number;
  50877. /**
  50878. * Sets the input sensibility for a mouse input.
  50879. * Higher values reduce sensitivity.
  50880. */
  50881. set angularSensibility(value: number);
  50882. /**
  50883. * Get the keys for camera movement forward.
  50884. */
  50885. get keysForward(): number[];
  50886. /**
  50887. * Set the keys for camera movement forward.
  50888. */
  50889. set keysForward(value: number[]);
  50890. /**
  50891. * Get the keys for camera movement backward.
  50892. */
  50893. get keysBackward(): number[];
  50894. set keysBackward(value: number[]);
  50895. /**
  50896. * Get the keys for camera movement up.
  50897. */
  50898. get keysUp(): number[];
  50899. /**
  50900. * Set the keys for camera movement up.
  50901. */
  50902. set keysUp(value: number[]);
  50903. /**
  50904. * Get the keys for camera movement down.
  50905. */
  50906. get keysDown(): number[];
  50907. /**
  50908. * Set the keys for camera movement down.
  50909. */
  50910. set keysDown(value: number[]);
  50911. /**
  50912. * Get the keys for camera movement left.
  50913. */
  50914. get keysLeft(): number[];
  50915. /**
  50916. * Set the keys for camera movement left.
  50917. */
  50918. set keysLeft(value: number[]);
  50919. /**
  50920. * Set the keys for camera movement right.
  50921. */
  50922. get keysRight(): number[];
  50923. /**
  50924. * Set the keys for camera movement right.
  50925. */
  50926. set keysRight(value: number[]);
  50927. /**
  50928. * Event raised when the camera collides with a mesh in the scene.
  50929. */
  50930. onCollide: (collidedMesh: AbstractMesh) => void;
  50931. private _collider;
  50932. private _needMoveForGravity;
  50933. private _oldPosition;
  50934. private _diffPosition;
  50935. private _newPosition;
  50936. /** @hidden */
  50937. _localDirection: Vector3;
  50938. /** @hidden */
  50939. _transformedDirection: Vector3;
  50940. /**
  50941. * Instantiates a FlyCamera.
  50942. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50943. * such as in a 3D Space Shooter or a Flight Simulator.
  50944. * @param name Define the name of the camera in the scene.
  50945. * @param position Define the starting position of the camera in the scene.
  50946. * @param scene Define the scene the camera belongs to.
  50947. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  50948. */
  50949. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50950. /**
  50951. * Attach the input controls to a specific dom element to get the input from.
  50952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50953. */
  50954. attachControl(noPreventDefault?: boolean): void;
  50955. /**
  50956. * Detach a control from the HTML DOM element.
  50957. * The camera will stop reacting to that input.
  50958. */
  50959. detachControl(): void;
  50960. private _collisionMask;
  50961. /**
  50962. * Get the mask that the camera ignores in collision events.
  50963. */
  50964. get collisionMask(): number;
  50965. /**
  50966. * Set the mask that the camera ignores in collision events.
  50967. */
  50968. set collisionMask(mask: number);
  50969. /** @hidden */
  50970. _collideWithWorld(displacement: Vector3): void;
  50971. /** @hidden */
  50972. private _onCollisionPositionChange;
  50973. /** @hidden */
  50974. _checkInputs(): void;
  50975. /** @hidden */
  50976. _decideIfNeedsToMove(): boolean;
  50977. /** @hidden */
  50978. _updatePosition(): void;
  50979. /**
  50980. * Restore the Roll to its target value at the rate specified.
  50981. * @param rate - Higher means slower restoring.
  50982. * @hidden
  50983. */
  50984. restoreRoll(rate: number): void;
  50985. /**
  50986. * Destroy the camera and release the current resources held by it.
  50987. */
  50988. dispose(): void;
  50989. /**
  50990. * Get the current object class name.
  50991. * @returns the class name.
  50992. */
  50993. getClassName(): string;
  50994. }
  50995. }
  50996. declare module BABYLON {
  50997. /**
  50998. * Listen to keyboard events to control the camera.
  50999. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51000. */
  51001. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  51002. /**
  51003. * Defines the camera the input is attached to.
  51004. */
  51005. camera: FlyCamera;
  51006. /**
  51007. * The list of keyboard keys used to control the forward move of the camera.
  51008. */
  51009. keysForward: number[];
  51010. /**
  51011. * The list of keyboard keys used to control the backward move of the camera.
  51012. */
  51013. keysBackward: number[];
  51014. /**
  51015. * The list of keyboard keys used to control the forward move of the camera.
  51016. */
  51017. keysUp: number[];
  51018. /**
  51019. * The list of keyboard keys used to control the backward move of the camera.
  51020. */
  51021. keysDown: number[];
  51022. /**
  51023. * The list of keyboard keys used to control the right strafe move of the camera.
  51024. */
  51025. keysRight: number[];
  51026. /**
  51027. * The list of keyboard keys used to control the left strafe move of the camera.
  51028. */
  51029. keysLeft: number[];
  51030. private _keys;
  51031. private _onCanvasBlurObserver;
  51032. private _onKeyboardObserver;
  51033. private _engine;
  51034. private _scene;
  51035. /**
  51036. * Attach the input controls to a specific dom element to get the input from.
  51037. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51038. */
  51039. attachControl(noPreventDefault?: boolean): void;
  51040. /**
  51041. * Detach the current controls from the specified dom element.
  51042. */
  51043. detachControl(): void;
  51044. /**
  51045. * Gets the class name of the current intput.
  51046. * @returns the class name
  51047. */
  51048. getClassName(): string;
  51049. /** @hidden */
  51050. _onLostFocus(e: FocusEvent): void;
  51051. /**
  51052. * Get the friendly name associated with the input class.
  51053. * @returns the input friendly name
  51054. */
  51055. getSimpleName(): string;
  51056. /**
  51057. * Update the current camera state depending on the inputs that have been used this frame.
  51058. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51059. */
  51060. checkInputs(): void;
  51061. }
  51062. }
  51063. declare module BABYLON {
  51064. /**
  51065. * Manage the mouse wheel inputs to control a follow camera.
  51066. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51067. */
  51068. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51069. /**
  51070. * Defines the camera the input is attached to.
  51071. */
  51072. camera: FollowCamera;
  51073. /**
  51074. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51075. */
  51076. axisControlRadius: boolean;
  51077. /**
  51078. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51079. */
  51080. axisControlHeight: boolean;
  51081. /**
  51082. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51083. */
  51084. axisControlRotation: boolean;
  51085. /**
  51086. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51087. * relation to mouseWheel events.
  51088. */
  51089. wheelPrecision: number;
  51090. /**
  51091. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51092. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51093. */
  51094. wheelDeltaPercentage: number;
  51095. private _wheel;
  51096. private _observer;
  51097. /**
  51098. * Attach the input controls to a specific dom element to get the input from.
  51099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51100. */
  51101. attachControl(noPreventDefault?: boolean): void;
  51102. /**
  51103. * Detach the current controls from the specified dom element.
  51104. */
  51105. detachControl(): void;
  51106. /**
  51107. * Gets the class name of the current intput.
  51108. * @returns the class name
  51109. */
  51110. getClassName(): string;
  51111. /**
  51112. * Get the friendly name associated with the input class.
  51113. * @returns the input friendly name
  51114. */
  51115. getSimpleName(): string;
  51116. }
  51117. }
  51118. declare module BABYLON {
  51119. /**
  51120. * Manage the pointers inputs to control an follow camera.
  51121. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51122. */
  51123. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51124. /**
  51125. * Defines the camera the input is attached to.
  51126. */
  51127. camera: FollowCamera;
  51128. /**
  51129. * Gets the class name of the current input.
  51130. * @returns the class name
  51131. */
  51132. getClassName(): string;
  51133. /**
  51134. * Defines the pointer angular sensibility along the X axis or how fast is
  51135. * the camera rotating.
  51136. * A negative number will reverse the axis direction.
  51137. */
  51138. angularSensibilityX: number;
  51139. /**
  51140. * Defines the pointer angular sensibility along the Y axis or how fast is
  51141. * the camera rotating.
  51142. * A negative number will reverse the axis direction.
  51143. */
  51144. angularSensibilityY: number;
  51145. /**
  51146. * Defines the pointer pinch precision or how fast is the camera zooming.
  51147. * A negative number will reverse the axis direction.
  51148. */
  51149. pinchPrecision: number;
  51150. /**
  51151. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51152. * from 0.
  51153. * It defines the percentage of current camera.radius to use as delta when
  51154. * pinch zoom is used.
  51155. */
  51156. pinchDeltaPercentage: number;
  51157. /**
  51158. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51159. */
  51160. axisXControlRadius: boolean;
  51161. /**
  51162. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51163. */
  51164. axisXControlHeight: boolean;
  51165. /**
  51166. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51167. */
  51168. axisXControlRotation: boolean;
  51169. /**
  51170. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51171. */
  51172. axisYControlRadius: boolean;
  51173. /**
  51174. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51175. */
  51176. axisYControlHeight: boolean;
  51177. /**
  51178. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51179. */
  51180. axisYControlRotation: boolean;
  51181. /**
  51182. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51183. */
  51184. axisPinchControlRadius: boolean;
  51185. /**
  51186. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51187. */
  51188. axisPinchControlHeight: boolean;
  51189. /**
  51190. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51191. */
  51192. axisPinchControlRotation: boolean;
  51193. /**
  51194. * Log error messages if basic misconfiguration has occurred.
  51195. */
  51196. warningEnable: boolean;
  51197. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51198. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51199. private _warningCounter;
  51200. private _warning;
  51201. }
  51202. }
  51203. declare module BABYLON {
  51204. /**
  51205. * Default Inputs manager for the FollowCamera.
  51206. * It groups all the default supported inputs for ease of use.
  51207. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51208. */
  51209. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51210. /**
  51211. * Instantiates a new FollowCameraInputsManager.
  51212. * @param camera Defines the camera the inputs belong to
  51213. */
  51214. constructor(camera: FollowCamera);
  51215. /**
  51216. * Add keyboard input support to the input manager.
  51217. * @returns the current input manager
  51218. */
  51219. addKeyboard(): FollowCameraInputsManager;
  51220. /**
  51221. * Add mouse wheel input support to the input manager.
  51222. * @returns the current input manager
  51223. */
  51224. addMouseWheel(): FollowCameraInputsManager;
  51225. /**
  51226. * Add pointers input support to the input manager.
  51227. * @returns the current input manager
  51228. */
  51229. addPointers(): FollowCameraInputsManager;
  51230. /**
  51231. * Add orientation input support to the input manager.
  51232. * @returns the current input manager
  51233. */
  51234. addVRDeviceOrientation(): FollowCameraInputsManager;
  51235. }
  51236. }
  51237. declare module BABYLON {
  51238. /**
  51239. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51240. * an arc rotate version arcFollowCamera are available.
  51241. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51242. */
  51243. export class FollowCamera extends TargetCamera {
  51244. /**
  51245. * Distance the follow camera should follow an object at
  51246. */
  51247. radius: number;
  51248. /**
  51249. * Minimum allowed distance of the camera to the axis of rotation
  51250. * (The camera can not get closer).
  51251. * This can help limiting how the Camera is able to move in the scene.
  51252. */
  51253. lowerRadiusLimit: Nullable<number>;
  51254. /**
  51255. * Maximum allowed distance of the camera to the axis of rotation
  51256. * (The camera can not get further).
  51257. * This can help limiting how the Camera is able to move in the scene.
  51258. */
  51259. upperRadiusLimit: Nullable<number>;
  51260. /**
  51261. * Define a rotation offset between the camera and the object it follows
  51262. */
  51263. rotationOffset: number;
  51264. /**
  51265. * Minimum allowed angle to camera position relative to target object.
  51266. * This can help limiting how the Camera is able to move in the scene.
  51267. */
  51268. lowerRotationOffsetLimit: Nullable<number>;
  51269. /**
  51270. * Maximum allowed angle to camera position relative to target object.
  51271. * This can help limiting how the Camera is able to move in the scene.
  51272. */
  51273. upperRotationOffsetLimit: Nullable<number>;
  51274. /**
  51275. * Define a height offset between the camera and the object it follows.
  51276. * It can help following an object from the top (like a car chaing a plane)
  51277. */
  51278. heightOffset: number;
  51279. /**
  51280. * Minimum allowed height of camera position relative to target object.
  51281. * This can help limiting how the Camera is able to move in the scene.
  51282. */
  51283. lowerHeightOffsetLimit: Nullable<number>;
  51284. /**
  51285. * Maximum allowed height of camera position relative to target object.
  51286. * This can help limiting how the Camera is able to move in the scene.
  51287. */
  51288. upperHeightOffsetLimit: Nullable<number>;
  51289. /**
  51290. * Define how fast the camera can accelerate to follow it s target.
  51291. */
  51292. cameraAcceleration: number;
  51293. /**
  51294. * Define the speed limit of the camera following an object.
  51295. */
  51296. maxCameraSpeed: number;
  51297. /**
  51298. * Define the target of the camera.
  51299. */
  51300. lockedTarget: Nullable<AbstractMesh>;
  51301. /**
  51302. * Defines the input associated with the camera.
  51303. */
  51304. inputs: FollowCameraInputsManager;
  51305. /**
  51306. * Instantiates the follow camera.
  51307. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51308. * @param name Define the name of the camera in the scene
  51309. * @param position Define the position of the camera
  51310. * @param scene Define the scene the camera belong to
  51311. * @param lockedTarget Define the target of the camera
  51312. */
  51313. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51314. private _follow;
  51315. /**
  51316. * Attach the input controls to a specific dom element to get the input from.
  51317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51318. */
  51319. attachControl(noPreventDefault?: boolean): void;
  51320. /**
  51321. * Detach the current controls from the specified dom element.
  51322. */
  51323. detachControl(): void;
  51324. /** @hidden */
  51325. _checkInputs(): void;
  51326. private _checkLimits;
  51327. /**
  51328. * Gets the camera class name.
  51329. * @returns the class name
  51330. */
  51331. getClassName(): string;
  51332. }
  51333. /**
  51334. * Arc Rotate version of the follow camera.
  51335. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51336. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51337. */
  51338. export class ArcFollowCamera extends TargetCamera {
  51339. /** The longitudinal angle of the camera */
  51340. alpha: number;
  51341. /** The latitudinal angle of the camera */
  51342. beta: number;
  51343. /** The radius of the camera from its target */
  51344. radius: number;
  51345. private _cartesianCoordinates;
  51346. /** Define the camera target (the mesh it should follow) */
  51347. private _meshTarget;
  51348. /**
  51349. * Instantiates a new ArcFollowCamera
  51350. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51351. * @param name Define the name of the camera
  51352. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  51353. * @param beta Define the rotation angle of the camera around the elevation axis
  51354. * @param radius Define the radius of the camera from its target point
  51355. * @param target Define the target of the camera
  51356. * @param scene Define the scene the camera belongs to
  51357. */
  51358. constructor(name: string,
  51359. /** The longitudinal angle of the camera */
  51360. alpha: number,
  51361. /** The latitudinal angle of the camera */
  51362. beta: number,
  51363. /** The radius of the camera from its target */
  51364. radius: number,
  51365. /** Define the camera target (the mesh it should follow) */
  51366. target: Nullable<AbstractMesh>, scene: Scene);
  51367. private _follow;
  51368. /** @hidden */
  51369. _checkInputs(): void;
  51370. /**
  51371. * Returns the class name of the object.
  51372. * It is mostly used internally for serialization purposes.
  51373. */
  51374. getClassName(): string;
  51375. }
  51376. }
  51377. declare module BABYLON {
  51378. /**
  51379. * Manage the keyboard inputs to control the movement of a follow camera.
  51380. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51381. */
  51382. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51383. /**
  51384. * Defines the camera the input is attached to.
  51385. */
  51386. camera: FollowCamera;
  51387. /**
  51388. * Defines the list of key codes associated with the up action (increase heightOffset)
  51389. */
  51390. keysHeightOffsetIncr: number[];
  51391. /**
  51392. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51393. */
  51394. keysHeightOffsetDecr: number[];
  51395. /**
  51396. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51397. */
  51398. keysHeightOffsetModifierAlt: boolean;
  51399. /**
  51400. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51401. */
  51402. keysHeightOffsetModifierCtrl: boolean;
  51403. /**
  51404. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51405. */
  51406. keysHeightOffsetModifierShift: boolean;
  51407. /**
  51408. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51409. */
  51410. keysRotationOffsetIncr: number[];
  51411. /**
  51412. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51413. */
  51414. keysRotationOffsetDecr: number[];
  51415. /**
  51416. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51417. */
  51418. keysRotationOffsetModifierAlt: boolean;
  51419. /**
  51420. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51421. */
  51422. keysRotationOffsetModifierCtrl: boolean;
  51423. /**
  51424. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51425. */
  51426. keysRotationOffsetModifierShift: boolean;
  51427. /**
  51428. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51429. */
  51430. keysRadiusIncr: number[];
  51431. /**
  51432. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51433. */
  51434. keysRadiusDecr: number[];
  51435. /**
  51436. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51437. */
  51438. keysRadiusModifierAlt: boolean;
  51439. /**
  51440. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51441. */
  51442. keysRadiusModifierCtrl: boolean;
  51443. /**
  51444. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51445. */
  51446. keysRadiusModifierShift: boolean;
  51447. /**
  51448. * Defines the rate of change of heightOffset.
  51449. */
  51450. heightSensibility: number;
  51451. /**
  51452. * Defines the rate of change of rotationOffset.
  51453. */
  51454. rotationSensibility: number;
  51455. /**
  51456. * Defines the rate of change of radius.
  51457. */
  51458. radiusSensibility: number;
  51459. private _keys;
  51460. private _ctrlPressed;
  51461. private _altPressed;
  51462. private _shiftPressed;
  51463. private _onCanvasBlurObserver;
  51464. private _onKeyboardObserver;
  51465. private _engine;
  51466. private _scene;
  51467. /**
  51468. * Attach the input controls to a specific dom element to get the input from.
  51469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51470. */
  51471. attachControl(noPreventDefault?: boolean): void;
  51472. /**
  51473. * Detach the current controls from the specified dom element.
  51474. */
  51475. detachControl(): void;
  51476. /**
  51477. * Update the current camera state depending on the inputs that have been used this frame.
  51478. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51479. */
  51480. checkInputs(): void;
  51481. /**
  51482. * Gets the class name of the current input.
  51483. * @returns the class name
  51484. */
  51485. getClassName(): string;
  51486. /**
  51487. * Get the friendly name associated with the input class.
  51488. * @returns the input friendly name
  51489. */
  51490. getSimpleName(): string;
  51491. /**
  51492. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51493. * allow modification of the heightOffset value.
  51494. */
  51495. private _modifierHeightOffset;
  51496. /**
  51497. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51498. * allow modification of the rotationOffset value.
  51499. */
  51500. private _modifierRotationOffset;
  51501. /**
  51502. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51503. * allow modification of the radius value.
  51504. */
  51505. private _modifierRadius;
  51506. }
  51507. }
  51508. declare module BABYLON {
  51509. interface FreeCameraInputsManager {
  51510. /**
  51511. * @hidden
  51512. */
  51513. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51514. /**
  51515. * Add orientation input support to the input manager.
  51516. * @returns the current input manager
  51517. */
  51518. addDeviceOrientation(): FreeCameraInputsManager;
  51519. }
  51520. /**
  51521. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51522. * Screen rotation is taken into account.
  51523. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51524. */
  51525. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51526. private _camera;
  51527. private _screenOrientationAngle;
  51528. private _constantTranform;
  51529. private _screenQuaternion;
  51530. private _alpha;
  51531. private _beta;
  51532. private _gamma;
  51533. /**
  51534. * Can be used to detect if a device orientation sensor is available on a device
  51535. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51536. * @returns a promise that will resolve on orientation change
  51537. */
  51538. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51539. /**
  51540. * @hidden
  51541. */
  51542. _onDeviceOrientationChangedObservable: Observable<void>;
  51543. /**
  51544. * Instantiates a new input
  51545. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51546. */
  51547. constructor();
  51548. /**
  51549. * Define the camera controlled by the input.
  51550. */
  51551. get camera(): FreeCamera;
  51552. set camera(camera: FreeCamera);
  51553. /**
  51554. * Attach the input controls to a specific dom element to get the input from.
  51555. */
  51556. attachControl(): void;
  51557. private _orientationChanged;
  51558. private _deviceOrientation;
  51559. /**
  51560. * Detach the current controls from the specified dom element.
  51561. */
  51562. detachControl(): void;
  51563. /**
  51564. * Update the current camera state depending on the inputs that have been used this frame.
  51565. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51566. */
  51567. checkInputs(): void;
  51568. /**
  51569. * Gets the class name of the current intput.
  51570. * @returns the class name
  51571. */
  51572. getClassName(): string;
  51573. /**
  51574. * Get the friendly name associated with the input class.
  51575. * @returns the input friendly name
  51576. */
  51577. getSimpleName(): string;
  51578. }
  51579. }
  51580. declare module BABYLON {
  51581. /**
  51582. * Manage the gamepad inputs to control a free camera.
  51583. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51584. */
  51585. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51586. /**
  51587. * Define the camera the input is attached to.
  51588. */
  51589. camera: FreeCamera;
  51590. /**
  51591. * Define the Gamepad controlling the input
  51592. */
  51593. gamepad: Nullable<Gamepad>;
  51594. /**
  51595. * Defines the gamepad rotation sensiblity.
  51596. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51597. */
  51598. gamepadAngularSensibility: number;
  51599. /**
  51600. * Defines the gamepad move sensiblity.
  51601. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51602. */
  51603. gamepadMoveSensibility: number;
  51604. private _yAxisScale;
  51605. /**
  51606. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51607. */
  51608. get invertYAxis(): boolean;
  51609. set invertYAxis(value: boolean);
  51610. private _onGamepadConnectedObserver;
  51611. private _onGamepadDisconnectedObserver;
  51612. private _cameraTransform;
  51613. private _deltaTransform;
  51614. private _vector3;
  51615. private _vector2;
  51616. /**
  51617. * Attach the input controls to a specific dom element to get the input from.
  51618. */
  51619. attachControl(): void;
  51620. /**
  51621. * Detach the current controls from the specified dom element.
  51622. */
  51623. detachControl(): void;
  51624. /**
  51625. * Update the current camera state depending on the inputs that have been used this frame.
  51626. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51627. */
  51628. checkInputs(): void;
  51629. /**
  51630. * Gets the class name of the current intput.
  51631. * @returns the class name
  51632. */
  51633. getClassName(): string;
  51634. /**
  51635. * Get the friendly name associated with the input class.
  51636. * @returns the input friendly name
  51637. */
  51638. getSimpleName(): string;
  51639. }
  51640. }
  51641. declare module BABYLON {
  51642. /**
  51643. * Defines the potential axis of a Joystick
  51644. */
  51645. export enum JoystickAxis {
  51646. /** X axis */
  51647. X = 0,
  51648. /** Y axis */
  51649. Y = 1,
  51650. /** Z axis */
  51651. Z = 2
  51652. }
  51653. /**
  51654. * Represents the different customization options available
  51655. * for VirtualJoystick
  51656. */
  51657. interface VirtualJoystickCustomizations {
  51658. /**
  51659. * Size of the joystick's puck
  51660. */
  51661. puckSize: number;
  51662. /**
  51663. * Size of the joystick's container
  51664. */
  51665. containerSize: number;
  51666. /**
  51667. * Color of the joystick && puck
  51668. */
  51669. color: string;
  51670. /**
  51671. * Image URL for the joystick's puck
  51672. */
  51673. puckImage?: string;
  51674. /**
  51675. * Image URL for the joystick's container
  51676. */
  51677. containerImage?: string;
  51678. /**
  51679. * Defines the unmoving position of the joystick container
  51680. */
  51681. position?: {
  51682. x: number;
  51683. y: number;
  51684. };
  51685. /**
  51686. * Defines whether or not the joystick container is always visible
  51687. */
  51688. alwaysVisible: boolean;
  51689. /**
  51690. * Defines whether or not to limit the movement of the puck to the joystick's container
  51691. */
  51692. limitToContainer: boolean;
  51693. }
  51694. /**
  51695. * Class used to define virtual joystick (used in touch mode)
  51696. */
  51697. export class VirtualJoystick {
  51698. /**
  51699. * Gets or sets a boolean indicating that left and right values must be inverted
  51700. */
  51701. reverseLeftRight: boolean;
  51702. /**
  51703. * Gets or sets a boolean indicating that up and down values must be inverted
  51704. */
  51705. reverseUpDown: boolean;
  51706. /**
  51707. * Gets the offset value for the position (ie. the change of the position value)
  51708. */
  51709. deltaPosition: Vector3;
  51710. /**
  51711. * Gets a boolean indicating if the virtual joystick was pressed
  51712. */
  51713. pressed: boolean;
  51714. /**
  51715. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51716. */
  51717. static Canvas: Nullable<HTMLCanvasElement>;
  51718. /**
  51719. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51720. */
  51721. limitToContainer: boolean;
  51722. private static _globalJoystickIndex;
  51723. private static _alwaysVisibleSticks;
  51724. private static vjCanvasContext;
  51725. private static vjCanvasWidth;
  51726. private static vjCanvasHeight;
  51727. private static halfWidth;
  51728. private static _GetDefaultOptions;
  51729. private _action;
  51730. private _axisTargetedByLeftAndRight;
  51731. private _axisTargetedByUpAndDown;
  51732. private _joystickSensibility;
  51733. private _inversedSensibility;
  51734. private _joystickPointerID;
  51735. private _joystickColor;
  51736. private _joystickPointerPos;
  51737. private _joystickPreviousPointerPos;
  51738. private _joystickPointerStartPos;
  51739. private _deltaJoystickVector;
  51740. private _leftJoystick;
  51741. private _touches;
  51742. private _joystickPosition;
  51743. private _alwaysVisible;
  51744. private _puckImage;
  51745. private _containerImage;
  51746. private _joystickPuckSize;
  51747. private _joystickContainerSize;
  51748. private _clearPuckSize;
  51749. private _clearContainerSize;
  51750. private _clearPuckSizeOffset;
  51751. private _clearContainerSizeOffset;
  51752. private _onPointerDownHandlerRef;
  51753. private _onPointerMoveHandlerRef;
  51754. private _onPointerUpHandlerRef;
  51755. private _onResize;
  51756. /**
  51757. * Creates a new virtual joystick
  51758. * @param leftJoystick defines that the joystick is for left hand (false by default)
  51759. * @param customizations Defines the options we want to customize the VirtualJoystick
  51760. */
  51761. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  51762. /**
  51763. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  51764. * @param newJoystickSensibility defines the new sensibility
  51765. */
  51766. setJoystickSensibility(newJoystickSensibility: number): void;
  51767. private _onPointerDown;
  51768. private _onPointerMove;
  51769. private _onPointerUp;
  51770. /**
  51771. * Change the color of the virtual joystick
  51772. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  51773. */
  51774. setJoystickColor(newColor: string): void;
  51775. /**
  51776. * Size of the joystick's container
  51777. */
  51778. set containerSize(newSize: number);
  51779. get containerSize(): number;
  51780. /**
  51781. * Size of the joystick's puck
  51782. */
  51783. set puckSize(newSize: number);
  51784. get puckSize(): number;
  51785. /**
  51786. * Clears the set position of the joystick
  51787. */
  51788. clearPosition(): void;
  51789. /**
  51790. * Defines whether or not the joystick container is always visible
  51791. */
  51792. set alwaysVisible(value: boolean);
  51793. get alwaysVisible(): boolean;
  51794. /**
  51795. * Sets the constant position of the Joystick container
  51796. * @param x X axis coordinate
  51797. * @param y Y axis coordinate
  51798. */
  51799. setPosition(x: number, y: number): void;
  51800. /**
  51801. * Defines a callback to call when the joystick is touched
  51802. * @param action defines the callback
  51803. */
  51804. setActionOnTouch(action: () => any): void;
  51805. /**
  51806. * Defines which axis you'd like to control for left & right
  51807. * @param axis defines the axis to use
  51808. */
  51809. setAxisForLeftRight(axis: JoystickAxis): void;
  51810. /**
  51811. * Defines which axis you'd like to control for up & down
  51812. * @param axis defines the axis to use
  51813. */
  51814. setAxisForUpDown(axis: JoystickAxis): void;
  51815. /**
  51816. * Clears the canvas from the previous puck / container draw
  51817. */
  51818. private _clearPreviousDraw;
  51819. /**
  51820. * Loads `urlPath` to be used for the container's image
  51821. * @param urlPath defines the urlPath of an image to use
  51822. */
  51823. setContainerImage(urlPath: string): void;
  51824. /**
  51825. * Loads `urlPath` to be used for the puck's image
  51826. * @param urlPath defines the urlPath of an image to use
  51827. */
  51828. setPuckImage(urlPath: string): void;
  51829. /**
  51830. * Draws the Virtual Joystick's container
  51831. */
  51832. private _drawContainer;
  51833. /**
  51834. * Draws the Virtual Joystick's puck
  51835. */
  51836. private _drawPuck;
  51837. private _drawVirtualJoystick;
  51838. /**
  51839. * Release internal HTML canvas
  51840. */
  51841. releaseCanvas(): void;
  51842. }
  51843. }
  51844. declare module BABYLON {
  51845. interface FreeCameraInputsManager {
  51846. /**
  51847. * Add virtual joystick input support to the input manager.
  51848. * @returns the current input manager
  51849. */
  51850. addVirtualJoystick(): FreeCameraInputsManager;
  51851. }
  51852. /**
  51853. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  51854. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51855. */
  51856. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  51857. /**
  51858. * Defines the camera the input is attached to.
  51859. */
  51860. camera: FreeCamera;
  51861. private _leftjoystick;
  51862. private _rightjoystick;
  51863. /**
  51864. * Gets the left stick of the virtual joystick.
  51865. * @returns The virtual Joystick
  51866. */
  51867. getLeftJoystick(): VirtualJoystick;
  51868. /**
  51869. * Gets the right stick of the virtual joystick.
  51870. * @returns The virtual Joystick
  51871. */
  51872. getRightJoystick(): VirtualJoystick;
  51873. /**
  51874. * Update the current camera state depending on the inputs that have been used this frame.
  51875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51876. */
  51877. checkInputs(): void;
  51878. /**
  51879. * Attach the input controls to a specific dom element to get the input from.
  51880. */
  51881. attachControl(): void;
  51882. /**
  51883. * Detach the current controls from the specified dom element.
  51884. */
  51885. detachControl(): void;
  51886. /**
  51887. * Gets the class name of the current intput.
  51888. * @returns the class name
  51889. */
  51890. getClassName(): string;
  51891. /**
  51892. * Get the friendly name associated with the input class.
  51893. * @returns the input friendly name
  51894. */
  51895. getSimpleName(): string;
  51896. }
  51897. }
  51898. declare module BABYLON {
  51899. /**
  51900. * This represents a FPS type of camera controlled by touch.
  51901. * This is like a universal camera minus the Gamepad controls.
  51902. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51903. */
  51904. export class TouchCamera extends FreeCamera {
  51905. /**
  51906. * Defines the touch sensibility for rotation.
  51907. * The higher the faster.
  51908. */
  51909. get touchAngularSensibility(): number;
  51910. set touchAngularSensibility(value: number);
  51911. /**
  51912. * Defines the touch sensibility for move.
  51913. * The higher the faster.
  51914. */
  51915. get touchMoveSensibility(): number;
  51916. set touchMoveSensibility(value: number);
  51917. /**
  51918. * Instantiates a new touch camera.
  51919. * This represents a FPS type of camera controlled by touch.
  51920. * This is like a universal camera minus the Gamepad controls.
  51921. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51922. * @param name Define the name of the camera in the scene
  51923. * @param position Define the start position of the camera in the scene
  51924. * @param scene Define the scene the camera belongs to
  51925. */
  51926. constructor(name: string, position: Vector3, scene: Scene);
  51927. /**
  51928. * Gets the current object class name.
  51929. * @return the class name
  51930. */
  51931. getClassName(): string;
  51932. /** @hidden */
  51933. _setupInputs(): void;
  51934. }
  51935. }
  51936. declare module BABYLON {
  51937. /**
  51938. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  51939. * being tilted forward or back and left or right.
  51940. */
  51941. export class DeviceOrientationCamera extends FreeCamera {
  51942. private _initialQuaternion;
  51943. private _quaternionCache;
  51944. private _tmpDragQuaternion;
  51945. private _disablePointerInputWhenUsingDeviceOrientation;
  51946. /**
  51947. * Creates a new device orientation camera
  51948. * @param name The name of the camera
  51949. * @param position The start position camera
  51950. * @param scene The scene the camera belongs to
  51951. */
  51952. constructor(name: string, position: Vector3, scene: Scene);
  51953. /**
  51954. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  51955. */
  51956. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  51957. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  51958. private _dragFactor;
  51959. /**
  51960. * Enabled turning on the y axis when the orientation sensor is active
  51961. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  51962. */
  51963. enableHorizontalDragging(dragFactor?: number): void;
  51964. /**
  51965. * Gets the current instance class name ("DeviceOrientationCamera").
  51966. * This helps avoiding instanceof at run time.
  51967. * @returns the class name
  51968. */
  51969. getClassName(): string;
  51970. /**
  51971. * @hidden
  51972. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  51973. */
  51974. _checkInputs(): void;
  51975. /**
  51976. * Reset the camera to its default orientation on the specified axis only.
  51977. * @param axis The axis to reset
  51978. */
  51979. resetToCurrentRotation(axis?: Axis): void;
  51980. }
  51981. }
  51982. declare module BABYLON {
  51983. /**
  51984. * Defines supported buttons for XBox360 compatible gamepads
  51985. */
  51986. export enum Xbox360Button {
  51987. /** A */
  51988. A = 0,
  51989. /** B */
  51990. B = 1,
  51991. /** X */
  51992. X = 2,
  51993. /** Y */
  51994. Y = 3,
  51995. /** Left button */
  51996. LB = 4,
  51997. /** Right button */
  51998. RB = 5,
  51999. /** Back */
  52000. Back = 8,
  52001. /** Start */
  52002. Start = 9,
  52003. /** Left stick */
  52004. LeftStick = 10,
  52005. /** Right stick */
  52006. RightStick = 11
  52007. }
  52008. /** Defines values for XBox360 DPad */
  52009. export enum Xbox360Dpad {
  52010. /** Up */
  52011. Up = 12,
  52012. /** Down */
  52013. Down = 13,
  52014. /** Left */
  52015. Left = 14,
  52016. /** Right */
  52017. Right = 15
  52018. }
  52019. /**
  52020. * Defines a XBox360 gamepad
  52021. */
  52022. export class Xbox360Pad extends Gamepad {
  52023. private _leftTrigger;
  52024. private _rightTrigger;
  52025. private _onlefttriggerchanged;
  52026. private _onrighttriggerchanged;
  52027. private _onbuttondown;
  52028. private _onbuttonup;
  52029. private _ondpaddown;
  52030. private _ondpadup;
  52031. /** Observable raised when a button is pressed */
  52032. onButtonDownObservable: Observable<Xbox360Button>;
  52033. /** Observable raised when a button is released */
  52034. onButtonUpObservable: Observable<Xbox360Button>;
  52035. /** Observable raised when a pad is pressed */
  52036. onPadDownObservable: Observable<Xbox360Dpad>;
  52037. /** Observable raised when a pad is released */
  52038. onPadUpObservable: Observable<Xbox360Dpad>;
  52039. private _buttonA;
  52040. private _buttonB;
  52041. private _buttonX;
  52042. private _buttonY;
  52043. private _buttonBack;
  52044. private _buttonStart;
  52045. private _buttonLB;
  52046. private _buttonRB;
  52047. private _buttonLeftStick;
  52048. private _buttonRightStick;
  52049. private _dPadUp;
  52050. private _dPadDown;
  52051. private _dPadLeft;
  52052. private _dPadRight;
  52053. private _isXboxOnePad;
  52054. /**
  52055. * Creates a new XBox360 gamepad object
  52056. * @param id defines the id of this gamepad
  52057. * @param index defines its index
  52058. * @param gamepad defines the internal HTML gamepad object
  52059. * @param xboxOne defines if it is a XBox One gamepad
  52060. */
  52061. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52062. /**
  52063. * Defines the callback to call when left trigger is pressed
  52064. * @param callback defines the callback to use
  52065. */
  52066. onlefttriggerchanged(callback: (value: number) => void): void;
  52067. /**
  52068. * Defines the callback to call when right trigger is pressed
  52069. * @param callback defines the callback to use
  52070. */
  52071. onrighttriggerchanged(callback: (value: number) => void): void;
  52072. /**
  52073. * Gets the left trigger value
  52074. */
  52075. get leftTrigger(): number;
  52076. /**
  52077. * Sets the left trigger value
  52078. */
  52079. set leftTrigger(newValue: number);
  52080. /**
  52081. * Gets the right trigger value
  52082. */
  52083. get rightTrigger(): number;
  52084. /**
  52085. * Sets the right trigger value
  52086. */
  52087. set rightTrigger(newValue: number);
  52088. /**
  52089. * Defines the callback to call when a button is pressed
  52090. * @param callback defines the callback to use
  52091. */
  52092. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52093. /**
  52094. * Defines the callback to call when a button is released
  52095. * @param callback defines the callback to use
  52096. */
  52097. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52098. /**
  52099. * Defines the callback to call when a pad is pressed
  52100. * @param callback defines the callback to use
  52101. */
  52102. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52103. /**
  52104. * Defines the callback to call when a pad is released
  52105. * @param callback defines the callback to use
  52106. */
  52107. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52108. private _setButtonValue;
  52109. private _setDPadValue;
  52110. /**
  52111. * Gets the value of the `A` button
  52112. */
  52113. get buttonA(): number;
  52114. /**
  52115. * Sets the value of the `A` button
  52116. */
  52117. set buttonA(value: number);
  52118. /**
  52119. * Gets the value of the `B` button
  52120. */
  52121. get buttonB(): number;
  52122. /**
  52123. * Sets the value of the `B` button
  52124. */
  52125. set buttonB(value: number);
  52126. /**
  52127. * Gets the value of the `X` button
  52128. */
  52129. get buttonX(): number;
  52130. /**
  52131. * Sets the value of the `X` button
  52132. */
  52133. set buttonX(value: number);
  52134. /**
  52135. * Gets the value of the `Y` button
  52136. */
  52137. get buttonY(): number;
  52138. /**
  52139. * Sets the value of the `Y` button
  52140. */
  52141. set buttonY(value: number);
  52142. /**
  52143. * Gets the value of the `Start` button
  52144. */
  52145. get buttonStart(): number;
  52146. /**
  52147. * Sets the value of the `Start` button
  52148. */
  52149. set buttonStart(value: number);
  52150. /**
  52151. * Gets the value of the `Back` button
  52152. */
  52153. get buttonBack(): number;
  52154. /**
  52155. * Sets the value of the `Back` button
  52156. */
  52157. set buttonBack(value: number);
  52158. /**
  52159. * Gets the value of the `Left` button
  52160. */
  52161. get buttonLB(): number;
  52162. /**
  52163. * Sets the value of the `Left` button
  52164. */
  52165. set buttonLB(value: number);
  52166. /**
  52167. * Gets the value of the `Right` button
  52168. */
  52169. get buttonRB(): number;
  52170. /**
  52171. * Sets the value of the `Right` button
  52172. */
  52173. set buttonRB(value: number);
  52174. /**
  52175. * Gets the value of the Left joystick
  52176. */
  52177. get buttonLeftStick(): number;
  52178. /**
  52179. * Sets the value of the Left joystick
  52180. */
  52181. set buttonLeftStick(value: number);
  52182. /**
  52183. * Gets the value of the Right joystick
  52184. */
  52185. get buttonRightStick(): number;
  52186. /**
  52187. * Sets the value of the Right joystick
  52188. */
  52189. set buttonRightStick(value: number);
  52190. /**
  52191. * Gets the value of D-pad up
  52192. */
  52193. get dPadUp(): number;
  52194. /**
  52195. * Sets the value of D-pad up
  52196. */
  52197. set dPadUp(value: number);
  52198. /**
  52199. * Gets the value of D-pad down
  52200. */
  52201. get dPadDown(): number;
  52202. /**
  52203. * Sets the value of D-pad down
  52204. */
  52205. set dPadDown(value: number);
  52206. /**
  52207. * Gets the value of D-pad left
  52208. */
  52209. get dPadLeft(): number;
  52210. /**
  52211. * Sets the value of D-pad left
  52212. */
  52213. set dPadLeft(value: number);
  52214. /**
  52215. * Gets the value of D-pad right
  52216. */
  52217. get dPadRight(): number;
  52218. /**
  52219. * Sets the value of D-pad right
  52220. */
  52221. set dPadRight(value: number);
  52222. /**
  52223. * Force the gamepad to synchronize with device values
  52224. */
  52225. update(): void;
  52226. /**
  52227. * Disposes the gamepad
  52228. */
  52229. dispose(): void;
  52230. }
  52231. }
  52232. declare module BABYLON {
  52233. /**
  52234. * Defines supported buttons for DualShock compatible gamepads
  52235. */
  52236. export enum DualShockButton {
  52237. /** Cross */
  52238. Cross = 0,
  52239. /** Circle */
  52240. Circle = 1,
  52241. /** Square */
  52242. Square = 2,
  52243. /** Triangle */
  52244. Triangle = 3,
  52245. /** L1 */
  52246. L1 = 4,
  52247. /** R1 */
  52248. R1 = 5,
  52249. /** Share */
  52250. Share = 8,
  52251. /** Options */
  52252. Options = 9,
  52253. /** Left stick */
  52254. LeftStick = 10,
  52255. /** Right stick */
  52256. RightStick = 11
  52257. }
  52258. /** Defines values for DualShock DPad */
  52259. export enum DualShockDpad {
  52260. /** Up */
  52261. Up = 12,
  52262. /** Down */
  52263. Down = 13,
  52264. /** Left */
  52265. Left = 14,
  52266. /** Right */
  52267. Right = 15
  52268. }
  52269. /**
  52270. * Defines a DualShock gamepad
  52271. */
  52272. export class DualShockPad extends Gamepad {
  52273. private _leftTrigger;
  52274. private _rightTrigger;
  52275. private _onlefttriggerchanged;
  52276. private _onrighttriggerchanged;
  52277. private _onbuttondown;
  52278. private _onbuttonup;
  52279. private _ondpaddown;
  52280. private _ondpadup;
  52281. /** Observable raised when a button is pressed */
  52282. onButtonDownObservable: Observable<DualShockButton>;
  52283. /** Observable raised when a button is released */
  52284. onButtonUpObservable: Observable<DualShockButton>;
  52285. /** Observable raised when a pad is pressed */
  52286. onPadDownObservable: Observable<DualShockDpad>;
  52287. /** Observable raised when a pad is released */
  52288. onPadUpObservable: Observable<DualShockDpad>;
  52289. private _buttonCross;
  52290. private _buttonCircle;
  52291. private _buttonSquare;
  52292. private _buttonTriangle;
  52293. private _buttonShare;
  52294. private _buttonOptions;
  52295. private _buttonL1;
  52296. private _buttonR1;
  52297. private _buttonLeftStick;
  52298. private _buttonRightStick;
  52299. private _dPadUp;
  52300. private _dPadDown;
  52301. private _dPadLeft;
  52302. private _dPadRight;
  52303. /**
  52304. * Creates a new DualShock gamepad object
  52305. * @param id defines the id of this gamepad
  52306. * @param index defines its index
  52307. * @param gamepad defines the internal HTML gamepad object
  52308. */
  52309. constructor(id: string, index: number, gamepad: any);
  52310. /**
  52311. * Defines the callback to call when left trigger is pressed
  52312. * @param callback defines the callback to use
  52313. */
  52314. onlefttriggerchanged(callback: (value: number) => void): void;
  52315. /**
  52316. * Defines the callback to call when right trigger is pressed
  52317. * @param callback defines the callback to use
  52318. */
  52319. onrighttriggerchanged(callback: (value: number) => void): void;
  52320. /**
  52321. * Gets the left trigger value
  52322. */
  52323. get leftTrigger(): number;
  52324. /**
  52325. * Sets the left trigger value
  52326. */
  52327. set leftTrigger(newValue: number);
  52328. /**
  52329. * Gets the right trigger value
  52330. */
  52331. get rightTrigger(): number;
  52332. /**
  52333. * Sets the right trigger value
  52334. */
  52335. set rightTrigger(newValue: number);
  52336. /**
  52337. * Defines the callback to call when a button is pressed
  52338. * @param callback defines the callback to use
  52339. */
  52340. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52341. /**
  52342. * Defines the callback to call when a button is released
  52343. * @param callback defines the callback to use
  52344. */
  52345. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52346. /**
  52347. * Defines the callback to call when a pad is pressed
  52348. * @param callback defines the callback to use
  52349. */
  52350. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52351. /**
  52352. * Defines the callback to call when a pad is released
  52353. * @param callback defines the callback to use
  52354. */
  52355. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52356. private _setButtonValue;
  52357. private _setDPadValue;
  52358. /**
  52359. * Gets the value of the `Cross` button
  52360. */
  52361. get buttonCross(): number;
  52362. /**
  52363. * Sets the value of the `Cross` button
  52364. */
  52365. set buttonCross(value: number);
  52366. /**
  52367. * Gets the value of the `Circle` button
  52368. */
  52369. get buttonCircle(): number;
  52370. /**
  52371. * Sets the value of the `Circle` button
  52372. */
  52373. set buttonCircle(value: number);
  52374. /**
  52375. * Gets the value of the `Square` button
  52376. */
  52377. get buttonSquare(): number;
  52378. /**
  52379. * Sets the value of the `Square` button
  52380. */
  52381. set buttonSquare(value: number);
  52382. /**
  52383. * Gets the value of the `Triangle` button
  52384. */
  52385. get buttonTriangle(): number;
  52386. /**
  52387. * Sets the value of the `Triangle` button
  52388. */
  52389. set buttonTriangle(value: number);
  52390. /**
  52391. * Gets the value of the `Options` button
  52392. */
  52393. get buttonOptions(): number;
  52394. /**
  52395. * Sets the value of the `Options` button
  52396. */
  52397. set buttonOptions(value: number);
  52398. /**
  52399. * Gets the value of the `Share` button
  52400. */
  52401. get buttonShare(): number;
  52402. /**
  52403. * Sets the value of the `Share` button
  52404. */
  52405. set buttonShare(value: number);
  52406. /**
  52407. * Gets the value of the `L1` button
  52408. */
  52409. get buttonL1(): number;
  52410. /**
  52411. * Sets the value of the `L1` button
  52412. */
  52413. set buttonL1(value: number);
  52414. /**
  52415. * Gets the value of the `R1` button
  52416. */
  52417. get buttonR1(): number;
  52418. /**
  52419. * Sets the value of the `R1` button
  52420. */
  52421. set buttonR1(value: number);
  52422. /**
  52423. * Gets the value of the Left joystick
  52424. */
  52425. get buttonLeftStick(): number;
  52426. /**
  52427. * Sets the value of the Left joystick
  52428. */
  52429. set buttonLeftStick(value: number);
  52430. /**
  52431. * Gets the value of the Right joystick
  52432. */
  52433. get buttonRightStick(): number;
  52434. /**
  52435. * Sets the value of the Right joystick
  52436. */
  52437. set buttonRightStick(value: number);
  52438. /**
  52439. * Gets the value of D-pad up
  52440. */
  52441. get dPadUp(): number;
  52442. /**
  52443. * Sets the value of D-pad up
  52444. */
  52445. set dPadUp(value: number);
  52446. /**
  52447. * Gets the value of D-pad down
  52448. */
  52449. get dPadDown(): number;
  52450. /**
  52451. * Sets the value of D-pad down
  52452. */
  52453. set dPadDown(value: number);
  52454. /**
  52455. * Gets the value of D-pad left
  52456. */
  52457. get dPadLeft(): number;
  52458. /**
  52459. * Sets the value of D-pad left
  52460. */
  52461. set dPadLeft(value: number);
  52462. /**
  52463. * Gets the value of D-pad right
  52464. */
  52465. get dPadRight(): number;
  52466. /**
  52467. * Sets the value of D-pad right
  52468. */
  52469. set dPadRight(value: number);
  52470. /**
  52471. * Force the gamepad to synchronize with device values
  52472. */
  52473. update(): void;
  52474. /**
  52475. * Disposes the gamepad
  52476. */
  52477. dispose(): void;
  52478. }
  52479. }
  52480. declare module BABYLON {
  52481. /**
  52482. * Manager for handling gamepads
  52483. */
  52484. export class GamepadManager {
  52485. private _scene?;
  52486. private _babylonGamepads;
  52487. private _oneGamepadConnected;
  52488. /** @hidden */
  52489. _isMonitoring: boolean;
  52490. private _gamepadEventSupported;
  52491. private _gamepadSupport?;
  52492. /**
  52493. * observable to be triggered when the gamepad controller has been connected
  52494. */
  52495. onGamepadConnectedObservable: Observable<Gamepad>;
  52496. /**
  52497. * observable to be triggered when the gamepad controller has been disconnected
  52498. */
  52499. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52500. private _onGamepadConnectedEvent;
  52501. private _onGamepadDisconnectedEvent;
  52502. /**
  52503. * Initializes the gamepad manager
  52504. * @param _scene BabylonJS scene
  52505. */
  52506. constructor(_scene?: Scene | undefined);
  52507. /**
  52508. * The gamepads in the game pad manager
  52509. */
  52510. get gamepads(): Gamepad[];
  52511. /**
  52512. * Get the gamepad controllers based on type
  52513. * @param type The type of gamepad controller
  52514. * @returns Nullable gamepad
  52515. */
  52516. getGamepadByType(type?: number): Nullable<Gamepad>;
  52517. /**
  52518. * Disposes the gamepad manager
  52519. */
  52520. dispose(): void;
  52521. private _addNewGamepad;
  52522. private _startMonitoringGamepads;
  52523. private _stopMonitoringGamepads;
  52524. /** @hidden */
  52525. _checkGamepadsStatus(): void;
  52526. private _updateGamepadObjects;
  52527. }
  52528. }
  52529. declare module BABYLON {
  52530. interface Scene {
  52531. /** @hidden */
  52532. _gamepadManager: Nullable<GamepadManager>;
  52533. /**
  52534. * Gets the gamepad manager associated with the scene
  52535. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52536. */
  52537. gamepadManager: GamepadManager;
  52538. }
  52539. /**
  52540. * Interface representing a free camera inputs manager
  52541. */
  52542. interface FreeCameraInputsManager {
  52543. /**
  52544. * Adds gamepad input support to the FreeCameraInputsManager.
  52545. * @returns the FreeCameraInputsManager
  52546. */
  52547. addGamepad(): FreeCameraInputsManager;
  52548. }
  52549. /**
  52550. * Interface representing an arc rotate camera inputs manager
  52551. */
  52552. interface ArcRotateCameraInputsManager {
  52553. /**
  52554. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52555. * @returns the camera inputs manager
  52556. */
  52557. addGamepad(): ArcRotateCameraInputsManager;
  52558. }
  52559. /**
  52560. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52561. */
  52562. export class GamepadSystemSceneComponent implements ISceneComponent {
  52563. /**
  52564. * The component name helpfull to identify the component in the list of scene components.
  52565. */
  52566. readonly name: string;
  52567. /**
  52568. * The scene the component belongs to.
  52569. */
  52570. scene: Scene;
  52571. /**
  52572. * Creates a new instance of the component for the given scene
  52573. * @param scene Defines the scene to register the component in
  52574. */
  52575. constructor(scene: Scene);
  52576. /**
  52577. * Registers the component in a given scene
  52578. */
  52579. register(): void;
  52580. /**
  52581. * Rebuilds the elements related to this component in case of
  52582. * context lost for instance.
  52583. */
  52584. rebuild(): void;
  52585. /**
  52586. * Disposes the component and the associated ressources
  52587. */
  52588. dispose(): void;
  52589. private _beforeCameraUpdate;
  52590. }
  52591. }
  52592. declare module BABYLON {
  52593. /**
  52594. * 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,
  52595. * which still works and will still be found in many Playgrounds.
  52596. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52597. */
  52598. export class UniversalCamera extends TouchCamera {
  52599. /**
  52600. * Defines the gamepad rotation sensiblity.
  52601. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52602. */
  52603. get gamepadAngularSensibility(): number;
  52604. set gamepadAngularSensibility(value: number);
  52605. /**
  52606. * Defines the gamepad move sensiblity.
  52607. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52608. */
  52609. get gamepadMoveSensibility(): number;
  52610. set gamepadMoveSensibility(value: number);
  52611. /**
  52612. * 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,
  52613. * which still works and will still be found in many Playgrounds.
  52614. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52615. * @param name Define the name of the camera in the scene
  52616. * @param position Define the start position of the camera in the scene
  52617. * @param scene Define the scene the camera belongs to
  52618. */
  52619. constructor(name: string, position: Vector3, scene: Scene);
  52620. /**
  52621. * Gets the current object class name.
  52622. * @return the class name
  52623. */
  52624. getClassName(): string;
  52625. }
  52626. }
  52627. declare module BABYLON {
  52628. /**
  52629. * This represents a FPS type of camera. This is only here for back compat purpose.
  52630. * Please use the UniversalCamera instead as both are identical.
  52631. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52632. */
  52633. export class GamepadCamera extends UniversalCamera {
  52634. /**
  52635. * Instantiates a new Gamepad Camera
  52636. * This represents a FPS type of camera. This is only here for back compat purpose.
  52637. * Please use the UniversalCamera instead as both are identical.
  52638. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52639. * @param name Define the name of the camera in the scene
  52640. * @param position Define the start position of the camera in the scene
  52641. * @param scene Define the scene the camera belongs to
  52642. */
  52643. constructor(name: string, position: Vector3, scene: Scene);
  52644. /**
  52645. * Gets the current object class name.
  52646. * @return the class name
  52647. */
  52648. getClassName(): string;
  52649. }
  52650. }
  52651. declare module BABYLON {
  52652. /** @hidden */
  52653. export var anaglyphPixelShader: {
  52654. name: string;
  52655. shader: string;
  52656. };
  52657. }
  52658. declare module BABYLON {
  52659. /**
  52660. * Postprocess used to generate anaglyphic rendering
  52661. */
  52662. export class AnaglyphPostProcess extends PostProcess {
  52663. private _passedProcess;
  52664. /**
  52665. * Gets a string identifying the name of the class
  52666. * @returns "AnaglyphPostProcess" string
  52667. */
  52668. getClassName(): string;
  52669. /**
  52670. * Creates a new AnaglyphPostProcess
  52671. * @param name defines postprocess name
  52672. * @param options defines creation options or target ratio scale
  52673. * @param rigCameras defines cameras using this postprocess
  52674. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52675. * @param engine defines hosting engine
  52676. * @param reusable defines if the postprocess will be reused multiple times per frame
  52677. */
  52678. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52679. }
  52680. }
  52681. declare module BABYLON {
  52682. /**
  52683. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52684. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52685. */
  52686. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52687. /**
  52688. * Creates a new AnaglyphArcRotateCamera
  52689. * @param name defines camera name
  52690. * @param alpha defines alpha angle (in radians)
  52691. * @param beta defines beta angle (in radians)
  52692. * @param radius defines radius
  52693. * @param target defines camera target
  52694. * @param interaxialDistance defines distance between each color axis
  52695. * @param scene defines the hosting scene
  52696. */
  52697. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52698. /**
  52699. * Gets camera class name
  52700. * @returns AnaglyphArcRotateCamera
  52701. */
  52702. getClassName(): string;
  52703. }
  52704. }
  52705. declare module BABYLON {
  52706. /**
  52707. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52708. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52709. */
  52710. export class AnaglyphFreeCamera extends FreeCamera {
  52711. /**
  52712. * Creates a new AnaglyphFreeCamera
  52713. * @param name defines camera name
  52714. * @param position defines initial position
  52715. * @param interaxialDistance defines distance between each color axis
  52716. * @param scene defines the hosting scene
  52717. */
  52718. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52719. /**
  52720. * Gets camera class name
  52721. * @returns AnaglyphFreeCamera
  52722. */
  52723. getClassName(): string;
  52724. }
  52725. }
  52726. declare module BABYLON {
  52727. /**
  52728. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  52729. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52730. */
  52731. export class AnaglyphGamepadCamera extends GamepadCamera {
  52732. /**
  52733. * Creates a new AnaglyphGamepadCamera
  52734. * @param name defines camera name
  52735. * @param position defines initial position
  52736. * @param interaxialDistance defines distance between each color axis
  52737. * @param scene defines the hosting scene
  52738. */
  52739. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52740. /**
  52741. * Gets camera class name
  52742. * @returns AnaglyphGamepadCamera
  52743. */
  52744. getClassName(): string;
  52745. }
  52746. }
  52747. declare module BABYLON {
  52748. /**
  52749. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  52750. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52751. */
  52752. export class AnaglyphUniversalCamera extends UniversalCamera {
  52753. /**
  52754. * Creates a new AnaglyphUniversalCamera
  52755. * @param name defines camera name
  52756. * @param position defines initial position
  52757. * @param interaxialDistance defines distance between each color axis
  52758. * @param scene defines the hosting scene
  52759. */
  52760. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52761. /**
  52762. * Gets camera class name
  52763. * @returns AnaglyphUniversalCamera
  52764. */
  52765. getClassName(): string;
  52766. }
  52767. }
  52768. declare module BABYLON {
  52769. /** @hidden */
  52770. export var stereoscopicInterlacePixelShader: {
  52771. name: string;
  52772. shader: string;
  52773. };
  52774. }
  52775. declare module BABYLON {
  52776. /**
  52777. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  52778. */
  52779. export class StereoscopicInterlacePostProcessI extends PostProcess {
  52780. private _stepSize;
  52781. private _passedProcess;
  52782. /**
  52783. * Gets a string identifying the name of the class
  52784. * @returns "StereoscopicInterlacePostProcessI" string
  52785. */
  52786. getClassName(): string;
  52787. /**
  52788. * Initializes a StereoscopicInterlacePostProcessI
  52789. * @param name The name of the effect.
  52790. * @param rigCameras The rig cameras to be appled to the post process
  52791. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  52792. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  52793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52794. * @param engine The engine which the post process will be applied. (default: current engine)
  52795. * @param reusable If the post process can be reused on the same frame. (default: false)
  52796. */
  52797. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52798. }
  52799. /**
  52800. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  52801. */
  52802. export class StereoscopicInterlacePostProcess extends PostProcess {
  52803. private _stepSize;
  52804. private _passedProcess;
  52805. /**
  52806. * Gets a string identifying the name of the class
  52807. * @returns "StereoscopicInterlacePostProcess" string
  52808. */
  52809. getClassName(): string;
  52810. /**
  52811. * Initializes a StereoscopicInterlacePostProcess
  52812. * @param name The name of the effect.
  52813. * @param rigCameras The rig cameras to be appled to the post process
  52814. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  52815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52816. * @param engine The engine which the post process will be applied. (default: current engine)
  52817. * @param reusable If the post process can be reused on the same frame. (default: false)
  52818. */
  52819. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52820. }
  52821. }
  52822. declare module BABYLON {
  52823. /**
  52824. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  52825. * @see https://doc.babylonjs.com/features/cameras
  52826. */
  52827. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  52828. /**
  52829. * Creates a new StereoscopicArcRotateCamera
  52830. * @param name defines camera name
  52831. * @param alpha defines alpha angle (in radians)
  52832. * @param beta defines beta angle (in radians)
  52833. * @param radius defines radius
  52834. * @param target defines camera target
  52835. * @param interaxialDistance defines distance between each color axis
  52836. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52837. * @param scene defines the hosting scene
  52838. */
  52839. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52840. /**
  52841. * Gets camera class name
  52842. * @returns StereoscopicArcRotateCamera
  52843. */
  52844. getClassName(): string;
  52845. }
  52846. }
  52847. declare module BABYLON {
  52848. /**
  52849. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  52850. * @see https://doc.babylonjs.com/features/cameras
  52851. */
  52852. export class StereoscopicFreeCamera extends FreeCamera {
  52853. /**
  52854. * Creates a new StereoscopicFreeCamera
  52855. * @param name defines camera name
  52856. * @param position defines initial position
  52857. * @param interaxialDistance defines distance between each color axis
  52858. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52859. * @param scene defines the hosting scene
  52860. */
  52861. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52862. /**
  52863. * Gets camera class name
  52864. * @returns StereoscopicFreeCamera
  52865. */
  52866. getClassName(): string;
  52867. }
  52868. }
  52869. declare module BABYLON {
  52870. /**
  52871. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  52872. * @see https://doc.babylonjs.com/features/cameras
  52873. */
  52874. export class StereoscopicGamepadCamera extends GamepadCamera {
  52875. /**
  52876. * Creates a new StereoscopicGamepadCamera
  52877. * @param name defines camera name
  52878. * @param position defines initial position
  52879. * @param interaxialDistance defines distance between each color axis
  52880. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52881. * @param scene defines the hosting scene
  52882. */
  52883. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52884. /**
  52885. * Gets camera class name
  52886. * @returns StereoscopicGamepadCamera
  52887. */
  52888. getClassName(): string;
  52889. }
  52890. }
  52891. declare module BABYLON {
  52892. /**
  52893. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  52894. * @see https://doc.babylonjs.com/features/cameras
  52895. */
  52896. export class StereoscopicUniversalCamera extends UniversalCamera {
  52897. /**
  52898. * Creates a new StereoscopicUniversalCamera
  52899. * @param name defines camera name
  52900. * @param position defines initial position
  52901. * @param interaxialDistance defines distance between each color axis
  52902. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52903. * @param scene defines the hosting scene
  52904. */
  52905. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52906. /**
  52907. * Gets camera class name
  52908. * @returns StereoscopicUniversalCamera
  52909. */
  52910. getClassName(): string;
  52911. }
  52912. }
  52913. declare module BABYLON {
  52914. /**
  52915. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  52916. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52917. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52918. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52919. */
  52920. export class VirtualJoysticksCamera extends FreeCamera {
  52921. /**
  52922. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  52923. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52924. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52925. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52926. * @param name Define the name of the camera in the scene
  52927. * @param position Define the start position of the camera in the scene
  52928. * @param scene Define the scene the camera belongs to
  52929. */
  52930. constructor(name: string, position: Vector3, scene: Scene);
  52931. /**
  52932. * Gets the current object class name.
  52933. * @return the class name
  52934. */
  52935. getClassName(): string;
  52936. }
  52937. }
  52938. declare module BABYLON {
  52939. /**
  52940. * This represents all the required metrics to create a VR camera.
  52941. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  52942. */
  52943. export class VRCameraMetrics {
  52944. /**
  52945. * Define the horizontal resolution off the screen.
  52946. */
  52947. hResolution: number;
  52948. /**
  52949. * Define the vertical resolution off the screen.
  52950. */
  52951. vResolution: number;
  52952. /**
  52953. * Define the horizontal screen size.
  52954. */
  52955. hScreenSize: number;
  52956. /**
  52957. * Define the vertical screen size.
  52958. */
  52959. vScreenSize: number;
  52960. /**
  52961. * Define the vertical screen center position.
  52962. */
  52963. vScreenCenter: number;
  52964. /**
  52965. * Define the distance of the eyes to the screen.
  52966. */
  52967. eyeToScreenDistance: number;
  52968. /**
  52969. * Define the distance between both lenses
  52970. */
  52971. lensSeparationDistance: number;
  52972. /**
  52973. * Define the distance between both viewer's eyes.
  52974. */
  52975. interpupillaryDistance: number;
  52976. /**
  52977. * Define the distortion factor of the VR postprocess.
  52978. * Please, touch with care.
  52979. */
  52980. distortionK: number[];
  52981. /**
  52982. * Define the chromatic aberration correction factors for the VR post process.
  52983. */
  52984. chromaAbCorrection: number[];
  52985. /**
  52986. * Define the scale factor of the post process.
  52987. * The smaller the better but the slower.
  52988. */
  52989. postProcessScaleFactor: number;
  52990. /**
  52991. * Define an offset for the lens center.
  52992. */
  52993. lensCenterOffset: number;
  52994. /**
  52995. * Define if the current vr camera should compensate the distortion of the lense or not.
  52996. */
  52997. compensateDistortion: boolean;
  52998. /**
  52999. * Defines if multiview should be enabled when rendering (Default: false)
  53000. */
  53001. multiviewEnabled: boolean;
  53002. /**
  53003. * Gets the rendering aspect ratio based on the provided resolutions.
  53004. */
  53005. get aspectRatio(): number;
  53006. /**
  53007. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  53008. */
  53009. get aspectRatioFov(): number;
  53010. /**
  53011. * @hidden
  53012. */
  53013. get leftHMatrix(): Matrix;
  53014. /**
  53015. * @hidden
  53016. */
  53017. get rightHMatrix(): Matrix;
  53018. /**
  53019. * @hidden
  53020. */
  53021. get leftPreViewMatrix(): Matrix;
  53022. /**
  53023. * @hidden
  53024. */
  53025. get rightPreViewMatrix(): Matrix;
  53026. /**
  53027. * Get the default VRMetrics based on the most generic setup.
  53028. * @returns the default vr metrics
  53029. */
  53030. static GetDefault(): VRCameraMetrics;
  53031. }
  53032. }
  53033. declare module BABYLON {
  53034. /** @hidden */
  53035. export var vrDistortionCorrectionPixelShader: {
  53036. name: string;
  53037. shader: string;
  53038. };
  53039. }
  53040. declare module BABYLON {
  53041. /**
  53042. * VRDistortionCorrectionPostProcess used for mobile VR
  53043. */
  53044. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53045. private _isRightEye;
  53046. private _distortionFactors;
  53047. private _postProcessScaleFactor;
  53048. private _lensCenterOffset;
  53049. private _scaleIn;
  53050. private _scaleFactor;
  53051. private _lensCenter;
  53052. /**
  53053. * Gets a string identifying the name of the class
  53054. * @returns "VRDistortionCorrectionPostProcess" string
  53055. */
  53056. getClassName(): string;
  53057. /**
  53058. * Initializes the VRDistortionCorrectionPostProcess
  53059. * @param name The name of the effect.
  53060. * @param camera The camera to apply the render pass to.
  53061. * @param isRightEye If this is for the right eye distortion
  53062. * @param vrMetrics All the required metrics for the VR camera
  53063. */
  53064. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53065. }
  53066. }
  53067. declare module BABYLON {
  53068. /**
  53069. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53070. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53071. */
  53072. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53073. /**
  53074. * Creates a new VRDeviceOrientationArcRotateCamera
  53075. * @param name defines camera name
  53076. * @param alpha defines the camera rotation along the logitudinal axis
  53077. * @param beta defines the camera rotation along the latitudinal axis
  53078. * @param radius defines the camera distance from its target
  53079. * @param target defines the camera target
  53080. * @param scene defines the scene the camera belongs to
  53081. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53082. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53083. */
  53084. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53085. /**
  53086. * Gets camera class name
  53087. * @returns VRDeviceOrientationArcRotateCamera
  53088. */
  53089. getClassName(): string;
  53090. }
  53091. }
  53092. declare module BABYLON {
  53093. /**
  53094. * Camera used to simulate VR rendering (based on FreeCamera)
  53095. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53096. */
  53097. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53098. /**
  53099. * Creates a new VRDeviceOrientationFreeCamera
  53100. * @param name defines camera name
  53101. * @param position defines the start position of the camera
  53102. * @param scene defines the scene the camera belongs to
  53103. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53104. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53105. */
  53106. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53107. /**
  53108. * Gets camera class name
  53109. * @returns VRDeviceOrientationFreeCamera
  53110. */
  53111. getClassName(): string;
  53112. }
  53113. }
  53114. declare module BABYLON {
  53115. /**
  53116. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53117. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53118. */
  53119. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53120. /**
  53121. * Creates a new VRDeviceOrientationGamepadCamera
  53122. * @param name defines camera name
  53123. * @param position defines the start position of the camera
  53124. * @param scene defines the scene the camera belongs to
  53125. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53126. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53127. */
  53128. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53129. /**
  53130. * Gets camera class name
  53131. * @returns VRDeviceOrientationGamepadCamera
  53132. */
  53133. getClassName(): string;
  53134. }
  53135. }
  53136. declare module BABYLON {
  53137. /**
  53138. * A class extending Texture allowing drawing on a texture
  53139. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53140. */
  53141. export class DynamicTexture extends Texture {
  53142. private _generateMipMaps;
  53143. private _canvas;
  53144. private _context;
  53145. /**
  53146. * Creates a DynamicTexture
  53147. * @param name defines the name of the texture
  53148. * @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
  53149. * @param scene defines the scene where you want the texture
  53150. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53151. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53152. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53153. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53154. */
  53155. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53156. /**
  53157. * Get the current class name of the texture useful for serialization or dynamic coding.
  53158. * @returns "DynamicTexture"
  53159. */
  53160. getClassName(): string;
  53161. /**
  53162. * Gets the current state of canRescale
  53163. */
  53164. get canRescale(): boolean;
  53165. private _recreate;
  53166. /**
  53167. * Scales the texture
  53168. * @param ratio the scale factor to apply to both width and height
  53169. */
  53170. scale(ratio: number): void;
  53171. /**
  53172. * Resizes the texture
  53173. * @param width the new width
  53174. * @param height the new height
  53175. */
  53176. scaleTo(width: number, height: number): void;
  53177. /**
  53178. * Gets the context of the canvas used by the texture
  53179. * @returns the canvas context of the dynamic texture
  53180. */
  53181. getContext(): CanvasRenderingContext2D;
  53182. /**
  53183. * Clears the texture
  53184. */
  53185. clear(): void;
  53186. /**
  53187. * Updates the texture
  53188. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53189. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53190. */
  53191. update(invertY?: boolean, premulAlpha?: boolean): void;
  53192. /**
  53193. * Draws text onto the texture
  53194. * @param text defines the text to be drawn
  53195. * @param x defines the placement of the text from the left
  53196. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53197. * @param font defines the font to be used with font-style, font-size, font-name
  53198. * @param color defines the color used for the text
  53199. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53200. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53201. * @param update defines whether texture is immediately update (default is true)
  53202. */
  53203. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53204. /**
  53205. * Clones the texture
  53206. * @returns the clone of the texture.
  53207. */
  53208. clone(): DynamicTexture;
  53209. /**
  53210. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53211. * @returns a serialized dynamic texture object
  53212. */
  53213. serialize(): any;
  53214. private _IsCanvasElement;
  53215. /** @hidden */
  53216. _rebuild(): void;
  53217. }
  53218. }
  53219. declare module BABYLON {
  53220. /**
  53221. * Class containing static functions to help procedurally build meshes
  53222. */
  53223. export class GroundBuilder {
  53224. /**
  53225. * Creates a ground mesh
  53226. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53227. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53229. * @param name defines the name of the mesh
  53230. * @param options defines the options used to create the mesh
  53231. * @param scene defines the hosting scene
  53232. * @returns the ground mesh
  53233. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53234. */
  53235. static CreateGround(name: string, options: {
  53236. width?: number;
  53237. height?: number;
  53238. subdivisions?: number;
  53239. subdivisionsX?: number;
  53240. subdivisionsY?: number;
  53241. updatable?: boolean;
  53242. }, scene: any): Mesh;
  53243. /**
  53244. * Creates a tiled ground mesh
  53245. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53246. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53247. * * 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
  53248. * * 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
  53249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53250. * @param name defines the name of the mesh
  53251. * @param options defines the options used to create the mesh
  53252. * @param scene defines the hosting scene
  53253. * @returns the tiled ground mesh
  53254. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53255. */
  53256. static CreateTiledGround(name: string, options: {
  53257. xmin: number;
  53258. zmin: number;
  53259. xmax: number;
  53260. zmax: number;
  53261. subdivisions?: {
  53262. w: number;
  53263. h: number;
  53264. };
  53265. precision?: {
  53266. w: number;
  53267. h: number;
  53268. };
  53269. updatable?: boolean;
  53270. }, scene?: Nullable<Scene>): Mesh;
  53271. /**
  53272. * Creates a ground mesh from a height map
  53273. * * The parameter `url` sets the URL of the height map image resource.
  53274. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53275. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53276. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53277. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53278. * * 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.
  53279. * * 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).
  53280. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53282. * @param name defines the name of the mesh
  53283. * @param url defines the url to the height map
  53284. * @param options defines the options used to create the mesh
  53285. * @param scene defines the hosting scene
  53286. * @returns the ground mesh
  53287. * @see https://doc.babylonjs.com/babylon101/height_map
  53288. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53289. */
  53290. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53291. width?: number;
  53292. height?: number;
  53293. subdivisions?: number;
  53294. minHeight?: number;
  53295. maxHeight?: number;
  53296. colorFilter?: Color3;
  53297. alphaFilter?: number;
  53298. updatable?: boolean;
  53299. onReady?: (mesh: GroundMesh) => void;
  53300. }, scene?: Nullable<Scene>): GroundMesh;
  53301. }
  53302. }
  53303. declare module BABYLON {
  53304. /**
  53305. * Class containing static functions to help procedurally build meshes
  53306. */
  53307. export class TorusBuilder {
  53308. /**
  53309. * Creates a torus mesh
  53310. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53311. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53312. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53314. * * 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
  53315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53316. * @param name defines the name of the mesh
  53317. * @param options defines the options used to create the mesh
  53318. * @param scene defines the hosting scene
  53319. * @returns the torus mesh
  53320. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53321. */
  53322. static CreateTorus(name: string, options: {
  53323. diameter?: number;
  53324. thickness?: number;
  53325. tessellation?: number;
  53326. updatable?: boolean;
  53327. sideOrientation?: number;
  53328. frontUVs?: Vector4;
  53329. backUVs?: Vector4;
  53330. }, scene: any): Mesh;
  53331. }
  53332. }
  53333. declare module BABYLON {
  53334. /**
  53335. * Class containing static functions to help procedurally build meshes
  53336. */
  53337. export class CylinderBuilder {
  53338. /**
  53339. * Creates a cylinder or a cone mesh
  53340. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53341. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53342. * * 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.
  53343. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53344. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53345. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53346. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53347. * * 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).
  53348. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53349. * * 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).
  53350. * * 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
  53351. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53352. * * 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
  53353. * * 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.
  53354. * * If `enclose` is false, a ring surface is one element.
  53355. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53356. * * 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
  53357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53358. * * 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
  53359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53360. * @param name defines the name of the mesh
  53361. * @param options defines the options used to create the mesh
  53362. * @param scene defines the hosting scene
  53363. * @returns the cylinder mesh
  53364. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53365. */
  53366. static CreateCylinder(name: string, options: {
  53367. height?: number;
  53368. diameterTop?: number;
  53369. diameterBottom?: number;
  53370. diameter?: number;
  53371. tessellation?: number;
  53372. subdivisions?: number;
  53373. arc?: number;
  53374. faceColors?: Color4[];
  53375. faceUV?: Vector4[];
  53376. updatable?: boolean;
  53377. hasRings?: boolean;
  53378. enclose?: boolean;
  53379. cap?: number;
  53380. sideOrientation?: number;
  53381. frontUVs?: Vector4;
  53382. backUVs?: Vector4;
  53383. }, scene: any): Mesh;
  53384. }
  53385. }
  53386. declare module BABYLON {
  53387. /**
  53388. * States of the webXR experience
  53389. */
  53390. export enum WebXRState {
  53391. /**
  53392. * Transitioning to being in XR mode
  53393. */
  53394. ENTERING_XR = 0,
  53395. /**
  53396. * Transitioning to non XR mode
  53397. */
  53398. EXITING_XR = 1,
  53399. /**
  53400. * In XR mode and presenting
  53401. */
  53402. IN_XR = 2,
  53403. /**
  53404. * Not entered XR mode
  53405. */
  53406. NOT_IN_XR = 3
  53407. }
  53408. /**
  53409. * The state of the XR camera's tracking
  53410. */
  53411. export enum WebXRTrackingState {
  53412. /**
  53413. * No transformation received, device is not being tracked
  53414. */
  53415. NOT_TRACKING = 0,
  53416. /**
  53417. * Tracking lost - using emulated position
  53418. */
  53419. TRACKING_LOST = 1,
  53420. /**
  53421. * Transformation tracking works normally
  53422. */
  53423. TRACKING = 2
  53424. }
  53425. /**
  53426. * Abstraction of the XR render target
  53427. */
  53428. export interface WebXRRenderTarget extends IDisposable {
  53429. /**
  53430. * xrpresent context of the canvas which can be used to display/mirror xr content
  53431. */
  53432. canvasContext: WebGLRenderingContext;
  53433. /**
  53434. * xr layer for the canvas
  53435. */
  53436. xrLayer: Nullable<XRWebGLLayer>;
  53437. /**
  53438. * Initializes the xr layer for the session
  53439. * @param xrSession xr session
  53440. * @returns a promise that will resolve once the XR Layer has been created
  53441. */
  53442. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53443. }
  53444. }
  53445. declare module BABYLON {
  53446. /**
  53447. * COnfiguration object for WebXR output canvas
  53448. */
  53449. export class WebXRManagedOutputCanvasOptions {
  53450. /**
  53451. * An optional canvas in case you wish to create it yourself and provide it here.
  53452. * If not provided, a new canvas will be created
  53453. */
  53454. canvasElement?: HTMLCanvasElement;
  53455. /**
  53456. * Options for this XR Layer output
  53457. */
  53458. canvasOptions?: XRWebGLLayerInit;
  53459. /**
  53460. * CSS styling for a newly created canvas (if not provided)
  53461. */
  53462. newCanvasCssStyle?: string;
  53463. /**
  53464. * Get the default values of the configuration object
  53465. * @param engine defines the engine to use (can be null)
  53466. * @returns default values of this configuration object
  53467. */
  53468. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53469. }
  53470. /**
  53471. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53472. */
  53473. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53474. private _options;
  53475. private _canvas;
  53476. private _engine;
  53477. private _originalCanvasSize;
  53478. /**
  53479. * Rendering context of the canvas which can be used to display/mirror xr content
  53480. */
  53481. canvasContext: WebGLRenderingContext;
  53482. /**
  53483. * xr layer for the canvas
  53484. */
  53485. xrLayer: Nullable<XRWebGLLayer>;
  53486. /**
  53487. * Obseervers registered here will be triggered when the xr layer was initialized
  53488. */
  53489. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53490. /**
  53491. * Initializes the canvas to be added/removed upon entering/exiting xr
  53492. * @param _xrSessionManager The XR Session manager
  53493. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53494. */
  53495. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53496. /**
  53497. * Disposes of the object
  53498. */
  53499. dispose(): void;
  53500. /**
  53501. * Initializes the xr layer for the session
  53502. * @param xrSession xr session
  53503. * @returns a promise that will resolve once the XR Layer has been created
  53504. */
  53505. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53506. private _addCanvas;
  53507. private _removeCanvas;
  53508. private _setCanvasSize;
  53509. private _setManagedOutputCanvas;
  53510. }
  53511. }
  53512. declare module BABYLON {
  53513. /**
  53514. * Manages an XRSession to work with Babylon's engine
  53515. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53516. */
  53517. export class WebXRSessionManager implements IDisposable {
  53518. /** The scene which the session should be created for */
  53519. scene: Scene;
  53520. private _referenceSpace;
  53521. private _rttProvider;
  53522. private _sessionEnded;
  53523. private _xrNavigator;
  53524. private baseLayer;
  53525. /**
  53526. * The base reference space from which the session started. good if you want to reset your
  53527. * reference space
  53528. */
  53529. baseReferenceSpace: XRReferenceSpace;
  53530. /**
  53531. * Current XR frame
  53532. */
  53533. currentFrame: Nullable<XRFrame>;
  53534. /** WebXR timestamp updated every frame */
  53535. currentTimestamp: number;
  53536. /**
  53537. * Used just in case of a failure to initialize an immersive session.
  53538. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53539. */
  53540. defaultHeightCompensation: number;
  53541. /**
  53542. * Fires every time a new xrFrame arrives which can be used to update the camera
  53543. */
  53544. onXRFrameObservable: Observable<XRFrame>;
  53545. /**
  53546. * Fires when the reference space changed
  53547. */
  53548. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53549. /**
  53550. * Fires when the xr session is ended either by the device or manually done
  53551. */
  53552. onXRSessionEnded: Observable<any>;
  53553. /**
  53554. * Fires when the xr session is ended either by the device or manually done
  53555. */
  53556. onXRSessionInit: Observable<XRSession>;
  53557. /**
  53558. * Underlying xr session
  53559. */
  53560. session: XRSession;
  53561. /**
  53562. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53563. * or get the offset the player is currently at.
  53564. */
  53565. viewerReferenceSpace: XRReferenceSpace;
  53566. /**
  53567. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53568. * @param scene The scene which the session should be created for
  53569. */
  53570. constructor(
  53571. /** The scene which the session should be created for */
  53572. scene: Scene);
  53573. /**
  53574. * The current reference space used in this session. This reference space can constantly change!
  53575. * It is mainly used to offset the camera's position.
  53576. */
  53577. get referenceSpace(): XRReferenceSpace;
  53578. /**
  53579. * Set a new reference space and triggers the observable
  53580. */
  53581. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53582. /**
  53583. * Disposes of the session manager
  53584. */
  53585. dispose(): void;
  53586. /**
  53587. * Stops the xrSession and restores the render loop
  53588. * @returns Promise which resolves after it exits XR
  53589. */
  53590. exitXRAsync(): Promise<void>;
  53591. /**
  53592. * Gets the correct render target texture to be rendered this frame for this eye
  53593. * @param eye the eye for which to get the render target
  53594. * @returns the render target for the specified eye
  53595. */
  53596. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53597. /**
  53598. * Creates a WebXRRenderTarget object for the XR session
  53599. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53600. * @param options optional options to provide when creating a new render target
  53601. * @returns a WebXR render target to which the session can render
  53602. */
  53603. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53604. /**
  53605. * Initializes the manager
  53606. * After initialization enterXR can be called to start an XR session
  53607. * @returns Promise which resolves after it is initialized
  53608. */
  53609. initializeAsync(): Promise<void>;
  53610. /**
  53611. * Initializes an xr session
  53612. * @param xrSessionMode mode to initialize
  53613. * @param xrSessionInit defines optional and required values to pass to the session builder
  53614. * @returns a promise which will resolve once the session has been initialized
  53615. */
  53616. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53617. /**
  53618. * Checks if a session would be supported for the creation options specified
  53619. * @param sessionMode session mode to check if supported eg. immersive-vr
  53620. * @returns A Promise that resolves to true if supported and false if not
  53621. */
  53622. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53623. /**
  53624. * Resets the reference space to the one started the session
  53625. */
  53626. resetReferenceSpace(): void;
  53627. /**
  53628. * Starts rendering to the xr layer
  53629. */
  53630. runXRRenderLoop(): void;
  53631. /**
  53632. * Sets the reference space on the xr session
  53633. * @param referenceSpaceType space to set
  53634. * @returns a promise that will resolve once the reference space has been set
  53635. */
  53636. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53637. /**
  53638. * Updates the render state of the session
  53639. * @param state state to set
  53640. * @returns a promise that resolves once the render state has been updated
  53641. */
  53642. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53643. /**
  53644. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53645. * @param sessionMode defines the session to test
  53646. * @returns a promise with boolean as final value
  53647. */
  53648. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53649. /**
  53650. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53651. */
  53652. get isNative(): boolean;
  53653. private _createRenderTargetTexture;
  53654. }
  53655. }
  53656. declare module BABYLON {
  53657. /**
  53658. * WebXR Camera which holds the views for the xrSession
  53659. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53660. */
  53661. export class WebXRCamera extends FreeCamera {
  53662. private _xrSessionManager;
  53663. private _firstFrame;
  53664. private _referenceQuaternion;
  53665. private _referencedPosition;
  53666. private _xrInvPositionCache;
  53667. private _xrInvQuaternionCache;
  53668. private _trackingState;
  53669. /**
  53670. * Observable raised before camera teleportation
  53671. */
  53672. onBeforeCameraTeleport: Observable<Vector3>;
  53673. /**
  53674. * Observable raised after camera teleportation
  53675. */
  53676. onAfterCameraTeleport: Observable<Vector3>;
  53677. /**
  53678. * Notifies when the camera's tracking state has changed.
  53679. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53680. */
  53681. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53682. /**
  53683. * Should position compensation execute on first frame.
  53684. * This is used when copying the position from a native (non XR) camera
  53685. */
  53686. compensateOnFirstFrame: boolean;
  53687. /**
  53688. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53689. * @param name the name of the camera
  53690. * @param scene the scene to add the camera to
  53691. * @param _xrSessionManager a constructed xr session manager
  53692. */
  53693. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53694. /**
  53695. * Get the current XR tracking state of the camera
  53696. */
  53697. get trackingState(): WebXRTrackingState;
  53698. private _setTrackingState;
  53699. /**
  53700. * Return the user's height, unrelated to the current ground.
  53701. * This will be the y position of this camera, when ground level is 0.
  53702. */
  53703. get realWorldHeight(): number;
  53704. /** @hidden */
  53705. _updateForDualEyeDebugging(): void;
  53706. /**
  53707. * Sets this camera's transformation based on a non-vr camera
  53708. * @param otherCamera the non-vr camera to copy the transformation from
  53709. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53710. */
  53711. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53712. /**
  53713. * Gets the current instance class name ("WebXRCamera").
  53714. * @returns the class name
  53715. */
  53716. getClassName(): string;
  53717. private _rotate180;
  53718. private _updateFromXRSession;
  53719. private _updateNumberOfRigCameras;
  53720. private _updateReferenceSpace;
  53721. private _updateReferenceSpaceOffset;
  53722. }
  53723. }
  53724. declare module BABYLON {
  53725. /**
  53726. * Defining the interface required for a (webxr) feature
  53727. */
  53728. export interface IWebXRFeature extends IDisposable {
  53729. /**
  53730. * Is this feature attached
  53731. */
  53732. attached: boolean;
  53733. /**
  53734. * Should auto-attach be disabled?
  53735. */
  53736. disableAutoAttach: boolean;
  53737. /**
  53738. * Attach the feature to the session
  53739. * Will usually be called by the features manager
  53740. *
  53741. * @param force should attachment be forced (even when already attached)
  53742. * @returns true if successful.
  53743. */
  53744. attach(force?: boolean): boolean;
  53745. /**
  53746. * Detach the feature from the session
  53747. * Will usually be called by the features manager
  53748. *
  53749. * @returns true if successful.
  53750. */
  53751. detach(): boolean;
  53752. /**
  53753. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53754. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53755. *
  53756. * @returns whether or not the feature is compatible in this environment
  53757. */
  53758. isCompatible(): boolean;
  53759. /**
  53760. * Was this feature disposed;
  53761. */
  53762. isDisposed: boolean;
  53763. /**
  53764. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  53765. */
  53766. xrNativeFeatureName?: string;
  53767. /**
  53768. * A list of (Babylon WebXR) features this feature depends on
  53769. */
  53770. dependsOn?: string[];
  53771. /**
  53772. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  53773. */
  53774. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  53775. }
  53776. /**
  53777. * A list of the currently available features without referencing them
  53778. */
  53779. export class WebXRFeatureName {
  53780. /**
  53781. * The name of the anchor system feature
  53782. */
  53783. static readonly ANCHOR_SYSTEM: string;
  53784. /**
  53785. * The name of the background remover feature
  53786. */
  53787. static readonly BACKGROUND_REMOVER: string;
  53788. /**
  53789. * The name of the hit test feature
  53790. */
  53791. static readonly HIT_TEST: string;
  53792. /**
  53793. * The name of the mesh detection feature
  53794. */
  53795. static readonly MESH_DETECTION: string;
  53796. /**
  53797. * physics impostors for xr controllers feature
  53798. */
  53799. static readonly PHYSICS_CONTROLLERS: string;
  53800. /**
  53801. * The name of the plane detection feature
  53802. */
  53803. static readonly PLANE_DETECTION: string;
  53804. /**
  53805. * The name of the pointer selection feature
  53806. */
  53807. static readonly POINTER_SELECTION: string;
  53808. /**
  53809. * The name of the teleportation feature
  53810. */
  53811. static readonly TELEPORTATION: string;
  53812. /**
  53813. * The name of the feature points feature.
  53814. */
  53815. static readonly FEATURE_POINTS: string;
  53816. /**
  53817. * The name of the hand tracking feature.
  53818. */
  53819. static readonly HAND_TRACKING: string;
  53820. /**
  53821. * The name of the image tracking feature
  53822. */
  53823. static readonly IMAGE_TRACKING: string;
  53824. }
  53825. /**
  53826. * Defining the constructor of a feature. Used to register the modules.
  53827. */
  53828. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  53829. /**
  53830. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  53831. * It is mainly used in AR sessions.
  53832. *
  53833. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  53834. */
  53835. export class WebXRFeaturesManager implements IDisposable {
  53836. private _xrSessionManager;
  53837. private static readonly _AvailableFeatures;
  53838. private _features;
  53839. /**
  53840. * constructs a new features manages.
  53841. *
  53842. * @param _xrSessionManager an instance of WebXRSessionManager
  53843. */
  53844. constructor(_xrSessionManager: WebXRSessionManager);
  53845. /**
  53846. * Used to register a module. After calling this function a developer can use this feature in the scene.
  53847. * Mainly used internally.
  53848. *
  53849. * @param featureName the name of the feature to register
  53850. * @param constructorFunction the function used to construct the module
  53851. * @param version the (babylon) version of the module
  53852. * @param stable is that a stable version of this module
  53853. */
  53854. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  53855. /**
  53856. * Returns a constructor of a specific feature.
  53857. *
  53858. * @param featureName the name of the feature to construct
  53859. * @param version the version of the feature to load
  53860. * @param xrSessionManager the xrSessionManager. Used to construct the module
  53861. * @param options optional options provided to the module.
  53862. * @returns a function that, when called, will return a new instance of this feature
  53863. */
  53864. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  53865. /**
  53866. * Can be used to return the list of features currently registered
  53867. *
  53868. * @returns an Array of available features
  53869. */
  53870. static GetAvailableFeatures(): string[];
  53871. /**
  53872. * Gets the versions available for a specific feature
  53873. * @param featureName the name of the feature
  53874. * @returns an array with the available versions
  53875. */
  53876. static GetAvailableVersions(featureName: string): string[];
  53877. /**
  53878. * Return the latest unstable version of this feature
  53879. * @param featureName the name of the feature to search
  53880. * @returns the version number. if not found will return -1
  53881. */
  53882. static GetLatestVersionOfFeature(featureName: string): number;
  53883. /**
  53884. * Return the latest stable version of this feature
  53885. * @param featureName the name of the feature to search
  53886. * @returns the version number. if not found will return -1
  53887. */
  53888. static GetStableVersionOfFeature(featureName: string): number;
  53889. /**
  53890. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  53891. * Can be used during a session to start a feature
  53892. * @param featureName the name of feature to attach
  53893. */
  53894. attachFeature(featureName: string): void;
  53895. /**
  53896. * Can be used inside a session or when the session ends to detach a specific feature
  53897. * @param featureName the name of the feature to detach
  53898. */
  53899. detachFeature(featureName: string): void;
  53900. /**
  53901. * Used to disable an already-enabled feature
  53902. * The feature will be disposed and will be recreated once enabled.
  53903. * @param featureName the feature to disable
  53904. * @returns true if disable was successful
  53905. */
  53906. disableFeature(featureName: string | {
  53907. Name: string;
  53908. }): boolean;
  53909. /**
  53910. * dispose this features manager
  53911. */
  53912. dispose(): void;
  53913. /**
  53914. * 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.
  53915. * 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.
  53916. *
  53917. * @param featureName the name of the feature to load or the class of the feature
  53918. * @param version optional version to load. if not provided the latest version will be enabled
  53919. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  53920. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  53921. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  53922. * @returns a new constructed feature or throws an error if feature not found.
  53923. */
  53924. enableFeature(featureName: string | {
  53925. Name: string;
  53926. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  53927. /**
  53928. * get the implementation of an enabled feature.
  53929. * @param featureName the name of the feature to load
  53930. * @returns the feature class, if found
  53931. */
  53932. getEnabledFeature(featureName: string): IWebXRFeature;
  53933. /**
  53934. * Get the list of enabled features
  53935. * @returns an array of enabled features
  53936. */
  53937. getEnabledFeatures(): string[];
  53938. /**
  53939. * This function will extend the session creation configuration object with enabled features.
  53940. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53941. * according to the defined "required" variable, provided during enableFeature call
  53942. * @param xrSessionInit the xr Session init object to extend
  53943. *
  53944. * @returns an extended XRSessionInit object
  53945. */
  53946. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  53947. }
  53948. }
  53949. declare module BABYLON {
  53950. /**
  53951. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53952. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53953. */
  53954. export class WebXRExperienceHelper implements IDisposable {
  53955. private scene;
  53956. private _nonVRCamera;
  53957. private _originalSceneAutoClear;
  53958. private _supported;
  53959. /**
  53960. * Camera used to render xr content
  53961. */
  53962. camera: WebXRCamera;
  53963. /** A features manager for this xr session */
  53964. featuresManager: WebXRFeaturesManager;
  53965. /**
  53966. * Observers registered here will be triggered after the camera's initial transformation is set
  53967. * This can be used to set a different ground level or an extra rotation.
  53968. *
  53969. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53970. * to the position set after this observable is done executing.
  53971. */
  53972. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53973. /**
  53974. * Fires when the state of the experience helper has changed
  53975. */
  53976. onStateChangedObservable: Observable<WebXRState>;
  53977. /** Session manager used to keep track of xr session */
  53978. sessionManager: WebXRSessionManager;
  53979. /**
  53980. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53981. */
  53982. state: WebXRState;
  53983. /**
  53984. * Creates a WebXRExperienceHelper
  53985. * @param scene The scene the helper should be created in
  53986. */
  53987. private constructor();
  53988. /**
  53989. * Creates the experience helper
  53990. * @param scene the scene to attach the experience helper to
  53991. * @returns a promise for the experience helper
  53992. */
  53993. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53994. /**
  53995. * Disposes of the experience helper
  53996. */
  53997. dispose(): void;
  53998. /**
  53999. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  54000. * @param sessionMode options for the XR session
  54001. * @param referenceSpaceType frame of reference of the XR session
  54002. * @param renderTarget the output canvas that will be used to enter XR mode
  54003. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  54004. * @returns promise that resolves after xr mode has entered
  54005. */
  54006. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  54007. /**
  54008. * Exits XR mode and returns the scene to its original state
  54009. * @returns promise that resolves after xr mode has exited
  54010. */
  54011. exitXRAsync(): Promise<void>;
  54012. private _nonXRToXRCamera;
  54013. private _setState;
  54014. }
  54015. }
  54016. declare module BABYLON {
  54017. /**
  54018. * X-Y values for axes in WebXR
  54019. */
  54020. export interface IWebXRMotionControllerAxesValue {
  54021. /**
  54022. * The value of the x axis
  54023. */
  54024. x: number;
  54025. /**
  54026. * The value of the y-axis
  54027. */
  54028. y: number;
  54029. }
  54030. /**
  54031. * changed / previous values for the values of this component
  54032. */
  54033. export interface IWebXRMotionControllerComponentChangesValues<T> {
  54034. /**
  54035. * current (this frame) value
  54036. */
  54037. current: T;
  54038. /**
  54039. * previous (last change) value
  54040. */
  54041. previous: T;
  54042. }
  54043. /**
  54044. * Represents changes in the component between current frame and last values recorded
  54045. */
  54046. export interface IWebXRMotionControllerComponentChanges {
  54047. /**
  54048. * will be populated with previous and current values if axes changed
  54049. */
  54050. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54051. /**
  54052. * will be populated with previous and current values if pressed changed
  54053. */
  54054. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54055. /**
  54056. * will be populated with previous and current values if touched changed
  54057. */
  54058. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54059. /**
  54060. * will be populated with previous and current values if value changed
  54061. */
  54062. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54063. }
  54064. /**
  54065. * This class represents a single component (for example button or thumbstick) of a motion controller
  54066. */
  54067. export class WebXRControllerComponent implements IDisposable {
  54068. /**
  54069. * the id of this component
  54070. */
  54071. id: string;
  54072. /**
  54073. * the type of the component
  54074. */
  54075. type: MotionControllerComponentType;
  54076. private _buttonIndex;
  54077. private _axesIndices;
  54078. private _axes;
  54079. private _changes;
  54080. private _currentValue;
  54081. private _hasChanges;
  54082. private _pressed;
  54083. private _touched;
  54084. /**
  54085. * button component type
  54086. */
  54087. static BUTTON_TYPE: MotionControllerComponentType;
  54088. /**
  54089. * squeeze component type
  54090. */
  54091. static SQUEEZE_TYPE: MotionControllerComponentType;
  54092. /**
  54093. * Thumbstick component type
  54094. */
  54095. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54096. /**
  54097. * Touchpad component type
  54098. */
  54099. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54100. /**
  54101. * trigger component type
  54102. */
  54103. static TRIGGER_TYPE: MotionControllerComponentType;
  54104. /**
  54105. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54106. * the axes data changes
  54107. */
  54108. onAxisValueChangedObservable: Observable<{
  54109. x: number;
  54110. y: number;
  54111. }>;
  54112. /**
  54113. * Observers registered here will be triggered when the state of a button changes
  54114. * State change is either pressed / touched / value
  54115. */
  54116. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54117. /**
  54118. * Creates a new component for a motion controller.
  54119. * It is created by the motion controller itself
  54120. *
  54121. * @param id the id of this component
  54122. * @param type the type of the component
  54123. * @param _buttonIndex index in the buttons array of the gamepad
  54124. * @param _axesIndices indices of the values in the axes array of the gamepad
  54125. */
  54126. constructor(
  54127. /**
  54128. * the id of this component
  54129. */
  54130. id: string,
  54131. /**
  54132. * the type of the component
  54133. */
  54134. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54135. /**
  54136. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54137. */
  54138. get axes(): IWebXRMotionControllerAxesValue;
  54139. /**
  54140. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54141. */
  54142. get changes(): IWebXRMotionControllerComponentChanges;
  54143. /**
  54144. * Return whether or not the component changed the last frame
  54145. */
  54146. get hasChanges(): boolean;
  54147. /**
  54148. * is the button currently pressed
  54149. */
  54150. get pressed(): boolean;
  54151. /**
  54152. * is the button currently touched
  54153. */
  54154. get touched(): boolean;
  54155. /**
  54156. * Get the current value of this component
  54157. */
  54158. get value(): number;
  54159. /**
  54160. * Dispose this component
  54161. */
  54162. dispose(): void;
  54163. /**
  54164. * Are there axes correlating to this component
  54165. * @return true is axes data is available
  54166. */
  54167. isAxes(): boolean;
  54168. /**
  54169. * Is this component a button (hence - pressable)
  54170. * @returns true if can be pressed
  54171. */
  54172. isButton(): boolean;
  54173. /**
  54174. * update this component using the gamepad object it is in. Called on every frame
  54175. * @param nativeController the native gamepad controller object
  54176. */
  54177. update(nativeController: IMinimalMotionControllerObject): void;
  54178. }
  54179. }
  54180. declare module BABYLON {
  54181. /**
  54182. * Type used for the success callback of ImportMesh
  54183. */
  54184. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54185. /**
  54186. * Interface used for the result of ImportMeshAsync
  54187. */
  54188. export interface ISceneLoaderAsyncResult {
  54189. /**
  54190. * The array of loaded meshes
  54191. */
  54192. readonly meshes: AbstractMesh[];
  54193. /**
  54194. * The array of loaded particle systems
  54195. */
  54196. readonly particleSystems: IParticleSystem[];
  54197. /**
  54198. * The array of loaded skeletons
  54199. */
  54200. readonly skeletons: Skeleton[];
  54201. /**
  54202. * The array of loaded animation groups
  54203. */
  54204. readonly animationGroups: AnimationGroup[];
  54205. /**
  54206. * The array of loaded transform nodes
  54207. */
  54208. readonly transformNodes: TransformNode[];
  54209. /**
  54210. * The array of loaded geometries
  54211. */
  54212. readonly geometries: Geometry[];
  54213. /**
  54214. * The array of loaded lights
  54215. */
  54216. readonly lights: Light[];
  54217. }
  54218. /**
  54219. * Interface used to represent data loading progression
  54220. */
  54221. export interface ISceneLoaderProgressEvent {
  54222. /**
  54223. * Defines if data length to load can be evaluated
  54224. */
  54225. readonly lengthComputable: boolean;
  54226. /**
  54227. * Defines the loaded data length
  54228. */
  54229. readonly loaded: number;
  54230. /**
  54231. * Defines the data length to load
  54232. */
  54233. readonly total: number;
  54234. }
  54235. /**
  54236. * Interface used by SceneLoader plugins to define supported file extensions
  54237. */
  54238. export interface ISceneLoaderPluginExtensions {
  54239. /**
  54240. * Defines the list of supported extensions
  54241. */
  54242. [extension: string]: {
  54243. isBinary: boolean;
  54244. };
  54245. }
  54246. /**
  54247. * Interface used by SceneLoader plugin factory
  54248. */
  54249. export interface ISceneLoaderPluginFactory {
  54250. /**
  54251. * Defines the name of the factory
  54252. */
  54253. name: string;
  54254. /**
  54255. * Function called to create a new plugin
  54256. * @return the new plugin
  54257. */
  54258. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54259. /**
  54260. * The callback that returns true if the data can be directly loaded.
  54261. * @param data string containing the file data
  54262. * @returns if the data can be loaded directly
  54263. */
  54264. canDirectLoad?(data: string): boolean;
  54265. }
  54266. /**
  54267. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54268. */
  54269. export interface ISceneLoaderPluginBase {
  54270. /**
  54271. * The friendly name of this plugin.
  54272. */
  54273. name: string;
  54274. /**
  54275. * The file extensions supported by this plugin.
  54276. */
  54277. extensions: string | ISceneLoaderPluginExtensions;
  54278. /**
  54279. * The callback called when loading from a url.
  54280. * @param scene scene loading this url
  54281. * @param url url to load
  54282. * @param onSuccess callback called when the file successfully loads
  54283. * @param onProgress callback called while file is loading (if the server supports this mode)
  54284. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54285. * @param onError callback called when the file fails to load
  54286. * @returns a file request object
  54287. */
  54288. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54289. /**
  54290. * The callback called when loading from a file object.
  54291. * @param scene scene loading this file
  54292. * @param file defines the file to load
  54293. * @param onSuccess defines the callback to call when data is loaded
  54294. * @param onProgress defines the callback to call during loading process
  54295. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54296. * @param onError defines the callback to call when an error occurs
  54297. * @returns a file request object
  54298. */
  54299. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54300. /**
  54301. * The callback that returns true if the data can be directly loaded.
  54302. * @param data string containing the file data
  54303. * @returns if the data can be loaded directly
  54304. */
  54305. canDirectLoad?(data: string): boolean;
  54306. /**
  54307. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54308. * @param scene scene loading this data
  54309. * @param data string containing the data
  54310. * @returns data to pass to the plugin
  54311. */
  54312. directLoad?(scene: Scene, data: string): any;
  54313. /**
  54314. * The callback that allows custom handling of the root url based on the response url.
  54315. * @param rootUrl the original root url
  54316. * @param responseURL the response url if available
  54317. * @returns the new root url
  54318. */
  54319. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54320. }
  54321. /**
  54322. * Interface used to define a SceneLoader plugin
  54323. */
  54324. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54325. /**
  54326. * Import meshes into a scene.
  54327. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54328. * @param scene The scene to import into
  54329. * @param data The data to import
  54330. * @param rootUrl The root url for scene and resources
  54331. * @param meshes The meshes array to import into
  54332. * @param particleSystems The particle systems array to import into
  54333. * @param skeletons The skeletons array to import into
  54334. * @param onError The callback when import fails
  54335. * @returns True if successful or false otherwise
  54336. */
  54337. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54338. /**
  54339. * Load into a scene.
  54340. * @param scene The scene to load into
  54341. * @param data The data to import
  54342. * @param rootUrl The root url for scene and resources
  54343. * @param onError The callback when import fails
  54344. * @returns True if successful or false otherwise
  54345. */
  54346. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54347. /**
  54348. * Load into an asset container.
  54349. * @param scene The scene to load into
  54350. * @param data The data to import
  54351. * @param rootUrl The root url for scene and resources
  54352. * @param onError The callback when import fails
  54353. * @returns The loaded asset container
  54354. */
  54355. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54356. }
  54357. /**
  54358. * Interface used to define an async SceneLoader plugin
  54359. */
  54360. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54361. /**
  54362. * Import meshes into a scene.
  54363. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54364. * @param scene The scene to import into
  54365. * @param data The data to import
  54366. * @param rootUrl The root url for scene and resources
  54367. * @param onProgress The callback when the load progresses
  54368. * @param fileName Defines the name of the file to load
  54369. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54370. */
  54371. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54372. /**
  54373. * Load into a scene.
  54374. * @param scene The scene to load into
  54375. * @param data The data to import
  54376. * @param rootUrl The root url for scene and resources
  54377. * @param onProgress The callback when the load progresses
  54378. * @param fileName Defines the name of the file to load
  54379. * @returns Nothing
  54380. */
  54381. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54382. /**
  54383. * Load into an asset container.
  54384. * @param scene The scene to load into
  54385. * @param data The data to import
  54386. * @param rootUrl The root url for scene and resources
  54387. * @param onProgress The callback when the load progresses
  54388. * @param fileName Defines the name of the file to load
  54389. * @returns The loaded asset container
  54390. */
  54391. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54392. }
  54393. /**
  54394. * Mode that determines how to handle old animation groups before loading new ones.
  54395. */
  54396. export enum SceneLoaderAnimationGroupLoadingMode {
  54397. /**
  54398. * Reset all old animations to initial state then dispose them.
  54399. */
  54400. Clean = 0,
  54401. /**
  54402. * Stop all old animations.
  54403. */
  54404. Stop = 1,
  54405. /**
  54406. * Restart old animations from first frame.
  54407. */
  54408. Sync = 2,
  54409. /**
  54410. * Old animations remains untouched.
  54411. */
  54412. NoSync = 3
  54413. }
  54414. /**
  54415. * Defines a plugin registered by the SceneLoader
  54416. */
  54417. interface IRegisteredPlugin {
  54418. /**
  54419. * Defines the plugin to use
  54420. */
  54421. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54422. /**
  54423. * Defines if the plugin supports binary data
  54424. */
  54425. isBinary: boolean;
  54426. }
  54427. /**
  54428. * Class used to load scene from various file formats using registered plugins
  54429. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54430. */
  54431. export class SceneLoader {
  54432. /**
  54433. * No logging while loading
  54434. */
  54435. static readonly NO_LOGGING: number;
  54436. /**
  54437. * Minimal logging while loading
  54438. */
  54439. static readonly MINIMAL_LOGGING: number;
  54440. /**
  54441. * Summary logging while loading
  54442. */
  54443. static readonly SUMMARY_LOGGING: number;
  54444. /**
  54445. * Detailled logging while loading
  54446. */
  54447. static readonly DETAILED_LOGGING: number;
  54448. /**
  54449. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54450. */
  54451. static get ForceFullSceneLoadingForIncremental(): boolean;
  54452. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54453. /**
  54454. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54455. */
  54456. static get ShowLoadingScreen(): boolean;
  54457. static set ShowLoadingScreen(value: boolean);
  54458. /**
  54459. * Defines the current logging level (while loading the scene)
  54460. * @ignorenaming
  54461. */
  54462. static get loggingLevel(): number;
  54463. static set loggingLevel(value: number);
  54464. /**
  54465. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54466. */
  54467. static get CleanBoneMatrixWeights(): boolean;
  54468. static set CleanBoneMatrixWeights(value: boolean);
  54469. /**
  54470. * Event raised when a plugin is used to load a scene
  54471. */
  54472. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54473. private static _registeredPlugins;
  54474. private static _showingLoadingScreen;
  54475. /**
  54476. * Gets the default plugin (used to load Babylon files)
  54477. * @returns the .babylon plugin
  54478. */
  54479. static GetDefaultPlugin(): IRegisteredPlugin;
  54480. private static _GetPluginForExtension;
  54481. private static _GetPluginForDirectLoad;
  54482. private static _GetPluginForFilename;
  54483. private static _GetDirectLoad;
  54484. private static _LoadData;
  54485. private static _GetFileInfo;
  54486. /**
  54487. * Gets a plugin that can load the given extension
  54488. * @param extension defines the extension to load
  54489. * @returns a plugin or null if none works
  54490. */
  54491. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54492. /**
  54493. * Gets a boolean indicating that the given extension can be loaded
  54494. * @param extension defines the extension to load
  54495. * @returns true if the extension is supported
  54496. */
  54497. static IsPluginForExtensionAvailable(extension: string): boolean;
  54498. /**
  54499. * Adds a new plugin to the list of registered plugins
  54500. * @param plugin defines the plugin to add
  54501. */
  54502. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54503. /**
  54504. * Import meshes into a scene
  54505. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54506. * @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)
  54507. * @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)
  54508. * @param scene the instance of BABYLON.Scene to append to
  54509. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54510. * @param onProgress a callback with a progress event for each file being loaded
  54511. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54512. * @param pluginExtension the extension used to determine the plugin
  54513. * @returns The loaded plugin
  54514. */
  54515. 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>;
  54516. /**
  54517. * Import meshes into a scene
  54518. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54519. * @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)
  54520. * @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)
  54521. * @param scene the instance of BABYLON.Scene to append to
  54522. * @param onProgress a callback with a progress event for each file being loaded
  54523. * @param pluginExtension the extension used to determine the plugin
  54524. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54525. */
  54526. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54527. /**
  54528. * Load a scene
  54529. * @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)
  54530. * @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)
  54531. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54532. * @param onSuccess a callback with the scene when import succeeds
  54533. * @param onProgress a callback with a progress event for each file being loaded
  54534. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54535. * @param pluginExtension the extension used to determine the plugin
  54536. * @returns The loaded plugin
  54537. */
  54538. 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>;
  54539. /**
  54540. * Load a scene
  54541. * @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)
  54542. * @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)
  54543. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54544. * @param onProgress a callback with a progress event for each file being loaded
  54545. * @param pluginExtension the extension used to determine the plugin
  54546. * @returns The loaded scene
  54547. */
  54548. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54549. /**
  54550. * Append a scene
  54551. * @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)
  54552. * @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)
  54553. * @param scene is the instance of BABYLON.Scene to append to
  54554. * @param onSuccess a callback with the scene when import succeeds
  54555. * @param onProgress a callback with a progress event for each file being loaded
  54556. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54557. * @param pluginExtension the extension used to determine the plugin
  54558. * @returns The loaded plugin
  54559. */
  54560. 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>;
  54561. /**
  54562. * Append a scene
  54563. * @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)
  54564. * @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)
  54565. * @param scene is the instance of BABYLON.Scene to append to
  54566. * @param onProgress a callback with a progress event for each file being loaded
  54567. * @param pluginExtension the extension used to determine the plugin
  54568. * @returns The given scene
  54569. */
  54570. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54571. /**
  54572. * Load a scene into an asset container
  54573. * @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)
  54574. * @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)
  54575. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54576. * @param onSuccess a callback with the scene when import succeeds
  54577. * @param onProgress a callback with a progress event for each file being loaded
  54578. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54579. * @param pluginExtension the extension used to determine the plugin
  54580. * @returns The loaded plugin
  54581. */
  54582. 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>;
  54583. /**
  54584. * Load a scene into an asset container
  54585. * @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)
  54586. * @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)
  54587. * @param scene is the instance of Scene to append to
  54588. * @param onProgress a callback with a progress event for each file being loaded
  54589. * @param pluginExtension the extension used to determine the plugin
  54590. * @returns The loaded asset container
  54591. */
  54592. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54593. /**
  54594. * Import animations from a file into a scene
  54595. * @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)
  54596. * @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)
  54597. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54598. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54599. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54600. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54601. * @param onSuccess a callback with the scene when import succeeds
  54602. * @param onProgress a callback with a progress event for each file being loaded
  54603. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54604. * @param pluginExtension the extension used to determine the plugin
  54605. */
  54606. 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;
  54607. /**
  54608. * Import animations from a file into a scene
  54609. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  54610. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  54611. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54612. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54613. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54614. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54615. * @param onSuccess a callback with the scene when import succeeds
  54616. * @param onProgress a callback with a progress event for each file being loaded
  54617. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54618. * @param pluginExtension the extension used to determine the plugin
  54619. * @returns the updated scene with imported animations
  54620. */
  54621. 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>;
  54622. }
  54623. }
  54624. declare module BABYLON {
  54625. /**
  54626. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54627. */
  54628. export type MotionControllerHandedness = "none" | "left" | "right";
  54629. /**
  54630. * The type of components available in motion controllers.
  54631. * This is not the name of the component.
  54632. */
  54633. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54634. /**
  54635. * The state of a controller component
  54636. */
  54637. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54638. /**
  54639. * The schema of motion controller layout.
  54640. * No object will be initialized using this interface
  54641. * This is used just to define the profile.
  54642. */
  54643. export interface IMotionControllerLayout {
  54644. /**
  54645. * Path to load the assets. Usually relative to the base path
  54646. */
  54647. assetPath: string;
  54648. /**
  54649. * Available components (unsorted)
  54650. */
  54651. components: {
  54652. /**
  54653. * A map of component Ids
  54654. */
  54655. [componentId: string]: {
  54656. /**
  54657. * The type of input the component outputs
  54658. */
  54659. type: MotionControllerComponentType;
  54660. /**
  54661. * The indices of this component in the gamepad object
  54662. */
  54663. gamepadIndices: {
  54664. /**
  54665. * Index of button
  54666. */
  54667. button?: number;
  54668. /**
  54669. * If available, index of x-axis
  54670. */
  54671. xAxis?: number;
  54672. /**
  54673. * If available, index of y-axis
  54674. */
  54675. yAxis?: number;
  54676. };
  54677. /**
  54678. * The mesh's root node name
  54679. */
  54680. rootNodeName: string;
  54681. /**
  54682. * Animation definitions for this model
  54683. */
  54684. visualResponses: {
  54685. [stateKey: string]: {
  54686. /**
  54687. * What property will be animated
  54688. */
  54689. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54690. /**
  54691. * What states influence this visual response
  54692. */
  54693. states: MotionControllerComponentStateType[];
  54694. /**
  54695. * Type of animation - movement or visibility
  54696. */
  54697. valueNodeProperty: "transform" | "visibility";
  54698. /**
  54699. * Base node name to move. Its position will be calculated according to the min and max nodes
  54700. */
  54701. valueNodeName?: string;
  54702. /**
  54703. * Minimum movement node
  54704. */
  54705. minNodeName?: string;
  54706. /**
  54707. * Max movement node
  54708. */
  54709. maxNodeName?: string;
  54710. };
  54711. };
  54712. /**
  54713. * If touch enabled, what is the name of node to display user feedback
  54714. */
  54715. touchPointNodeName?: string;
  54716. };
  54717. };
  54718. /**
  54719. * Is it xr standard mapping or not
  54720. */
  54721. gamepadMapping: "" | "xr-standard";
  54722. /**
  54723. * Base root node of this entire model
  54724. */
  54725. rootNodeName: string;
  54726. /**
  54727. * Defines the main button component id
  54728. */
  54729. selectComponentId: string;
  54730. }
  54731. /**
  54732. * A definition for the layout map in the input profile
  54733. */
  54734. export interface IMotionControllerLayoutMap {
  54735. /**
  54736. * Layouts with handedness type as a key
  54737. */
  54738. [handedness: string]: IMotionControllerLayout;
  54739. }
  54740. /**
  54741. * The XR Input profile schema
  54742. * Profiles can be found here:
  54743. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  54744. */
  54745. export interface IMotionControllerProfile {
  54746. /**
  54747. * fallback profiles for this profileId
  54748. */
  54749. fallbackProfileIds: string[];
  54750. /**
  54751. * The layout map, with handedness as key
  54752. */
  54753. layouts: IMotionControllerLayoutMap;
  54754. /**
  54755. * The id of this profile
  54756. * correlates to the profile(s) in the xrInput.profiles array
  54757. */
  54758. profileId: string;
  54759. }
  54760. /**
  54761. * A helper-interface for the 3 meshes needed for controller button animation
  54762. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  54763. */
  54764. export interface IMotionControllerButtonMeshMap {
  54765. /**
  54766. * the mesh that defines the pressed value mesh position.
  54767. * This is used to find the max-position of this button
  54768. */
  54769. pressedMesh: AbstractMesh;
  54770. /**
  54771. * the mesh that defines the unpressed value mesh position.
  54772. * This is used to find the min (or initial) position of this button
  54773. */
  54774. unpressedMesh: AbstractMesh;
  54775. /**
  54776. * The mesh that will be changed when value changes
  54777. */
  54778. valueMesh: AbstractMesh;
  54779. }
  54780. /**
  54781. * A helper-interface for the 3 meshes needed for controller axis animation.
  54782. * This will be expanded when touchpad animations are fully supported
  54783. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  54784. */
  54785. export interface IMotionControllerMeshMap {
  54786. /**
  54787. * the mesh that defines the maximum value mesh position.
  54788. */
  54789. maxMesh?: AbstractMesh;
  54790. /**
  54791. * the mesh that defines the minimum value mesh position.
  54792. */
  54793. minMesh?: AbstractMesh;
  54794. /**
  54795. * The mesh that will be changed when axis value changes
  54796. */
  54797. valueMesh?: AbstractMesh;
  54798. }
  54799. /**
  54800. * The elements needed for change-detection of the gamepad objects in motion controllers
  54801. */
  54802. export interface IMinimalMotionControllerObject {
  54803. /**
  54804. * Available axes of this controller
  54805. */
  54806. axes: number[];
  54807. /**
  54808. * An array of available buttons
  54809. */
  54810. buttons: Array<{
  54811. /**
  54812. * Value of the button/trigger
  54813. */
  54814. value: number;
  54815. /**
  54816. * If the button/trigger is currently touched
  54817. */
  54818. touched: boolean;
  54819. /**
  54820. * If the button/trigger is currently pressed
  54821. */
  54822. pressed: boolean;
  54823. }>;
  54824. /**
  54825. * EXPERIMENTAL haptic support.
  54826. */
  54827. hapticActuators?: Array<{
  54828. pulse: (value: number, duration: number) => Promise<boolean>;
  54829. }>;
  54830. }
  54831. /**
  54832. * An Abstract Motion controller
  54833. * This class receives an xrInput and a profile layout and uses those to initialize the components
  54834. * Each component has an observable to check for changes in value and state
  54835. */
  54836. export abstract class WebXRAbstractMotionController implements IDisposable {
  54837. protected scene: Scene;
  54838. protected layout: IMotionControllerLayout;
  54839. /**
  54840. * The gamepad object correlating to this controller
  54841. */
  54842. gamepadObject: IMinimalMotionControllerObject;
  54843. /**
  54844. * handedness (left/right/none) of this controller
  54845. */
  54846. handedness: MotionControllerHandedness;
  54847. private _initComponent;
  54848. private _modelReady;
  54849. /**
  54850. * A map of components (WebXRControllerComponent) in this motion controller
  54851. * Components have a ComponentType and can also have both button and axis definitions
  54852. */
  54853. readonly components: {
  54854. [id: string]: WebXRControllerComponent;
  54855. };
  54856. /**
  54857. * Disable the model's animation. Can be set at any time.
  54858. */
  54859. disableAnimation: boolean;
  54860. /**
  54861. * Observers registered here will be triggered when the model of this controller is done loading
  54862. */
  54863. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  54864. /**
  54865. * The profile id of this motion controller
  54866. */
  54867. abstract profileId: string;
  54868. /**
  54869. * The root mesh of the model. It is null if the model was not yet initialized
  54870. */
  54871. rootMesh: Nullable<AbstractMesh>;
  54872. /**
  54873. * constructs a new abstract motion controller
  54874. * @param scene the scene to which the model of the controller will be added
  54875. * @param layout The profile layout to load
  54876. * @param gamepadObject The gamepad object correlating to this controller
  54877. * @param handedness handedness (left/right/none) of this controller
  54878. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  54879. */
  54880. constructor(scene: Scene, layout: IMotionControllerLayout,
  54881. /**
  54882. * The gamepad object correlating to this controller
  54883. */
  54884. gamepadObject: IMinimalMotionControllerObject,
  54885. /**
  54886. * handedness (left/right/none) of this controller
  54887. */
  54888. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  54889. /**
  54890. * Dispose this controller, the model mesh and all its components
  54891. */
  54892. dispose(): void;
  54893. /**
  54894. * Returns all components of specific type
  54895. * @param type the type to search for
  54896. * @return an array of components with this type
  54897. */
  54898. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  54899. /**
  54900. * get a component based an its component id as defined in layout.components
  54901. * @param id the id of the component
  54902. * @returns the component correlates to the id or undefined if not found
  54903. */
  54904. getComponent(id: string): WebXRControllerComponent;
  54905. /**
  54906. * Get the list of components available in this motion controller
  54907. * @returns an array of strings correlating to available components
  54908. */
  54909. getComponentIds(): string[];
  54910. /**
  54911. * Get the first component of specific type
  54912. * @param type type of component to find
  54913. * @return a controller component or null if not found
  54914. */
  54915. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54916. /**
  54917. * Get the main (Select) component of this controller as defined in the layout
  54918. * @returns the main component of this controller
  54919. */
  54920. getMainComponent(): WebXRControllerComponent;
  54921. /**
  54922. * Loads the model correlating to this controller
  54923. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54924. * @returns A promise fulfilled with the result of the model loading
  54925. */
  54926. loadModel(): Promise<boolean>;
  54927. /**
  54928. * Update this model using the current XRFrame
  54929. * @param xrFrame the current xr frame to use and update the model
  54930. */
  54931. updateFromXRFrame(xrFrame: XRFrame): void;
  54932. /**
  54933. * Backwards compatibility due to a deeply-integrated typo
  54934. */
  54935. get handness(): XREye;
  54936. /**
  54937. * Pulse (vibrate) this controller
  54938. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54939. * Consecutive calls to this function will cancel the last pulse call
  54940. *
  54941. * @param value the strength of the pulse in 0.0...1.0 range
  54942. * @param duration Duration of the pulse in milliseconds
  54943. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54944. * @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
  54945. */
  54946. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54947. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54948. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54949. /**
  54950. * Moves the axis on the controller mesh based on its current state
  54951. * @param axis the index of the axis
  54952. * @param axisValue the value of the axis which determines the meshes new position
  54953. * @hidden
  54954. */
  54955. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54956. /**
  54957. * Update the model itself with the current frame data
  54958. * @param xrFrame the frame to use for updating the model mesh
  54959. */
  54960. protected updateModel(xrFrame: XRFrame): void;
  54961. /**
  54962. * Get the filename and path for this controller's model
  54963. * @returns a map of filename and path
  54964. */
  54965. protected abstract _getFilenameAndPath(): {
  54966. filename: string;
  54967. path: string;
  54968. };
  54969. /**
  54970. * This function is called before the mesh is loaded. It checks for loading constraints.
  54971. * For example, this function can check if the GLB loader is available
  54972. * If this function returns false, the generic controller will be loaded instead
  54973. * @returns Is the client ready to load the mesh
  54974. */
  54975. protected abstract _getModelLoadingConstraints(): boolean;
  54976. /**
  54977. * This function will be called after the model was successfully loaded and can be used
  54978. * for mesh transformations before it is available for the user
  54979. * @param meshes the loaded meshes
  54980. */
  54981. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54982. /**
  54983. * Set the root mesh for this controller. Important for the WebXR controller class
  54984. * @param meshes the loaded meshes
  54985. */
  54986. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54987. /**
  54988. * A function executed each frame that updates the mesh (if needed)
  54989. * @param xrFrame the current xrFrame
  54990. */
  54991. protected abstract _updateModel(xrFrame: XRFrame): void;
  54992. private _getGenericFilenameAndPath;
  54993. private _getGenericParentMesh;
  54994. }
  54995. }
  54996. declare module BABYLON {
  54997. /**
  54998. * A generic trigger-only motion controller for WebXR
  54999. */
  55000. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  55001. /**
  55002. * Static version of the profile id of this controller
  55003. */
  55004. static ProfileId: string;
  55005. profileId: string;
  55006. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  55007. protected _getFilenameAndPath(): {
  55008. filename: string;
  55009. path: string;
  55010. };
  55011. protected _getModelLoadingConstraints(): boolean;
  55012. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  55013. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55014. protected _updateModel(): void;
  55015. }
  55016. }
  55017. declare module BABYLON {
  55018. /**
  55019. * Class containing static functions to help procedurally build meshes
  55020. */
  55021. export class SphereBuilder {
  55022. /**
  55023. * Creates a sphere mesh
  55024. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55025. * * 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`)
  55026. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55027. * * 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
  55028. * * 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)
  55029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55030. * * 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
  55031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55032. * @param name defines the name of the mesh
  55033. * @param options defines the options used to create the mesh
  55034. * @param scene defines the hosting scene
  55035. * @returns the sphere mesh
  55036. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55037. */
  55038. static CreateSphere(name: string, options: {
  55039. segments?: number;
  55040. diameter?: number;
  55041. diameterX?: number;
  55042. diameterY?: number;
  55043. diameterZ?: number;
  55044. arc?: number;
  55045. slice?: number;
  55046. sideOrientation?: number;
  55047. frontUVs?: Vector4;
  55048. backUVs?: Vector4;
  55049. updatable?: boolean;
  55050. }, scene?: Nullable<Scene>): Mesh;
  55051. }
  55052. }
  55053. declare module BABYLON {
  55054. /**
  55055. * A profiled motion controller has its profile loaded from an online repository.
  55056. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55057. */
  55058. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55059. private _repositoryUrl;
  55060. private _buttonMeshMapping;
  55061. private _touchDots;
  55062. /**
  55063. * The profile ID of this controller. Will be populated when the controller initializes.
  55064. */
  55065. profileId: string;
  55066. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55067. dispose(): void;
  55068. protected _getFilenameAndPath(): {
  55069. filename: string;
  55070. path: string;
  55071. };
  55072. protected _getModelLoadingConstraints(): boolean;
  55073. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55074. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55075. protected _updateModel(_xrFrame: XRFrame): void;
  55076. }
  55077. }
  55078. declare module BABYLON {
  55079. /**
  55080. * A construction function type to create a new controller based on an xrInput object
  55081. */
  55082. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55083. /**
  55084. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55085. *
  55086. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55087. * it should be replaced with auto-loaded controllers.
  55088. *
  55089. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55090. */
  55091. export class WebXRMotionControllerManager {
  55092. private static _AvailableControllers;
  55093. private static _Fallbacks;
  55094. private static _ProfileLoadingPromises;
  55095. private static _ProfilesList;
  55096. /**
  55097. * The base URL of the online controller repository. Can be changed at any time.
  55098. */
  55099. static BaseRepositoryUrl: string;
  55100. /**
  55101. * Which repository gets priority - local or online
  55102. */
  55103. static PrioritizeOnlineRepository: boolean;
  55104. /**
  55105. * Use the online repository, or use only locally-defined controllers
  55106. */
  55107. static UseOnlineRepository: boolean;
  55108. /**
  55109. * Clear the cache used for profile loading and reload when requested again
  55110. */
  55111. static ClearProfilesCache(): void;
  55112. /**
  55113. * Register the default fallbacks.
  55114. * This function is called automatically when this file is imported.
  55115. */
  55116. static DefaultFallbacks(): void;
  55117. /**
  55118. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55119. * @param profileId the profile to which a fallback needs to be found
  55120. * @return an array with corresponding fallback profiles
  55121. */
  55122. static FindFallbackWithProfileId(profileId: string): string[];
  55123. /**
  55124. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55125. * The order of search:
  55126. *
  55127. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55128. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55129. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55130. * 4) return the generic trigger controller if none were found
  55131. *
  55132. * @param xrInput the xrInput to which a new controller is initialized
  55133. * @param scene the scene to which the model will be added
  55134. * @param forceProfile force a certain profile for this controller
  55135. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55136. */
  55137. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55138. /**
  55139. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55140. *
  55141. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55142. *
  55143. * @param type the profile type to register
  55144. * @param constructFunction the function to be called when loading this profile
  55145. */
  55146. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55147. /**
  55148. * Register a fallback to a specific profile.
  55149. * @param profileId the profileId that will receive the fallbacks
  55150. * @param fallbacks A list of fallback profiles
  55151. */
  55152. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55153. /**
  55154. * Will update the list of profiles available in the repository
  55155. * @return a promise that resolves to a map of profiles available online
  55156. */
  55157. static UpdateProfilesList(): Promise<{
  55158. [profile: string]: string;
  55159. }>;
  55160. private static _LoadProfileFromRepository;
  55161. private static _LoadProfilesFromAvailableControllers;
  55162. }
  55163. }
  55164. declare module BABYLON {
  55165. /**
  55166. * Configuration options for the WebXR controller creation
  55167. */
  55168. export interface IWebXRControllerOptions {
  55169. /**
  55170. * Should the controller mesh be animated when a user interacts with it
  55171. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55172. */
  55173. disableMotionControllerAnimation?: boolean;
  55174. /**
  55175. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55176. */
  55177. doNotLoadControllerMesh?: boolean;
  55178. /**
  55179. * Force a specific controller type for this controller.
  55180. * This can be used when creating your own profile or when testing different controllers
  55181. */
  55182. forceControllerProfile?: string;
  55183. /**
  55184. * Defines a rendering group ID for meshes that will be loaded.
  55185. * This is for the default controllers only.
  55186. */
  55187. renderingGroupId?: number;
  55188. }
  55189. /**
  55190. * Represents an XR controller
  55191. */
  55192. export class WebXRInputSource {
  55193. private _scene;
  55194. /** The underlying input source for the controller */
  55195. inputSource: XRInputSource;
  55196. private _options;
  55197. private _tmpVector;
  55198. private _uniqueId;
  55199. private _disposed;
  55200. /**
  55201. * 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
  55202. */
  55203. grip?: AbstractMesh;
  55204. /**
  55205. * If available, this is the gamepad object related to this controller.
  55206. * Using this object it is possible to get click events and trackpad changes of the
  55207. * webxr controller that is currently being used.
  55208. */
  55209. motionController?: WebXRAbstractMotionController;
  55210. /**
  55211. * Event that fires when the controller is removed/disposed.
  55212. * The object provided as event data is this controller, after associated assets were disposed.
  55213. * uniqueId is still available.
  55214. */
  55215. onDisposeObservable: Observable<WebXRInputSource>;
  55216. /**
  55217. * Will be triggered when the mesh associated with the motion controller is done loading.
  55218. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55219. * A shortened version of controller -> motion controller -> on mesh loaded.
  55220. */
  55221. onMeshLoadedObservable: Observable<AbstractMesh>;
  55222. /**
  55223. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55224. */
  55225. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55226. /**
  55227. * Pointer which can be used to select objects or attach a visible laser to
  55228. */
  55229. pointer: AbstractMesh;
  55230. /**
  55231. * Creates the input source object
  55232. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55233. * @param _scene the scene which the controller should be associated to
  55234. * @param inputSource the underlying input source for the controller
  55235. * @param _options options for this controller creation
  55236. */
  55237. constructor(_scene: Scene,
  55238. /** The underlying input source for the controller */
  55239. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55240. /**
  55241. * Get this controllers unique id
  55242. */
  55243. get uniqueId(): string;
  55244. /**
  55245. * Disposes of the object
  55246. */
  55247. dispose(): void;
  55248. /**
  55249. * Gets a world space ray coming from the pointer or grip
  55250. * @param result the resulting ray
  55251. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55252. */
  55253. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55254. /**
  55255. * Updates the controller pose based on the given XRFrame
  55256. * @param xrFrame xr frame to update the pose with
  55257. * @param referenceSpace reference space to use
  55258. */
  55259. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55260. }
  55261. }
  55262. declare module BABYLON {
  55263. /**
  55264. * The schema for initialization options of the XR Input class
  55265. */
  55266. export interface IWebXRInputOptions {
  55267. /**
  55268. * If set to true no model will be automatically loaded
  55269. */
  55270. doNotLoadControllerMeshes?: boolean;
  55271. /**
  55272. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55273. * If not found, the xr input profile data will be used.
  55274. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55275. */
  55276. forceInputProfile?: string;
  55277. /**
  55278. * Do not send a request to the controller repository to load the profile.
  55279. *
  55280. * Instead, use the controllers available in babylon itself.
  55281. */
  55282. disableOnlineControllerRepository?: boolean;
  55283. /**
  55284. * A custom URL for the controllers repository
  55285. */
  55286. customControllersRepositoryURL?: string;
  55287. /**
  55288. * Should the controller model's components not move according to the user input
  55289. */
  55290. disableControllerAnimation?: boolean;
  55291. /**
  55292. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55293. */
  55294. controllerOptions?: IWebXRControllerOptions;
  55295. }
  55296. /**
  55297. * XR input used to track XR inputs such as controllers/rays
  55298. */
  55299. export class WebXRInput implements IDisposable {
  55300. /**
  55301. * the xr session manager for this session
  55302. */
  55303. xrSessionManager: WebXRSessionManager;
  55304. /**
  55305. * the WebXR camera for this session. Mainly used for teleportation
  55306. */
  55307. xrCamera: WebXRCamera;
  55308. private readonly options;
  55309. /**
  55310. * XR controllers being tracked
  55311. */
  55312. controllers: Array<WebXRInputSource>;
  55313. private _frameObserver;
  55314. private _sessionEndedObserver;
  55315. private _sessionInitObserver;
  55316. /**
  55317. * Event when a controller has been connected/added
  55318. */
  55319. onControllerAddedObservable: Observable<WebXRInputSource>;
  55320. /**
  55321. * Event when a controller has been removed/disconnected
  55322. */
  55323. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55324. /**
  55325. * Initializes the WebXRInput
  55326. * @param xrSessionManager the xr session manager for this session
  55327. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55328. * @param options = initialization options for this xr input
  55329. */
  55330. constructor(
  55331. /**
  55332. * the xr session manager for this session
  55333. */
  55334. xrSessionManager: WebXRSessionManager,
  55335. /**
  55336. * the WebXR camera for this session. Mainly used for teleportation
  55337. */
  55338. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55339. private _onInputSourcesChange;
  55340. private _addAndRemoveControllers;
  55341. /**
  55342. * Disposes of the object
  55343. */
  55344. dispose(): void;
  55345. }
  55346. }
  55347. declare module BABYLON {
  55348. /**
  55349. * This is the base class for all WebXR features.
  55350. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55351. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55352. */
  55353. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55354. protected _xrSessionManager: WebXRSessionManager;
  55355. private _attached;
  55356. private _removeOnDetach;
  55357. /**
  55358. * Is this feature disposed?
  55359. */
  55360. isDisposed: boolean;
  55361. /**
  55362. * Should auto-attach be disabled?
  55363. */
  55364. disableAutoAttach: boolean;
  55365. /**
  55366. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55367. */
  55368. xrNativeFeatureName: string;
  55369. /**
  55370. * Construct a new (abstract) WebXR feature
  55371. * @param _xrSessionManager the xr session manager for this feature
  55372. */
  55373. constructor(_xrSessionManager: WebXRSessionManager);
  55374. /**
  55375. * Is this feature attached
  55376. */
  55377. get attached(): boolean;
  55378. /**
  55379. * attach this feature
  55380. *
  55381. * @param force should attachment be forced (even when already attached)
  55382. * @returns true if successful, false is failed or already attached
  55383. */
  55384. attach(force?: boolean): boolean;
  55385. /**
  55386. * detach this feature.
  55387. *
  55388. * @returns true if successful, false if failed or already detached
  55389. */
  55390. detach(): boolean;
  55391. /**
  55392. * Dispose this feature and all of the resources attached
  55393. */
  55394. dispose(): void;
  55395. /**
  55396. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55397. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55398. *
  55399. * @returns whether or not the feature is compatible in this environment
  55400. */
  55401. isCompatible(): boolean;
  55402. /**
  55403. * This is used to register callbacks that will automatically be removed when detach is called.
  55404. * @param observable the observable to which the observer will be attached
  55405. * @param callback the callback to register
  55406. */
  55407. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55408. /**
  55409. * Code in this function will be executed on each xrFrame received from the browser.
  55410. * This function will not execute after the feature is detached.
  55411. * @param _xrFrame the current frame
  55412. */
  55413. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55414. }
  55415. }
  55416. declare module BABYLON {
  55417. /**
  55418. * Renders a layer on top of an existing scene
  55419. */
  55420. export class UtilityLayerRenderer implements IDisposable {
  55421. /** the original scene that will be rendered on top of */
  55422. originalScene: Scene;
  55423. private _pointerCaptures;
  55424. private _lastPointerEvents;
  55425. private static _DefaultUtilityLayer;
  55426. private static _DefaultKeepDepthUtilityLayer;
  55427. private _sharedGizmoLight;
  55428. private _renderCamera;
  55429. /**
  55430. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55431. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55432. * @returns the camera that is used when rendering the utility layer
  55433. */
  55434. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55435. /**
  55436. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55437. * @param cam the camera that should be used when rendering the utility layer
  55438. */
  55439. setRenderCamera(cam: Nullable<Camera>): void;
  55440. /**
  55441. * @hidden
  55442. * Light which used by gizmos to get light shading
  55443. */
  55444. _getSharedGizmoLight(): HemisphericLight;
  55445. /**
  55446. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55447. */
  55448. pickUtilitySceneFirst: boolean;
  55449. /**
  55450. * 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)
  55451. */
  55452. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55453. /**
  55454. * 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)
  55455. */
  55456. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55457. /**
  55458. * The scene that is rendered on top of the original scene
  55459. */
  55460. utilityLayerScene: Scene;
  55461. /**
  55462. * If the utility layer should automatically be rendered on top of existing scene
  55463. */
  55464. shouldRender: boolean;
  55465. /**
  55466. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55467. */
  55468. onlyCheckPointerDownEvents: boolean;
  55469. /**
  55470. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55471. */
  55472. processAllEvents: boolean;
  55473. /**
  55474. * Observable raised when the pointer move from the utility layer scene to the main scene
  55475. */
  55476. onPointerOutObservable: Observable<number>;
  55477. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55478. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55479. private _afterRenderObserver;
  55480. private _sceneDisposeObserver;
  55481. private _originalPointerObserver;
  55482. /**
  55483. * Instantiates a UtilityLayerRenderer
  55484. * @param originalScene the original scene that will be rendered on top of
  55485. * @param handleEvents boolean indicating if the utility layer should handle events
  55486. */
  55487. constructor(
  55488. /** the original scene that will be rendered on top of */
  55489. originalScene: Scene, handleEvents?: boolean);
  55490. private _notifyObservers;
  55491. /**
  55492. * Renders the utility layers scene on top of the original scene
  55493. */
  55494. render(): void;
  55495. /**
  55496. * Disposes of the renderer
  55497. */
  55498. dispose(): void;
  55499. private _updateCamera;
  55500. }
  55501. }
  55502. declare module BABYLON {
  55503. /**
  55504. * Options interface for the pointer selection module
  55505. */
  55506. export interface IWebXRControllerPointerSelectionOptions {
  55507. /**
  55508. * if provided, this scene will be used to render meshes.
  55509. */
  55510. customUtilityLayerScene?: Scene;
  55511. /**
  55512. * 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)
  55513. * If not disabled, the last picked point will be used to execute a pointer up event
  55514. * If disabled, pointer up event will be triggered right after the pointer down event.
  55515. * Used in screen and gaze target ray mode only
  55516. */
  55517. disablePointerUpOnTouchOut: boolean;
  55518. /**
  55519. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55520. */
  55521. forceGazeMode: boolean;
  55522. /**
  55523. * 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
  55524. * to start a new countdown to the pointer down event.
  55525. * Defaults to 1.
  55526. */
  55527. gazeModePointerMovedFactor?: number;
  55528. /**
  55529. * Different button type to use instead of the main component
  55530. */
  55531. overrideButtonId?: string;
  55532. /**
  55533. * use this rendering group id for the meshes (optional)
  55534. */
  55535. renderingGroupId?: number;
  55536. /**
  55537. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55538. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55539. * 3000 means 3 seconds between pointing at something and selecting it
  55540. */
  55541. timeToSelect?: number;
  55542. /**
  55543. * Should meshes created here be added to a utility layer or the main scene
  55544. */
  55545. useUtilityLayer?: boolean;
  55546. /**
  55547. * Optional WebXR camera to be used for gaze selection
  55548. */
  55549. gazeCamera?: WebXRCamera;
  55550. /**
  55551. * the xr input to use with this pointer selection
  55552. */
  55553. xrInput: WebXRInput;
  55554. /**
  55555. * Should the scene pointerX and pointerY update be disabled
  55556. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55557. * Disable in VR, if not needed.
  55558. * The first rig camera (left eye) will be used to calculate the projection
  55559. */
  55560. disableScenePointerVectorUpdate: boolean;
  55561. /**
  55562. * Enable pointer selection on all controllers instead of switching between them
  55563. */
  55564. enablePointerSelectionOnAllControllers?: boolean;
  55565. /**
  55566. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55567. * If switch is enabled, it will still allow the user to switch between the different controllers
  55568. */
  55569. preferredHandedness?: XRHandedness;
  55570. /**
  55571. * Disable switching the pointer selection from one controller to the other.
  55572. * 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
  55573. */
  55574. disableSwitchOnClick?: boolean;
  55575. /**
  55576. * The maximum distance of the pointer selection feature. Defaults to 100.
  55577. */
  55578. maxPointerDistance?: number;
  55579. }
  55580. /**
  55581. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55582. */
  55583. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55584. private readonly _options;
  55585. private static _idCounter;
  55586. private _attachController;
  55587. private _controllers;
  55588. private _scene;
  55589. private _tmpVectorForPickCompare;
  55590. private _attachedController;
  55591. /**
  55592. * The module's name
  55593. */
  55594. static readonly Name: string;
  55595. /**
  55596. * The (Babylon) version of this module.
  55597. * This is an integer representing the implementation version.
  55598. * This number does not correspond to the WebXR specs version
  55599. */
  55600. static readonly Version: number;
  55601. /**
  55602. * Disable lighting on the laser pointer (so it will always be visible)
  55603. */
  55604. disablePointerLighting: boolean;
  55605. /**
  55606. * Disable lighting on the selection mesh (so it will always be visible)
  55607. */
  55608. disableSelectionMeshLighting: boolean;
  55609. /**
  55610. * Should the laser pointer be displayed
  55611. */
  55612. displayLaserPointer: boolean;
  55613. /**
  55614. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55615. */
  55616. displaySelectionMesh: boolean;
  55617. /**
  55618. * This color will be set to the laser pointer when selection is triggered
  55619. */
  55620. laserPointerPickedColor: Color3;
  55621. /**
  55622. * Default color of the laser pointer
  55623. */
  55624. laserPointerDefaultColor: Color3;
  55625. /**
  55626. * default color of the selection ring
  55627. */
  55628. selectionMeshDefaultColor: Color3;
  55629. /**
  55630. * This color will be applied to the selection ring when selection is triggered
  55631. */
  55632. selectionMeshPickedColor: Color3;
  55633. /**
  55634. * Optional filter to be used for ray selection. This predicate shares behavior with
  55635. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55636. */
  55637. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55638. /**
  55639. * constructs a new background remover module
  55640. * @param _xrSessionManager the session manager for this module
  55641. * @param _options read-only options to be used in this module
  55642. */
  55643. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55644. /**
  55645. * attach this feature
  55646. * Will usually be called by the features manager
  55647. *
  55648. * @returns true if successful.
  55649. */
  55650. attach(): boolean;
  55651. /**
  55652. * detach this feature.
  55653. * Will usually be called by the features manager
  55654. *
  55655. * @returns true if successful.
  55656. */
  55657. detach(): boolean;
  55658. /**
  55659. * Will get the mesh under a specific pointer.
  55660. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55661. * @param controllerId the controllerId to check
  55662. * @returns The mesh under pointer or null if no mesh is under the pointer
  55663. */
  55664. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55665. /**
  55666. * Get the xr controller that correlates to the pointer id in the pointer event
  55667. *
  55668. * @param id the pointer id to search for
  55669. * @returns the controller that correlates to this id or null if not found
  55670. */
  55671. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55672. private _identityMatrix;
  55673. private _screenCoordinatesRef;
  55674. private _viewportRef;
  55675. protected _onXRFrame(_xrFrame: XRFrame): void;
  55676. private _attachGazeMode;
  55677. private _attachScreenRayMode;
  55678. private _attachTrackedPointerRayMode;
  55679. private _convertNormalToDirectionOfRay;
  55680. private _detachController;
  55681. private _generateNewMeshPair;
  55682. private _pickingMoved;
  55683. private _updatePointerDistance;
  55684. /** @hidden */
  55685. get lasterPointerDefaultColor(): Color3;
  55686. }
  55687. }
  55688. declare module BABYLON {
  55689. /**
  55690. * Button which can be used to enter a different mode of XR
  55691. */
  55692. export class WebXREnterExitUIButton {
  55693. /** button element */
  55694. element: HTMLElement;
  55695. /** XR initialization options for the button */
  55696. sessionMode: XRSessionMode;
  55697. /** Reference space type */
  55698. referenceSpaceType: XRReferenceSpaceType;
  55699. /**
  55700. * Creates a WebXREnterExitUIButton
  55701. * @param element button element
  55702. * @param sessionMode XR initialization session mode
  55703. * @param referenceSpaceType the type of reference space to be used
  55704. */
  55705. constructor(
  55706. /** button element */
  55707. element: HTMLElement,
  55708. /** XR initialization options for the button */
  55709. sessionMode: XRSessionMode,
  55710. /** Reference space type */
  55711. referenceSpaceType: XRReferenceSpaceType);
  55712. /**
  55713. * Extendable function which can be used to update the button's visuals when the state changes
  55714. * @param activeButton the current active button in the UI
  55715. */
  55716. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55717. }
  55718. /**
  55719. * Options to create the webXR UI
  55720. */
  55721. export class WebXREnterExitUIOptions {
  55722. /**
  55723. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  55724. */
  55725. customButtons?: Array<WebXREnterExitUIButton>;
  55726. /**
  55727. * A reference space type to use when creating the default button.
  55728. * Default is local-floor
  55729. */
  55730. referenceSpaceType?: XRReferenceSpaceType;
  55731. /**
  55732. * Context to enter xr with
  55733. */
  55734. renderTarget?: Nullable<WebXRRenderTarget>;
  55735. /**
  55736. * A session mode to use when creating the default button.
  55737. * Default is immersive-vr
  55738. */
  55739. sessionMode?: XRSessionMode;
  55740. /**
  55741. * A list of optional features to init the session with
  55742. */
  55743. optionalFeatures?: string[];
  55744. /**
  55745. * A list of optional features to init the session with
  55746. */
  55747. requiredFeatures?: string[];
  55748. /**
  55749. * If defined, this function will be executed if the UI encounters an error when entering XR
  55750. */
  55751. onError?: (error: any) => void;
  55752. }
  55753. /**
  55754. * UI to allow the user to enter/exit XR mode
  55755. */
  55756. export class WebXREnterExitUI implements IDisposable {
  55757. private scene;
  55758. /** version of the options passed to this UI */
  55759. options: WebXREnterExitUIOptions;
  55760. private _activeButton;
  55761. private _buttons;
  55762. /**
  55763. * The HTML Div Element to which buttons are added.
  55764. */
  55765. readonly overlay: HTMLDivElement;
  55766. /**
  55767. * Fired every time the active button is changed.
  55768. *
  55769. * When xr is entered via a button that launches xr that button will be the callback parameter
  55770. *
  55771. * When exiting xr the callback parameter will be null)
  55772. */
  55773. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  55774. /**
  55775. *
  55776. * @param scene babylon scene object to use
  55777. * @param options (read-only) version of the options passed to this UI
  55778. */
  55779. private constructor();
  55780. /**
  55781. * Creates UI to allow the user to enter/exit XR mode
  55782. * @param scene the scene to add the ui to
  55783. * @param helper the xr experience helper to enter/exit xr with
  55784. * @param options options to configure the UI
  55785. * @returns the created ui
  55786. */
  55787. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  55788. /**
  55789. * Disposes of the XR UI component
  55790. */
  55791. dispose(): void;
  55792. private _updateButtons;
  55793. }
  55794. }
  55795. declare module BABYLON {
  55796. /**
  55797. * Class containing static functions to help procedurally build meshes
  55798. */
  55799. export class LinesBuilder {
  55800. /**
  55801. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55802. * * 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
  55803. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55804. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55805. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55806. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55807. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55808. * * 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
  55809. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55812. * @param name defines the name of the new line system
  55813. * @param options defines the options used to create the line system
  55814. * @param scene defines the hosting scene
  55815. * @returns a new line system mesh
  55816. */
  55817. static CreateLineSystem(name: string, options: {
  55818. lines: Vector3[][];
  55819. updatable?: boolean;
  55820. instance?: Nullable<LinesMesh>;
  55821. colors?: Nullable<Color4[][]>;
  55822. useVertexAlpha?: boolean;
  55823. }, scene: Nullable<Scene>): LinesMesh;
  55824. /**
  55825. * Creates a line mesh
  55826. * 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
  55827. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55828. * * The parameter `points` is an array successive Vector3
  55829. * * 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
  55830. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55831. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55832. * * When updating an instance, remember that only point positions can change, not the number of points
  55833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55835. * @param name defines the name of the new line system
  55836. * @param options defines the options used to create the line system
  55837. * @param scene defines the hosting scene
  55838. * @returns a new line mesh
  55839. */
  55840. static CreateLines(name: string, options: {
  55841. points: Vector3[];
  55842. updatable?: boolean;
  55843. instance?: Nullable<LinesMesh>;
  55844. colors?: Color4[];
  55845. useVertexAlpha?: boolean;
  55846. }, scene?: Nullable<Scene>): LinesMesh;
  55847. /**
  55848. * Creates a dashed line mesh
  55849. * * 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
  55850. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55851. * * The parameter `points` is an array successive Vector3
  55852. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55853. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55854. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55855. * * 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
  55856. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55857. * * When updating an instance, remember that only point positions can change, not the number of points
  55858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55859. * @param name defines the name of the mesh
  55860. * @param options defines the options used to create the mesh
  55861. * @param scene defines the hosting scene
  55862. * @returns the dashed line mesh
  55863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55864. */
  55865. static CreateDashedLines(name: string, options: {
  55866. points: Vector3[];
  55867. dashSize?: number;
  55868. gapSize?: number;
  55869. dashNb?: number;
  55870. updatable?: boolean;
  55871. instance?: LinesMesh;
  55872. useVertexAlpha?: boolean;
  55873. }, scene?: Nullable<Scene>): LinesMesh;
  55874. }
  55875. }
  55876. declare module BABYLON {
  55877. /**
  55878. * Construction options for a timer
  55879. */
  55880. export interface ITimerOptions<T> {
  55881. /**
  55882. * Time-to-end
  55883. */
  55884. timeout: number;
  55885. /**
  55886. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55887. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55888. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55889. */
  55890. contextObservable: Observable<T>;
  55891. /**
  55892. * Optional parameters when adding an observer to the observable
  55893. */
  55894. observableParameters?: {
  55895. mask?: number;
  55896. insertFirst?: boolean;
  55897. scope?: any;
  55898. };
  55899. /**
  55900. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55901. */
  55902. breakCondition?: (data?: ITimerData<T>) => boolean;
  55903. /**
  55904. * Will be triggered when the time condition has met
  55905. */
  55906. onEnded?: (data: ITimerData<any>) => void;
  55907. /**
  55908. * Will be triggered when the break condition has met (prematurely ended)
  55909. */
  55910. onAborted?: (data: ITimerData<any>) => void;
  55911. /**
  55912. * Optional function to execute on each tick (or count)
  55913. */
  55914. onTick?: (data: ITimerData<any>) => void;
  55915. }
  55916. /**
  55917. * An interface defining the data sent by the timer
  55918. */
  55919. export interface ITimerData<T> {
  55920. /**
  55921. * When did it start
  55922. */
  55923. startTime: number;
  55924. /**
  55925. * Time now
  55926. */
  55927. currentTime: number;
  55928. /**
  55929. * Time passed since started
  55930. */
  55931. deltaTime: number;
  55932. /**
  55933. * How much is completed, in [0.0...1.0].
  55934. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55935. */
  55936. completeRate: number;
  55937. /**
  55938. * What the registered observable sent in the last count
  55939. */
  55940. payload: T;
  55941. }
  55942. /**
  55943. * The current state of the timer
  55944. */
  55945. export enum TimerState {
  55946. /**
  55947. * Timer initialized, not yet started
  55948. */
  55949. INIT = 0,
  55950. /**
  55951. * Timer started and counting
  55952. */
  55953. STARTED = 1,
  55954. /**
  55955. * Timer ended (whether aborted or time reached)
  55956. */
  55957. ENDED = 2
  55958. }
  55959. /**
  55960. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55961. *
  55962. * @param options options with which to initialize this timer
  55963. */
  55964. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55965. /**
  55966. * An advanced implementation of a timer class
  55967. */
  55968. export class AdvancedTimer<T = any> implements IDisposable {
  55969. /**
  55970. * Will notify each time the timer calculates the remaining time
  55971. */
  55972. onEachCountObservable: Observable<ITimerData<T>>;
  55973. /**
  55974. * Will trigger when the timer was aborted due to the break condition
  55975. */
  55976. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55977. /**
  55978. * Will trigger when the timer ended successfully
  55979. */
  55980. onTimerEndedObservable: Observable<ITimerData<T>>;
  55981. /**
  55982. * Will trigger when the timer state has changed
  55983. */
  55984. onStateChangedObservable: Observable<TimerState>;
  55985. private _observer;
  55986. private _contextObservable;
  55987. private _observableParameters;
  55988. private _startTime;
  55989. private _timer;
  55990. private _state;
  55991. private _breakCondition;
  55992. private _timeToEnd;
  55993. private _breakOnNextTick;
  55994. /**
  55995. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55996. * @param options construction options for this advanced timer
  55997. */
  55998. constructor(options: ITimerOptions<T>);
  55999. /**
  56000. * set a breaking condition for this timer. Default is to never break during count
  56001. * @param predicate the new break condition. Returns true to break, false otherwise
  56002. */
  56003. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  56004. /**
  56005. * Reset ALL associated observables in this advanced timer
  56006. */
  56007. clearObservables(): void;
  56008. /**
  56009. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  56010. *
  56011. * @param timeToEnd how much time to measure until timer ended
  56012. */
  56013. start(timeToEnd?: number): void;
  56014. /**
  56015. * Will force a stop on the next tick.
  56016. */
  56017. stop(): void;
  56018. /**
  56019. * Dispose this timer, clearing all resources
  56020. */
  56021. dispose(): void;
  56022. private _setState;
  56023. private _tick;
  56024. private _stop;
  56025. }
  56026. }
  56027. declare module BABYLON {
  56028. /**
  56029. * The options container for the teleportation module
  56030. */
  56031. export interface IWebXRTeleportationOptions {
  56032. /**
  56033. * if provided, this scene will be used to render meshes.
  56034. */
  56035. customUtilityLayerScene?: Scene;
  56036. /**
  56037. * Values to configure the default target mesh
  56038. */
  56039. defaultTargetMeshOptions?: {
  56040. /**
  56041. * Fill color of the teleportation area
  56042. */
  56043. teleportationFillColor?: string;
  56044. /**
  56045. * Border color for the teleportation area
  56046. */
  56047. teleportationBorderColor?: string;
  56048. /**
  56049. * Disable the mesh's animation sequence
  56050. */
  56051. disableAnimation?: boolean;
  56052. /**
  56053. * Disable lighting on the material or the ring and arrow
  56054. */
  56055. disableLighting?: boolean;
  56056. /**
  56057. * Override the default material of the torus and arrow
  56058. */
  56059. torusArrowMaterial?: Material;
  56060. };
  56061. /**
  56062. * A list of meshes to use as floor meshes.
  56063. * Meshes can be added and removed after initializing the feature using the
  56064. * addFloorMesh and removeFloorMesh functions
  56065. * If empty, rotation will still work
  56066. */
  56067. floorMeshes?: AbstractMesh[];
  56068. /**
  56069. * use this rendering group id for the meshes (optional)
  56070. */
  56071. renderingGroupId?: number;
  56072. /**
  56073. * Should teleportation move only to snap points
  56074. */
  56075. snapPointsOnly?: boolean;
  56076. /**
  56077. * An array of points to which the teleportation will snap to.
  56078. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56079. */
  56080. snapPositions?: Vector3[];
  56081. /**
  56082. * How close should the teleportation ray be in order to snap to position.
  56083. * Default to 0.8 units (meters)
  56084. */
  56085. snapToPositionRadius?: number;
  56086. /**
  56087. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56088. * If you want to support rotation, make sure your mesh has a direction indicator.
  56089. *
  56090. * When left untouched, the default mesh will be initialized.
  56091. */
  56092. teleportationTargetMesh?: AbstractMesh;
  56093. /**
  56094. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56095. */
  56096. timeToTeleport?: number;
  56097. /**
  56098. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56099. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56100. */
  56101. useMainComponentOnly?: boolean;
  56102. /**
  56103. * Should meshes created here be added to a utility layer or the main scene
  56104. */
  56105. useUtilityLayer?: boolean;
  56106. /**
  56107. * Babylon XR Input class for controller
  56108. */
  56109. xrInput: WebXRInput;
  56110. /**
  56111. * Meshes that the teleportation ray cannot go through
  56112. */
  56113. pickBlockerMeshes?: AbstractMesh[];
  56114. /**
  56115. * Should teleport work only on a specific hand?
  56116. */
  56117. forceHandedness?: XRHandedness;
  56118. /**
  56119. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56120. */
  56121. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56122. }
  56123. /**
  56124. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56125. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56126. * the input of the attached controllers.
  56127. */
  56128. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56129. private _options;
  56130. private _controllers;
  56131. private _currentTeleportationControllerId;
  56132. private _floorMeshes;
  56133. private _quadraticBezierCurve;
  56134. private _selectionFeature;
  56135. private _snapToPositions;
  56136. private _snappedToPoint;
  56137. private _teleportationRingMaterial?;
  56138. private _tmpRay;
  56139. private _tmpVector;
  56140. private _tmpQuaternion;
  56141. /**
  56142. * The module's name
  56143. */
  56144. static readonly Name: string;
  56145. /**
  56146. * The (Babylon) version of this module.
  56147. * This is an integer representing the implementation version.
  56148. * This number does not correspond to the webxr specs version
  56149. */
  56150. static readonly Version: number;
  56151. /**
  56152. * Is movement backwards enabled
  56153. */
  56154. backwardsMovementEnabled: boolean;
  56155. /**
  56156. * Distance to travel when moving backwards
  56157. */
  56158. backwardsTeleportationDistance: number;
  56159. /**
  56160. * The distance from the user to the inspection point in the direction of the controller
  56161. * A higher number will allow the user to move further
  56162. * defaults to 5 (meters, in xr units)
  56163. */
  56164. parabolicCheckRadius: number;
  56165. /**
  56166. * Should the module support parabolic ray on top of direct ray
  56167. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56168. * Very helpful when moving between floors / different heights
  56169. */
  56170. parabolicRayEnabled: boolean;
  56171. /**
  56172. * The second type of ray - straight line.
  56173. * Should it be enabled or should the parabolic line be the only one.
  56174. */
  56175. straightRayEnabled: boolean;
  56176. /**
  56177. * How much rotation should be applied when rotating right and left
  56178. */
  56179. rotationAngle: number;
  56180. private _rotationEnabled;
  56181. /**
  56182. * Is rotation enabled when moving forward?
  56183. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56184. */
  56185. get rotationEnabled(): boolean;
  56186. /**
  56187. * Sets wether rotation is enabled or not
  56188. * @param enabled is rotation enabled when teleportation is shown
  56189. */
  56190. set rotationEnabled(enabled: boolean);
  56191. /**
  56192. * Exposes the currently set teleportation target mesh.
  56193. */
  56194. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56195. /**
  56196. * constructs a new anchor system
  56197. * @param _xrSessionManager an instance of WebXRSessionManager
  56198. * @param _options configuration object for this feature
  56199. */
  56200. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56201. /**
  56202. * Get the snapPointsOnly flag
  56203. */
  56204. get snapPointsOnly(): boolean;
  56205. /**
  56206. * Sets the snapPointsOnly flag
  56207. * @param snapToPoints should teleportation be exclusively to snap points
  56208. */
  56209. set snapPointsOnly(snapToPoints: boolean);
  56210. /**
  56211. * Add a new mesh to the floor meshes array
  56212. * @param mesh the mesh to use as floor mesh
  56213. */
  56214. addFloorMesh(mesh: AbstractMesh): void;
  56215. /**
  56216. * Add a new snap-to point to fix teleportation to this position
  56217. * @param newSnapPoint The new Snap-To point
  56218. */
  56219. addSnapPoint(newSnapPoint: Vector3): void;
  56220. attach(): boolean;
  56221. detach(): boolean;
  56222. dispose(): void;
  56223. /**
  56224. * Remove a mesh from the floor meshes array
  56225. * @param mesh the mesh to remove
  56226. */
  56227. removeFloorMesh(mesh: AbstractMesh): void;
  56228. /**
  56229. * Remove a mesh from the floor meshes array using its name
  56230. * @param name the mesh name to remove
  56231. */
  56232. removeFloorMeshByName(name: string): void;
  56233. /**
  56234. * 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
  56235. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56236. * @returns was the point found and removed or not
  56237. */
  56238. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56239. /**
  56240. * This function sets a selection feature that will be disabled when
  56241. * the forward ray is shown and will be reattached when hidden.
  56242. * This is used to remove the selection rays when moving.
  56243. * @param selectionFeature the feature to disable when forward movement is enabled
  56244. */
  56245. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56246. protected _onXRFrame(_xrFrame: XRFrame): void;
  56247. private _attachController;
  56248. private _createDefaultTargetMesh;
  56249. private _detachController;
  56250. private _findClosestSnapPointWithRadius;
  56251. private _setTargetMeshPosition;
  56252. private _setTargetMeshVisibility;
  56253. private _showParabolicPath;
  56254. private _teleportForward;
  56255. }
  56256. }
  56257. declare module BABYLON {
  56258. /**
  56259. * Options for the default xr helper
  56260. */
  56261. export class WebXRDefaultExperienceOptions {
  56262. /**
  56263. * Enable or disable default UI to enter XR
  56264. */
  56265. disableDefaultUI?: boolean;
  56266. /**
  56267. * Should teleportation not initialize. defaults to false.
  56268. */
  56269. disableTeleportation?: boolean;
  56270. /**
  56271. * Floor meshes that will be used for teleport
  56272. */
  56273. floorMeshes?: Array<AbstractMesh>;
  56274. /**
  56275. * If set to true, the first frame will not be used to reset position
  56276. * The first frame is mainly used when copying transformation from the old camera
  56277. * Mainly used in AR
  56278. */
  56279. ignoreNativeCameraTransformation?: boolean;
  56280. /**
  56281. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56282. */
  56283. inputOptions?: IWebXRInputOptions;
  56284. /**
  56285. * optional configuration for the output canvas
  56286. */
  56287. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56288. /**
  56289. * optional UI options. This can be used among other to change session mode and reference space type
  56290. */
  56291. uiOptions?: WebXREnterExitUIOptions;
  56292. /**
  56293. * When loading teleportation and pointer select, use stable versions instead of latest.
  56294. */
  56295. useStablePlugins?: boolean;
  56296. /**
  56297. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56298. */
  56299. renderingGroupId?: number;
  56300. /**
  56301. * A list of optional features to init the session with
  56302. * If set to true, all features we support will be added
  56303. */
  56304. optionalFeatures?: boolean | string[];
  56305. }
  56306. /**
  56307. * Default experience which provides a similar setup to the previous webVRExperience
  56308. */
  56309. export class WebXRDefaultExperience {
  56310. /**
  56311. * Base experience
  56312. */
  56313. baseExperience: WebXRExperienceHelper;
  56314. /**
  56315. * Enables ui for entering/exiting xr
  56316. */
  56317. enterExitUI: WebXREnterExitUI;
  56318. /**
  56319. * Input experience extension
  56320. */
  56321. input: WebXRInput;
  56322. /**
  56323. * Enables laser pointer and selection
  56324. */
  56325. pointerSelection: WebXRControllerPointerSelection;
  56326. /**
  56327. * Default target xr should render to
  56328. */
  56329. renderTarget: WebXRRenderTarget;
  56330. /**
  56331. * Enables teleportation
  56332. */
  56333. teleportation: WebXRMotionControllerTeleportation;
  56334. private constructor();
  56335. /**
  56336. * Creates the default xr experience
  56337. * @param scene scene
  56338. * @param options options for basic configuration
  56339. * @returns resulting WebXRDefaultExperience
  56340. */
  56341. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56342. /**
  56343. * DIsposes of the experience helper
  56344. */
  56345. dispose(): void;
  56346. }
  56347. }
  56348. declare module BABYLON {
  56349. /**
  56350. * Options to modify the vr teleportation behavior.
  56351. */
  56352. export interface VRTeleportationOptions {
  56353. /**
  56354. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56355. */
  56356. floorMeshName?: string;
  56357. /**
  56358. * A list of meshes to be used as the teleportation floor. (default: empty)
  56359. */
  56360. floorMeshes?: Mesh[];
  56361. /**
  56362. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56363. */
  56364. teleportationMode?: number;
  56365. /**
  56366. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56367. */
  56368. teleportationTime?: number;
  56369. /**
  56370. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56371. */
  56372. teleportationSpeed?: number;
  56373. /**
  56374. * The easing function used in the animation or null for Linear. (default CircleEase)
  56375. */
  56376. easingFunction?: EasingFunction;
  56377. }
  56378. /**
  56379. * Options to modify the vr experience helper's behavior.
  56380. */
  56381. export interface VRExperienceHelperOptions extends WebVROptions {
  56382. /**
  56383. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56384. */
  56385. createDeviceOrientationCamera?: boolean;
  56386. /**
  56387. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56388. */
  56389. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56390. /**
  56391. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56392. */
  56393. laserToggle?: boolean;
  56394. /**
  56395. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56396. */
  56397. floorMeshes?: Mesh[];
  56398. /**
  56399. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56400. */
  56401. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56402. /**
  56403. * Defines if WebXR should be used instead of WebVR (if available)
  56404. */
  56405. useXR?: boolean;
  56406. }
  56407. /**
  56408. * Event containing information after VR has been entered
  56409. */
  56410. export class OnAfterEnteringVRObservableEvent {
  56411. /**
  56412. * If entering vr was successful
  56413. */
  56414. success: boolean;
  56415. }
  56416. /**
  56417. * Helps to quickly add VR support to an existing scene.
  56418. * See https://doc.babylonjs.com/how_to/webvr_helper
  56419. */
  56420. export class VRExperienceHelper {
  56421. /** Options to modify the vr experience helper's behavior. */
  56422. webVROptions: VRExperienceHelperOptions;
  56423. private _scene;
  56424. private _position;
  56425. private _btnVR;
  56426. private _btnVRDisplayed;
  56427. private _webVRsupported;
  56428. private _webVRready;
  56429. private _webVRrequesting;
  56430. private _webVRpresenting;
  56431. private _hasEnteredVR;
  56432. private _fullscreenVRpresenting;
  56433. private _inputElement;
  56434. private _webVRCamera;
  56435. private _vrDeviceOrientationCamera;
  56436. private _deviceOrientationCamera;
  56437. private _existingCamera;
  56438. private _onKeyDown;
  56439. private _onVrDisplayPresentChange;
  56440. private _onVRDisplayChanged;
  56441. private _onVRRequestPresentStart;
  56442. private _onVRRequestPresentComplete;
  56443. /**
  56444. * 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)
  56445. */
  56446. enableGazeEvenWhenNoPointerLock: boolean;
  56447. /**
  56448. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56449. */
  56450. exitVROnDoubleTap: boolean;
  56451. /**
  56452. * Observable raised right before entering VR.
  56453. */
  56454. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56455. /**
  56456. * Observable raised when entering VR has completed.
  56457. */
  56458. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56459. /**
  56460. * Observable raised when exiting VR.
  56461. */
  56462. onExitingVRObservable: Observable<VRExperienceHelper>;
  56463. /**
  56464. * Observable raised when controller mesh is loaded.
  56465. */
  56466. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56467. /** Return this.onEnteringVRObservable
  56468. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56469. */
  56470. get onEnteringVR(): Observable<VRExperienceHelper>;
  56471. /** Return this.onExitingVRObservable
  56472. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56473. */
  56474. get onExitingVR(): Observable<VRExperienceHelper>;
  56475. /** Return this.onControllerMeshLoadedObservable
  56476. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56477. */
  56478. get onControllerMeshLoaded(): Observable<WebVRController>;
  56479. private _rayLength;
  56480. private _useCustomVRButton;
  56481. private _teleportationRequested;
  56482. private _teleportActive;
  56483. private _floorMeshName;
  56484. private _floorMeshesCollection;
  56485. private _teleportationMode;
  56486. private _teleportationTime;
  56487. private _teleportationSpeed;
  56488. private _teleportationEasing;
  56489. private _rotationAllowed;
  56490. private _teleportBackwardsVector;
  56491. private _teleportationTarget;
  56492. private _isDefaultTeleportationTarget;
  56493. private _postProcessMove;
  56494. private _teleportationFillColor;
  56495. private _teleportationBorderColor;
  56496. private _rotationAngle;
  56497. private _haloCenter;
  56498. private _cameraGazer;
  56499. private _padSensibilityUp;
  56500. private _padSensibilityDown;
  56501. private _leftController;
  56502. private _rightController;
  56503. private _gazeColor;
  56504. private _laserColor;
  56505. private _pickedLaserColor;
  56506. private _pickedGazeColor;
  56507. /**
  56508. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56509. */
  56510. onNewMeshSelected: Observable<AbstractMesh>;
  56511. /**
  56512. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56513. * This observable will provide the mesh and the controller used to select the mesh
  56514. */
  56515. onMeshSelectedWithController: Observable<{
  56516. mesh: AbstractMesh;
  56517. controller: WebVRController;
  56518. }>;
  56519. /**
  56520. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56521. */
  56522. onNewMeshPicked: Observable<PickingInfo>;
  56523. private _circleEase;
  56524. /**
  56525. * Observable raised before camera teleportation
  56526. */
  56527. onBeforeCameraTeleport: Observable<Vector3>;
  56528. /**
  56529. * Observable raised after camera teleportation
  56530. */
  56531. onAfterCameraTeleport: Observable<Vector3>;
  56532. /**
  56533. * Observable raised when current selected mesh gets unselected
  56534. */
  56535. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56536. private _raySelectionPredicate;
  56537. /**
  56538. * To be optionaly changed by user to define custom ray selection
  56539. */
  56540. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56541. /**
  56542. * To be optionaly changed by user to define custom selection logic (after ray selection)
  56543. */
  56544. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56545. /**
  56546. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56547. */
  56548. teleportationEnabled: boolean;
  56549. private _defaultHeight;
  56550. private _teleportationInitialized;
  56551. private _interactionsEnabled;
  56552. private _interactionsRequested;
  56553. private _displayGaze;
  56554. private _displayLaserPointer;
  56555. /**
  56556. * The mesh used to display where the user is going to teleport.
  56557. */
  56558. get teleportationTarget(): Mesh;
  56559. /**
  56560. * Sets the mesh to be used to display where the user is going to teleport.
  56561. */
  56562. set teleportationTarget(value: Mesh);
  56563. /**
  56564. * 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
  56565. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56566. * See https://doc.babylonjs.com/resources/baking_transformations
  56567. */
  56568. get gazeTrackerMesh(): Mesh;
  56569. set gazeTrackerMesh(value: Mesh);
  56570. /**
  56571. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56572. */
  56573. updateGazeTrackerScale: boolean;
  56574. /**
  56575. * If the gaze trackers color should be updated when selecting meshes
  56576. */
  56577. updateGazeTrackerColor: boolean;
  56578. /**
  56579. * If the controller laser color should be updated when selecting meshes
  56580. */
  56581. updateControllerLaserColor: boolean;
  56582. /**
  56583. * The gaze tracking mesh corresponding to the left controller
  56584. */
  56585. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56586. /**
  56587. * The gaze tracking mesh corresponding to the right controller
  56588. */
  56589. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56590. /**
  56591. * If the ray of the gaze should be displayed.
  56592. */
  56593. get displayGaze(): boolean;
  56594. /**
  56595. * Sets if the ray of the gaze should be displayed.
  56596. */
  56597. set displayGaze(value: boolean);
  56598. /**
  56599. * If the ray of the LaserPointer should be displayed.
  56600. */
  56601. get displayLaserPointer(): boolean;
  56602. /**
  56603. * Sets if the ray of the LaserPointer should be displayed.
  56604. */
  56605. set displayLaserPointer(value: boolean);
  56606. /**
  56607. * The deviceOrientationCamera used as the camera when not in VR.
  56608. */
  56609. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56610. /**
  56611. * Based on the current WebVR support, returns the current VR camera used.
  56612. */
  56613. get currentVRCamera(): Nullable<Camera>;
  56614. /**
  56615. * The webVRCamera which is used when in VR.
  56616. */
  56617. get webVRCamera(): WebVRFreeCamera;
  56618. /**
  56619. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56620. */
  56621. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56622. /**
  56623. * The html button that is used to trigger entering into VR.
  56624. */
  56625. get vrButton(): Nullable<HTMLButtonElement>;
  56626. private get _teleportationRequestInitiated();
  56627. /**
  56628. * Defines whether or not Pointer lock should be requested when switching to
  56629. * full screen.
  56630. */
  56631. requestPointerLockOnFullScreen: boolean;
  56632. /**
  56633. * If asking to force XR, this will be populated with the default xr experience
  56634. */
  56635. xr: WebXRDefaultExperience;
  56636. /**
  56637. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56638. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56639. */
  56640. xrTestDone: boolean;
  56641. /**
  56642. * Instantiates a VRExperienceHelper.
  56643. * Helps to quickly add VR support to an existing scene.
  56644. * @param scene The scene the VRExperienceHelper belongs to.
  56645. * @param webVROptions Options to modify the vr experience helper's behavior.
  56646. */
  56647. constructor(scene: Scene,
  56648. /** Options to modify the vr experience helper's behavior. */
  56649. webVROptions?: VRExperienceHelperOptions);
  56650. private completeVRInit;
  56651. private _onDefaultMeshLoaded;
  56652. private _onResize;
  56653. private _onFullscreenChange;
  56654. /**
  56655. * Gets a value indicating if we are currently in VR mode.
  56656. */
  56657. get isInVRMode(): boolean;
  56658. private onVrDisplayPresentChange;
  56659. private onVRDisplayChanged;
  56660. private moveButtonToBottomRight;
  56661. private displayVRButton;
  56662. private updateButtonVisibility;
  56663. private _cachedAngularSensibility;
  56664. /**
  56665. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56666. * Otherwise, will use the fullscreen API.
  56667. */
  56668. enterVR(): void;
  56669. /**
  56670. * Attempt to exit VR, or fullscreen.
  56671. */
  56672. exitVR(): void;
  56673. /**
  56674. * The position of the vr experience helper.
  56675. */
  56676. get position(): Vector3;
  56677. /**
  56678. * Sets the position of the vr experience helper.
  56679. */
  56680. set position(value: Vector3);
  56681. /**
  56682. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56683. */
  56684. enableInteractions(): void;
  56685. private get _noControllerIsActive();
  56686. private beforeRender;
  56687. private _isTeleportationFloor;
  56688. /**
  56689. * Adds a floor mesh to be used for teleportation.
  56690. * @param floorMesh the mesh to be used for teleportation.
  56691. */
  56692. addFloorMesh(floorMesh: Mesh): void;
  56693. /**
  56694. * Removes a floor mesh from being used for teleportation.
  56695. * @param floorMesh the mesh to be removed.
  56696. */
  56697. removeFloorMesh(floorMesh: Mesh): void;
  56698. /**
  56699. * Enables interactions and teleportation using the VR controllers and gaze.
  56700. * @param vrTeleportationOptions options to modify teleportation behavior.
  56701. */
  56702. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56703. private _onNewGamepadConnected;
  56704. private _tryEnableInteractionOnController;
  56705. private _onNewGamepadDisconnected;
  56706. private _enableInteractionOnController;
  56707. private _checkTeleportWithRay;
  56708. private _checkRotate;
  56709. private _checkTeleportBackwards;
  56710. private _enableTeleportationOnController;
  56711. private _createTeleportationCircles;
  56712. private _displayTeleportationTarget;
  56713. private _hideTeleportationTarget;
  56714. private _rotateCamera;
  56715. private _moveTeleportationSelectorTo;
  56716. private _workingVector;
  56717. private _workingQuaternion;
  56718. private _workingMatrix;
  56719. /**
  56720. * Time Constant Teleportation Mode
  56721. */
  56722. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  56723. /**
  56724. * Speed Constant Teleportation Mode
  56725. */
  56726. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  56727. /**
  56728. * Teleports the users feet to the desired location
  56729. * @param location The location where the user's feet should be placed
  56730. */
  56731. teleportCamera(location: Vector3): void;
  56732. private _convertNormalToDirectionOfRay;
  56733. private _castRayAndSelectObject;
  56734. private _notifySelectedMeshUnselected;
  56735. /**
  56736. * Permanently set new colors for the laser pointer
  56737. * @param color the new laser color
  56738. * @param pickedColor the new laser color when picked mesh detected
  56739. */
  56740. setLaserColor(color: Color3, pickedColor?: Color3): void;
  56741. /**
  56742. * Set lighting enabled / disabled on the laser pointer of both controllers
  56743. * @param enabled should the lighting be enabled on the laser pointer
  56744. */
  56745. setLaserLightingState(enabled?: boolean): void;
  56746. /**
  56747. * Permanently set new colors for the gaze pointer
  56748. * @param color the new gaze color
  56749. * @param pickedColor the new gaze color when picked mesh detected
  56750. */
  56751. setGazeColor(color: Color3, pickedColor?: Color3): void;
  56752. /**
  56753. * Sets the color of the laser ray from the vr controllers.
  56754. * @param color new color for the ray.
  56755. */
  56756. changeLaserColor(color: Color3): void;
  56757. /**
  56758. * Sets the color of the ray from the vr headsets gaze.
  56759. * @param color new color for the ray.
  56760. */
  56761. changeGazeColor(color: Color3): void;
  56762. /**
  56763. * Exits VR and disposes of the vr experience helper
  56764. */
  56765. dispose(): void;
  56766. /**
  56767. * Gets the name of the VRExperienceHelper class
  56768. * @returns "VRExperienceHelper"
  56769. */
  56770. getClassName(): string;
  56771. }
  56772. }
  56773. declare module BABYLON {
  56774. /**
  56775. * Contains an array of blocks representing the octree
  56776. */
  56777. export interface IOctreeContainer<T> {
  56778. /**
  56779. * Blocks within the octree
  56780. */
  56781. blocks: Array<OctreeBlock<T>>;
  56782. }
  56783. /**
  56784. * Class used to store a cell in an octree
  56785. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56786. */
  56787. export class OctreeBlock<T> {
  56788. /**
  56789. * Gets the content of the current block
  56790. */
  56791. entries: T[];
  56792. /**
  56793. * Gets the list of block children
  56794. */
  56795. blocks: Array<OctreeBlock<T>>;
  56796. private _depth;
  56797. private _maxDepth;
  56798. private _capacity;
  56799. private _minPoint;
  56800. private _maxPoint;
  56801. private _boundingVectors;
  56802. private _creationFunc;
  56803. /**
  56804. * Creates a new block
  56805. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56806. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56807. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56808. * @param depth defines the current depth of this block in the octree
  56809. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56810. * @param creationFunc defines a callback to call when an element is added to the block
  56811. */
  56812. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56813. /**
  56814. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56815. */
  56816. get capacity(): number;
  56817. /**
  56818. * Gets the minimum vector (in world space) of the block's bounding box
  56819. */
  56820. get minPoint(): Vector3;
  56821. /**
  56822. * Gets the maximum vector (in world space) of the block's bounding box
  56823. */
  56824. get maxPoint(): Vector3;
  56825. /**
  56826. * Add a new element to this block
  56827. * @param entry defines the element to add
  56828. */
  56829. addEntry(entry: T): void;
  56830. /**
  56831. * Remove an element from this block
  56832. * @param entry defines the element to remove
  56833. */
  56834. removeEntry(entry: T): void;
  56835. /**
  56836. * Add an array of elements to this block
  56837. * @param entries defines the array of elements to add
  56838. */
  56839. addEntries(entries: T[]): void;
  56840. /**
  56841. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56842. * @param frustumPlanes defines the frustum planes to test
  56843. * @param selection defines the array to store current content if selection is positive
  56844. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56845. */
  56846. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56847. /**
  56848. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56849. * @param sphereCenter defines the bounding sphere center
  56850. * @param sphereRadius defines the bounding sphere radius
  56851. * @param selection defines the array to store current content if selection is positive
  56852. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56853. */
  56854. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56855. /**
  56856. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56857. * @param ray defines the ray to test with
  56858. * @param selection defines the array to store current content if selection is positive
  56859. */
  56860. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56861. /**
  56862. * Subdivide the content into child blocks (this block will then be empty)
  56863. */
  56864. createInnerBlocks(): void;
  56865. /**
  56866. * @hidden
  56867. */
  56868. 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;
  56869. }
  56870. }
  56871. declare module BABYLON {
  56872. /**
  56873. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56874. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56875. */
  56876. export class Octree<T> {
  56877. /** 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.) */
  56878. maxDepth: number;
  56879. /**
  56880. * Blocks within the octree containing objects
  56881. */
  56882. blocks: Array<OctreeBlock<T>>;
  56883. /**
  56884. * Content stored in the octree
  56885. */
  56886. dynamicContent: T[];
  56887. private _maxBlockCapacity;
  56888. private _selectionContent;
  56889. private _creationFunc;
  56890. /**
  56891. * Creates a octree
  56892. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56893. * @param creationFunc function to be used to instatiate the octree
  56894. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56895. * @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.)
  56896. */
  56897. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56898. /** 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.) */
  56899. maxDepth?: number);
  56900. /**
  56901. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56902. * @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);
  56903. * @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);
  56904. * @param entries meshes to be added to the octree blocks
  56905. */
  56906. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56907. /**
  56908. * Adds a mesh to the octree
  56909. * @param entry Mesh to add to the octree
  56910. */
  56911. addMesh(entry: T): void;
  56912. /**
  56913. * Remove an element from the octree
  56914. * @param entry defines the element to remove
  56915. */
  56916. removeMesh(entry: T): void;
  56917. /**
  56918. * Selects an array of meshes within the frustum
  56919. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56920. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56921. * @returns array of meshes within the frustum
  56922. */
  56923. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56924. /**
  56925. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56926. * @param sphereCenter defines the bounding sphere center
  56927. * @param sphereRadius defines the bounding sphere radius
  56928. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56929. * @returns an array of objects that intersect the sphere
  56930. */
  56931. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56932. /**
  56933. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56934. * @param ray defines the ray to test with
  56935. * @returns array of intersected objects
  56936. */
  56937. intersectsRay(ray: Ray): SmartArray<T>;
  56938. /**
  56939. * Adds a mesh into the octree block if it intersects the block
  56940. */
  56941. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56942. /**
  56943. * Adds a submesh into the octree block if it intersects the block
  56944. */
  56945. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56946. }
  56947. }
  56948. declare module BABYLON {
  56949. interface Scene {
  56950. /**
  56951. * @hidden
  56952. * Backing Filed
  56953. */
  56954. _selectionOctree: Octree<AbstractMesh>;
  56955. /**
  56956. * Gets the octree used to boost mesh selection (picking)
  56957. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56958. */
  56959. selectionOctree: Octree<AbstractMesh>;
  56960. /**
  56961. * Creates or updates the octree used to boost selection (picking)
  56962. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56963. * @param maxCapacity defines the maximum capacity per leaf
  56964. * @param maxDepth defines the maximum depth of the octree
  56965. * @returns an octree of AbstractMesh
  56966. */
  56967. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56968. }
  56969. interface AbstractMesh {
  56970. /**
  56971. * @hidden
  56972. * Backing Field
  56973. */
  56974. _submeshesOctree: Octree<SubMesh>;
  56975. /**
  56976. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56977. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56978. * @param maxCapacity defines the maximum size of each block (64 by default)
  56979. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56980. * @returns the new octree
  56981. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56982. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56983. */
  56984. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56985. }
  56986. /**
  56987. * Defines the octree scene component responsible to manage any octrees
  56988. * in a given scene.
  56989. */
  56990. export class OctreeSceneComponent {
  56991. /**
  56992. * The component name help to identify the component in the list of scene components.
  56993. */
  56994. readonly name: string;
  56995. /**
  56996. * The scene the component belongs to.
  56997. */
  56998. scene: Scene;
  56999. /**
  57000. * Indicates if the meshes have been checked to make sure they are isEnabled()
  57001. */
  57002. readonly checksIsEnabled: boolean;
  57003. /**
  57004. * Creates a new instance of the component for the given scene
  57005. * @param scene Defines the scene to register the component in
  57006. */
  57007. constructor(scene: Scene);
  57008. /**
  57009. * Registers the component in a given scene
  57010. */
  57011. register(): void;
  57012. /**
  57013. * Return the list of active meshes
  57014. * @returns the list of active meshes
  57015. */
  57016. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  57017. /**
  57018. * Return the list of active sub meshes
  57019. * @param mesh The mesh to get the candidates sub meshes from
  57020. * @returns the list of active sub meshes
  57021. */
  57022. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  57023. private _tempRay;
  57024. /**
  57025. * Return the list of sub meshes intersecting with a given local ray
  57026. * @param mesh defines the mesh to find the submesh for
  57027. * @param localRay defines the ray in local space
  57028. * @returns the list of intersecting sub meshes
  57029. */
  57030. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  57031. /**
  57032. * Return the list of sub meshes colliding with a collider
  57033. * @param mesh defines the mesh to find the submesh for
  57034. * @param collider defines the collider to evaluate the collision against
  57035. * @returns the list of colliding sub meshes
  57036. */
  57037. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  57038. /**
  57039. * Rebuilds the elements related to this component in case of
  57040. * context lost for instance.
  57041. */
  57042. rebuild(): void;
  57043. /**
  57044. * Disposes the component and the associated ressources.
  57045. */
  57046. dispose(): void;
  57047. }
  57048. }
  57049. declare module BABYLON {
  57050. /**
  57051. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57052. */
  57053. export interface GizmoAxisCache {
  57054. /** Mesh used to runder the Gizmo */
  57055. gizmoMeshes: Mesh[];
  57056. /** Mesh used to detect user interaction with Gizmo */
  57057. colliderMeshes: Mesh[];
  57058. /** Material used to inicate color of gizmo mesh */
  57059. material: StandardMaterial;
  57060. /** Material used to inicate hover state of the Gizmo */
  57061. hoverMaterial: StandardMaterial;
  57062. /** Material used to inicate disabled state of the Gizmo */
  57063. disableMaterial: StandardMaterial;
  57064. /** Used to indicate Active state of the Gizmo */
  57065. active: boolean;
  57066. }
  57067. /**
  57068. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57069. */
  57070. export class Gizmo implements IDisposable {
  57071. /** The utility layer the gizmo will be added to */
  57072. gizmoLayer: UtilityLayerRenderer;
  57073. /**
  57074. * The root mesh of the gizmo
  57075. */
  57076. _rootMesh: Mesh;
  57077. private _attachedMesh;
  57078. private _attachedNode;
  57079. /**
  57080. * Ratio for the scale of the gizmo (Default: 1)
  57081. */
  57082. protected _scaleRatio: number;
  57083. /**
  57084. * boolean updated by pointermove when a gizmo mesh is hovered
  57085. */
  57086. protected _isHovered: boolean;
  57087. /**
  57088. * Ratio for the scale of the gizmo (Default: 1)
  57089. */
  57090. set scaleRatio(value: number);
  57091. get scaleRatio(): number;
  57092. /**
  57093. * True when the mouse pointer is hovered a gizmo mesh
  57094. */
  57095. get isHovered(): boolean;
  57096. /**
  57097. * If a custom mesh has been set (Default: false)
  57098. */
  57099. protected _customMeshSet: boolean;
  57100. /**
  57101. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57102. * * When set, interactions will be enabled
  57103. */
  57104. get attachedMesh(): Nullable<AbstractMesh>;
  57105. set attachedMesh(value: Nullable<AbstractMesh>);
  57106. /**
  57107. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57108. * * When set, interactions will be enabled
  57109. */
  57110. get attachedNode(): Nullable<Node>;
  57111. set attachedNode(value: Nullable<Node>);
  57112. /**
  57113. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57114. * @param mesh The mesh to replace the default mesh of the gizmo
  57115. */
  57116. setCustomMesh(mesh: Mesh): void;
  57117. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57118. /**
  57119. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57120. */
  57121. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57122. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57123. /**
  57124. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57125. */
  57126. updateGizmoPositionToMatchAttachedMesh: boolean;
  57127. /**
  57128. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57129. */
  57130. updateScale: boolean;
  57131. protected _interactionsEnabled: boolean;
  57132. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57133. private _beforeRenderObserver;
  57134. private _tempQuaternion;
  57135. private _tempVector;
  57136. private _tempVector2;
  57137. private _tempMatrix1;
  57138. private _tempMatrix2;
  57139. private _rightHandtoLeftHandMatrix;
  57140. /**
  57141. * Creates a gizmo
  57142. * @param gizmoLayer The utility layer the gizmo will be added to
  57143. */
  57144. constructor(
  57145. /** The utility layer the gizmo will be added to */
  57146. gizmoLayer?: UtilityLayerRenderer);
  57147. /**
  57148. * Updates the gizmo to match the attached mesh's position/rotation
  57149. */
  57150. protected _update(): void;
  57151. /**
  57152. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57153. * @param value Node, TransformNode or mesh
  57154. */
  57155. protected _matrixChanged(): void;
  57156. /**
  57157. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57158. * @param gizmoLayer The utility layer the gizmo will be added to
  57159. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57160. * @returns {Observer<PointerInfo>} pointerObserver
  57161. */
  57162. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57163. /**
  57164. * Disposes of the gizmo
  57165. */
  57166. dispose(): void;
  57167. }
  57168. }
  57169. declare module BABYLON {
  57170. /**
  57171. * Single plane drag gizmo
  57172. */
  57173. export class PlaneDragGizmo extends Gizmo {
  57174. /**
  57175. * Drag behavior responsible for the gizmos dragging interactions
  57176. */
  57177. dragBehavior: PointerDragBehavior;
  57178. private _pointerObserver;
  57179. /**
  57180. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57181. */
  57182. snapDistance: number;
  57183. /**
  57184. * Event that fires each time the gizmo snaps to a new location.
  57185. * * snapDistance is the the change in distance
  57186. */
  57187. onSnapObservable: Observable<{
  57188. snapDistance: number;
  57189. }>;
  57190. private _gizmoMesh;
  57191. private _coloredMaterial;
  57192. private _hoverMaterial;
  57193. private _disableMaterial;
  57194. private _isEnabled;
  57195. private _parent;
  57196. private _dragging;
  57197. /** @hidden */
  57198. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57199. /**
  57200. * Creates a PlaneDragGizmo
  57201. * @param gizmoLayer The utility layer the gizmo will be added to
  57202. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57203. * @param color The color of the gizmo
  57204. */
  57205. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57206. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57207. /**
  57208. * If the gizmo is enabled
  57209. */
  57210. set isEnabled(value: boolean);
  57211. get isEnabled(): boolean;
  57212. /**
  57213. * Disposes of the gizmo
  57214. */
  57215. dispose(): void;
  57216. }
  57217. }
  57218. declare module BABYLON {
  57219. /**
  57220. * Single plane rotation gizmo
  57221. */
  57222. export class PlaneRotationGizmo extends Gizmo {
  57223. /**
  57224. * Drag behavior responsible for the gizmos dragging interactions
  57225. */
  57226. dragBehavior: PointerDragBehavior;
  57227. private _pointerObserver;
  57228. /**
  57229. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57230. */
  57231. snapDistance: number;
  57232. /**
  57233. * Event that fires each time the gizmo snaps to a new location.
  57234. * * snapDistance is the the change in distance
  57235. */
  57236. onSnapObservable: Observable<{
  57237. snapDistance: number;
  57238. }>;
  57239. private _isEnabled;
  57240. private _parent;
  57241. private _coloredMaterial;
  57242. private _hoverMaterial;
  57243. private _disableMaterial;
  57244. private _gizmoMesh;
  57245. private _rotationCircle;
  57246. private _dragging;
  57247. private static _CircleConstants;
  57248. /**
  57249. * Creates a PlaneRotationGizmo
  57250. * @param gizmoLayer The utility layer the gizmo will be added to
  57251. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57252. * @param color The color of the gizmo
  57253. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57254. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57255. * @param thickness display gizmo axis thickness
  57256. */
  57257. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57258. /** Create Geometry for Gizmo */
  57259. private _createGizmoMesh;
  57260. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57261. private setupRotationCircle;
  57262. private updateRotationPath;
  57263. private updateRotationCircle;
  57264. /**
  57265. * If the gizmo is enabled
  57266. */
  57267. set isEnabled(value: boolean);
  57268. get isEnabled(): boolean;
  57269. /**
  57270. * Disposes of the gizmo
  57271. */
  57272. dispose(): void;
  57273. }
  57274. }
  57275. declare module BABYLON {
  57276. /**
  57277. * Gizmo that enables rotating a mesh along 3 axis
  57278. */
  57279. export class RotationGizmo extends Gizmo {
  57280. /**
  57281. * Internal gizmo used for interactions on the x axis
  57282. */
  57283. xGizmo: PlaneRotationGizmo;
  57284. /**
  57285. * Internal gizmo used for interactions on the y axis
  57286. */
  57287. yGizmo: PlaneRotationGizmo;
  57288. /**
  57289. * Internal gizmo used for interactions on the z axis
  57290. */
  57291. zGizmo: PlaneRotationGizmo;
  57292. /** Fires an event when any of it's sub gizmos are dragged */
  57293. onDragStartObservable: Observable<unknown>;
  57294. /** Fires an event when any of it's sub gizmos are released from dragging */
  57295. onDragEndObservable: Observable<unknown>;
  57296. private _meshAttached;
  57297. private _nodeAttached;
  57298. private _observables;
  57299. /** Node Caching for quick lookup */
  57300. private _gizmoAxisCache;
  57301. get attachedMesh(): Nullable<AbstractMesh>;
  57302. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57303. get attachedNode(): Nullable<Node>;
  57304. set attachedNode(node: Nullable<Node>);
  57305. protected _checkBillboardTransform(): void;
  57306. /**
  57307. * True when the mouse pointer is hovering a gizmo mesh
  57308. */
  57309. get isHovered(): boolean;
  57310. /**
  57311. * Creates a RotationGizmo
  57312. * @param gizmoLayer The utility layer the gizmo will be added to
  57313. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57314. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57315. * @param thickness display gizmo axis thickness
  57316. */
  57317. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57318. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57319. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57320. /**
  57321. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57322. */
  57323. set snapDistance(value: number);
  57324. get snapDistance(): number;
  57325. /**
  57326. * Ratio for the scale of the gizmo (Default: 1)
  57327. */
  57328. set scaleRatio(value: number);
  57329. get scaleRatio(): number;
  57330. /**
  57331. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57332. * @param mesh Axis gizmo mesh
  57333. * @param cache Gizmo axis definition used for reactive gizmo UI
  57334. */
  57335. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57336. /**
  57337. * Disposes of the gizmo
  57338. */
  57339. dispose(): void;
  57340. /**
  57341. * CustomMeshes are not supported by this gizmo
  57342. * @param mesh The mesh to replace the default mesh of the gizmo
  57343. */
  57344. setCustomMesh(mesh: Mesh): void;
  57345. }
  57346. }
  57347. declare module BABYLON {
  57348. /**
  57349. * Class containing static functions to help procedurally build meshes
  57350. */
  57351. export class PolyhedronBuilder {
  57352. /**
  57353. * Creates a polyhedron mesh
  57354. * * 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
  57355. * * The parameter `size` (positive float, default 1) sets the polygon size
  57356. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57357. * * 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`
  57358. * * 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
  57359. * * 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)`)
  57360. * * 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
  57361. * * 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
  57362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57363. * * 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
  57364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57365. * @param name defines the name of the mesh
  57366. * @param options defines the options used to create the mesh
  57367. * @param scene defines the hosting scene
  57368. * @returns the polyhedron mesh
  57369. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57370. */
  57371. static CreatePolyhedron(name: string, options: {
  57372. type?: number;
  57373. size?: number;
  57374. sizeX?: number;
  57375. sizeY?: number;
  57376. sizeZ?: number;
  57377. custom?: any;
  57378. faceUV?: Vector4[];
  57379. faceColors?: Color4[];
  57380. flat?: boolean;
  57381. updatable?: boolean;
  57382. sideOrientation?: number;
  57383. frontUVs?: Vector4;
  57384. backUVs?: Vector4;
  57385. }, scene?: Nullable<Scene>): Mesh;
  57386. }
  57387. }
  57388. declare module BABYLON {
  57389. /**
  57390. * Class containing static functions to help procedurally build meshes
  57391. */
  57392. export class BoxBuilder {
  57393. /**
  57394. * Creates a box mesh
  57395. * * The parameter `size` sets the size (float) of each box side (default 1)
  57396. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57397. * * 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)
  57398. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57400. * * 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
  57401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57402. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57403. * @param name defines the name of the mesh
  57404. * @param options defines the options used to create the mesh
  57405. * @param scene defines the hosting scene
  57406. * @returns the box mesh
  57407. */
  57408. static CreateBox(name: string, options: {
  57409. size?: number;
  57410. width?: number;
  57411. height?: number;
  57412. depth?: number;
  57413. faceUV?: Vector4[];
  57414. faceColors?: Color4[];
  57415. sideOrientation?: number;
  57416. frontUVs?: Vector4;
  57417. backUVs?: Vector4;
  57418. wrap?: boolean;
  57419. topBaseAt?: number;
  57420. bottomBaseAt?: number;
  57421. updatable?: boolean;
  57422. }, scene?: Nullable<Scene>): Mesh;
  57423. }
  57424. }
  57425. declare module BABYLON {
  57426. /**
  57427. * Single axis scale gizmo
  57428. */
  57429. export class AxisScaleGizmo extends Gizmo {
  57430. /**
  57431. * Drag behavior responsible for the gizmos dragging interactions
  57432. */
  57433. dragBehavior: PointerDragBehavior;
  57434. private _pointerObserver;
  57435. /**
  57436. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57437. */
  57438. snapDistance: number;
  57439. /**
  57440. * Event that fires each time the gizmo snaps to a new location.
  57441. * * snapDistance is the the change in distance
  57442. */
  57443. onSnapObservable: Observable<{
  57444. snapDistance: number;
  57445. }>;
  57446. /**
  57447. * If the scaling operation should be done on all axis (default: false)
  57448. */
  57449. uniformScaling: boolean;
  57450. /**
  57451. * Custom sensitivity value for the drag strength
  57452. */
  57453. sensitivity: number;
  57454. private _isEnabled;
  57455. private _parent;
  57456. private _gizmoMesh;
  57457. private _coloredMaterial;
  57458. private _hoverMaterial;
  57459. private _disableMaterial;
  57460. private _dragging;
  57461. private _tmpVector;
  57462. private _tmpMatrix;
  57463. private _tmpMatrix2;
  57464. /**
  57465. * Creates an AxisScaleGizmo
  57466. * @param gizmoLayer The utility layer the gizmo will be added to
  57467. * @param dragAxis The axis which the gizmo will be able to scale on
  57468. * @param color The color of the gizmo
  57469. * @param thickness display gizmo axis thickness
  57470. */
  57471. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57472. /** Create Geometry for Gizmo */
  57473. private _createGizmoMesh;
  57474. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57475. /**
  57476. * If the gizmo is enabled
  57477. */
  57478. set isEnabled(value: boolean);
  57479. get isEnabled(): boolean;
  57480. /**
  57481. * Disposes of the gizmo
  57482. */
  57483. dispose(): void;
  57484. /**
  57485. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57486. * @param mesh The mesh to replace the default mesh of the gizmo
  57487. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57488. */
  57489. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57490. }
  57491. }
  57492. declare module BABYLON {
  57493. /**
  57494. * Gizmo that enables scaling a mesh along 3 axis
  57495. */
  57496. export class ScaleGizmo extends Gizmo {
  57497. /**
  57498. * Internal gizmo used for interactions on the x axis
  57499. */
  57500. xGizmo: AxisScaleGizmo;
  57501. /**
  57502. * Internal gizmo used for interactions on the y axis
  57503. */
  57504. yGizmo: AxisScaleGizmo;
  57505. /**
  57506. * Internal gizmo used for interactions on the z axis
  57507. */
  57508. zGizmo: AxisScaleGizmo;
  57509. /**
  57510. * Internal gizmo used to scale all axis equally
  57511. */
  57512. uniformScaleGizmo: AxisScaleGizmo;
  57513. private _meshAttached;
  57514. private _nodeAttached;
  57515. private _snapDistance;
  57516. private _uniformScalingMesh;
  57517. private _octahedron;
  57518. private _sensitivity;
  57519. private _coloredMaterial;
  57520. private _hoverMaterial;
  57521. private _disableMaterial;
  57522. private _observables;
  57523. /** Node Caching for quick lookup */
  57524. private _gizmoAxisCache;
  57525. /** Fires an event when any of it's sub gizmos are dragged */
  57526. onDragStartObservable: Observable<unknown>;
  57527. /** Fires an event when any of it's sub gizmos are released from dragging */
  57528. onDragEndObservable: Observable<unknown>;
  57529. get attachedMesh(): Nullable<AbstractMesh>;
  57530. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57531. get attachedNode(): Nullable<Node>;
  57532. set attachedNode(node: Nullable<Node>);
  57533. /**
  57534. * True when the mouse pointer is hovering a gizmo mesh
  57535. */
  57536. get isHovered(): boolean;
  57537. /**
  57538. * Creates a ScaleGizmo
  57539. * @param gizmoLayer The utility layer the gizmo will be added to
  57540. * @param thickness display gizmo axis thickness
  57541. */
  57542. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57543. /** Create Geometry for Gizmo */
  57544. private _createUniformScaleMesh;
  57545. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57546. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57547. /**
  57548. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57549. */
  57550. set snapDistance(value: number);
  57551. get snapDistance(): number;
  57552. /**
  57553. * Ratio for the scale of the gizmo (Default: 1)
  57554. */
  57555. set scaleRatio(value: number);
  57556. get scaleRatio(): number;
  57557. /**
  57558. * Sensitivity factor for dragging (Default: 1)
  57559. */
  57560. set sensitivity(value: number);
  57561. get sensitivity(): number;
  57562. /**
  57563. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57564. * @param mesh Axis gizmo mesh
  57565. * @param cache Gizmo axis definition used for reactive gizmo UI
  57566. */
  57567. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57568. /**
  57569. * Disposes of the gizmo
  57570. */
  57571. dispose(): void;
  57572. }
  57573. }
  57574. declare module BABYLON {
  57575. /**
  57576. * Bounding box gizmo
  57577. */
  57578. export class BoundingBoxGizmo extends Gizmo {
  57579. private _lineBoundingBox;
  57580. private _rotateSpheresParent;
  57581. private _scaleBoxesParent;
  57582. private _boundingDimensions;
  57583. private _renderObserver;
  57584. private _pointerObserver;
  57585. private _scaleDragSpeed;
  57586. private _tmpQuaternion;
  57587. private _tmpVector;
  57588. private _tmpRotationMatrix;
  57589. /**
  57590. * 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)
  57591. */
  57592. ignoreChildren: boolean;
  57593. /**
  57594. * 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)
  57595. */
  57596. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57597. /**
  57598. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57599. */
  57600. rotationSphereSize: number;
  57601. /**
  57602. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57603. */
  57604. scaleBoxSize: number;
  57605. /**
  57606. * 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)
  57607. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57608. */
  57609. fixedDragMeshScreenSize: boolean;
  57610. /**
  57611. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57612. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57613. */
  57614. fixedDragMeshBoundsSize: boolean;
  57615. /**
  57616. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57617. */
  57618. fixedDragMeshScreenSizeDistanceFactor: number;
  57619. /**
  57620. * Fired when a rotation sphere or scale box is dragged
  57621. */
  57622. onDragStartObservable: Observable<{}>;
  57623. /**
  57624. * Fired when a scale box is dragged
  57625. */
  57626. onScaleBoxDragObservable: Observable<{}>;
  57627. /**
  57628. * Fired when a scale box drag is ended
  57629. */
  57630. onScaleBoxDragEndObservable: Observable<{}>;
  57631. /**
  57632. * Fired when a rotation sphere is dragged
  57633. */
  57634. onRotationSphereDragObservable: Observable<{}>;
  57635. /**
  57636. * Fired when a rotation sphere drag is ended
  57637. */
  57638. onRotationSphereDragEndObservable: Observable<{}>;
  57639. /**
  57640. * 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)
  57641. */
  57642. scalePivot: Nullable<Vector3>;
  57643. /**
  57644. * Mesh used as a pivot to rotate the attached node
  57645. */
  57646. private _anchorMesh;
  57647. private _existingMeshScale;
  57648. private _dragMesh;
  57649. private pointerDragBehavior;
  57650. private coloredMaterial;
  57651. private hoverColoredMaterial;
  57652. /**
  57653. * Sets the color of the bounding box gizmo
  57654. * @param color the color to set
  57655. */
  57656. setColor(color: Color3): void;
  57657. /**
  57658. * Creates an BoundingBoxGizmo
  57659. * @param gizmoLayer The utility layer the gizmo will be added to
  57660. * @param color The color of the gizmo
  57661. */
  57662. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57663. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57664. private _selectNode;
  57665. /**
  57666. * Updates the bounding box information for the Gizmo
  57667. */
  57668. updateBoundingBox(): void;
  57669. private _updateRotationSpheres;
  57670. private _updateScaleBoxes;
  57671. /**
  57672. * Enables rotation on the specified axis and disables rotation on the others
  57673. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57674. */
  57675. setEnabledRotationAxis(axis: string): void;
  57676. /**
  57677. * Enables/disables scaling
  57678. * @param enable if scaling should be enabled
  57679. * @param homogeneousScaling defines if scaling should only be homogeneous
  57680. */
  57681. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57682. private _updateDummy;
  57683. /**
  57684. * Enables a pointer drag behavior on the bounding box of the gizmo
  57685. */
  57686. enableDragBehavior(): void;
  57687. /**
  57688. * Disposes of the gizmo
  57689. */
  57690. dispose(): void;
  57691. /**
  57692. * 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)
  57693. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57694. * @returns the bounding box mesh with the passed in mesh as a child
  57695. */
  57696. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57697. /**
  57698. * CustomMeshes are not supported by this gizmo
  57699. * @param mesh The mesh to replace the default mesh of the gizmo
  57700. */
  57701. setCustomMesh(mesh: Mesh): void;
  57702. }
  57703. }
  57704. declare module BABYLON {
  57705. /**
  57706. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57707. */
  57708. export class GizmoManager implements IDisposable {
  57709. private scene;
  57710. /**
  57711. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57712. */
  57713. gizmos: {
  57714. positionGizmo: Nullable<PositionGizmo>;
  57715. rotationGizmo: Nullable<RotationGizmo>;
  57716. scaleGizmo: Nullable<ScaleGizmo>;
  57717. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57718. };
  57719. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57720. clearGizmoOnEmptyPointerEvent: boolean;
  57721. /** Fires an event when the manager is attached to a mesh */
  57722. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57723. /** Fires an event when the manager is attached to a node */
  57724. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57725. private _gizmosEnabled;
  57726. private _pointerObservers;
  57727. private _attachedMesh;
  57728. private _attachedNode;
  57729. private _boundingBoxColor;
  57730. private _defaultUtilityLayer;
  57731. private _defaultKeepDepthUtilityLayer;
  57732. private _thickness;
  57733. /** Node Caching for quick lookup */
  57734. private _gizmoAxisCache;
  57735. /**
  57736. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57737. */
  57738. boundingBoxDragBehavior: SixDofDragBehavior;
  57739. /**
  57740. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57741. */
  57742. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57743. /**
  57744. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57745. */
  57746. attachableNodes: Nullable<Array<Node>>;
  57747. /**
  57748. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57749. */
  57750. usePointerToAttachGizmos: boolean;
  57751. /**
  57752. * Utility layer that the bounding box gizmo belongs to
  57753. */
  57754. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57755. /**
  57756. * Utility layer that all gizmos besides bounding box belong to
  57757. */
  57758. get utilityLayer(): UtilityLayerRenderer;
  57759. /**
  57760. * True when the mouse pointer is hovering a gizmo mesh
  57761. */
  57762. get isHovered(): boolean;
  57763. /**
  57764. * Instatiates a gizmo manager
  57765. * @param scene the scene to overlay the gizmos on top of
  57766. * @param thickness display gizmo axis thickness
  57767. * @param utilityLayer the layer where gizmos are rendered
  57768. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57769. */
  57770. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57771. /**
  57772. * Subscribes to pointer down events, for attaching and detaching mesh
  57773. * @param scene The sceme layer the observer will be added to
  57774. */
  57775. private _attachToMeshPointerObserver;
  57776. /**
  57777. * Attaches a set of gizmos to the specified mesh
  57778. * @param mesh The mesh the gizmo's should be attached to
  57779. */
  57780. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57781. /**
  57782. * Attaches a set of gizmos to the specified node
  57783. * @param node The node the gizmo's should be attached to
  57784. */
  57785. attachToNode(node: Nullable<Node>): void;
  57786. /**
  57787. * If the position gizmo is enabled
  57788. */
  57789. set positionGizmoEnabled(value: boolean);
  57790. get positionGizmoEnabled(): boolean;
  57791. /**
  57792. * If the rotation gizmo is enabled
  57793. */
  57794. set rotationGizmoEnabled(value: boolean);
  57795. get rotationGizmoEnabled(): boolean;
  57796. /**
  57797. * If the scale gizmo is enabled
  57798. */
  57799. set scaleGizmoEnabled(value: boolean);
  57800. get scaleGizmoEnabled(): boolean;
  57801. /**
  57802. * If the boundingBox gizmo is enabled
  57803. */
  57804. set boundingBoxGizmoEnabled(value: boolean);
  57805. get boundingBoxGizmoEnabled(): boolean;
  57806. /**
  57807. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57808. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57809. */
  57810. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57811. /**
  57812. * Disposes of the gizmo manager
  57813. */
  57814. dispose(): void;
  57815. }
  57816. }
  57817. declare module BABYLON {
  57818. /**
  57819. * Gizmo that enables dragging a mesh along 3 axis
  57820. */
  57821. export class PositionGizmo extends Gizmo {
  57822. /**
  57823. * Internal gizmo used for interactions on the x axis
  57824. */
  57825. xGizmo: AxisDragGizmo;
  57826. /**
  57827. * Internal gizmo used for interactions on the y axis
  57828. */
  57829. yGizmo: AxisDragGizmo;
  57830. /**
  57831. * Internal gizmo used for interactions on the z axis
  57832. */
  57833. zGizmo: AxisDragGizmo;
  57834. /**
  57835. * Internal gizmo used for interactions on the yz plane
  57836. */
  57837. xPlaneGizmo: PlaneDragGizmo;
  57838. /**
  57839. * Internal gizmo used for interactions on the xz plane
  57840. */
  57841. yPlaneGizmo: PlaneDragGizmo;
  57842. /**
  57843. * Internal gizmo used for interactions on the xy plane
  57844. */
  57845. zPlaneGizmo: PlaneDragGizmo;
  57846. /**
  57847. * private variables
  57848. */
  57849. private _meshAttached;
  57850. private _nodeAttached;
  57851. private _snapDistance;
  57852. private _observables;
  57853. /** Node Caching for quick lookup */
  57854. private _gizmoAxisCache;
  57855. /** Fires an event when any of it's sub gizmos are dragged */
  57856. onDragStartObservable: Observable<unknown>;
  57857. /** Fires an event when any of it's sub gizmos are released from dragging */
  57858. onDragEndObservable: Observable<unknown>;
  57859. /**
  57860. * If set to true, planar drag is enabled
  57861. */
  57862. private _planarGizmoEnabled;
  57863. get attachedMesh(): Nullable<AbstractMesh>;
  57864. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57865. get attachedNode(): Nullable<Node>;
  57866. set attachedNode(node: Nullable<Node>);
  57867. /**
  57868. * True when the mouse pointer is hovering a gizmo mesh
  57869. */
  57870. get isHovered(): boolean;
  57871. /**
  57872. * Creates a PositionGizmo
  57873. * @param gizmoLayer The utility layer the gizmo will be added to
  57874. @param thickness display gizmo axis thickness
  57875. */
  57876. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57877. /**
  57878. * If the planar drag gizmo is enabled
  57879. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57880. */
  57881. set planarGizmoEnabled(value: boolean);
  57882. get planarGizmoEnabled(): boolean;
  57883. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57884. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57885. /**
  57886. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57887. */
  57888. set snapDistance(value: number);
  57889. get snapDistance(): number;
  57890. /**
  57891. * Ratio for the scale of the gizmo (Default: 1)
  57892. */
  57893. set scaleRatio(value: number);
  57894. get scaleRatio(): number;
  57895. /**
  57896. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57897. * @param mesh Axis gizmo mesh
  57898. * @param cache Gizmo axis definition used for reactive gizmo UI
  57899. */
  57900. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57901. /**
  57902. * Disposes of the gizmo
  57903. */
  57904. dispose(): void;
  57905. /**
  57906. * CustomMeshes are not supported by this gizmo
  57907. * @param mesh The mesh to replace the default mesh of the gizmo
  57908. */
  57909. setCustomMesh(mesh: Mesh): void;
  57910. }
  57911. }
  57912. declare module BABYLON {
  57913. /**
  57914. * Single axis drag gizmo
  57915. */
  57916. export class AxisDragGizmo extends Gizmo {
  57917. /**
  57918. * Drag behavior responsible for the gizmos dragging interactions
  57919. */
  57920. dragBehavior: PointerDragBehavior;
  57921. private _pointerObserver;
  57922. /**
  57923. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57924. */
  57925. snapDistance: number;
  57926. /**
  57927. * Event that fires each time the gizmo snaps to a new location.
  57928. * * snapDistance is the the change in distance
  57929. */
  57930. onSnapObservable: Observable<{
  57931. snapDistance: number;
  57932. }>;
  57933. private _isEnabled;
  57934. private _parent;
  57935. private _gizmoMesh;
  57936. private _coloredMaterial;
  57937. private _hoverMaterial;
  57938. private _disableMaterial;
  57939. private _dragging;
  57940. /** @hidden */
  57941. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57942. /** @hidden */
  57943. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57944. /**
  57945. * Creates an AxisDragGizmo
  57946. * @param gizmoLayer The utility layer the gizmo will be added to
  57947. * @param dragAxis The axis which the gizmo will be able to drag on
  57948. * @param color The color of the gizmo
  57949. * @param thickness display gizmo axis thickness
  57950. */
  57951. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57952. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57953. /**
  57954. * If the gizmo is enabled
  57955. */
  57956. set isEnabled(value: boolean);
  57957. get isEnabled(): boolean;
  57958. /**
  57959. * Disposes of the gizmo
  57960. */
  57961. dispose(): void;
  57962. }
  57963. }
  57964. declare module BABYLON.Debug {
  57965. /**
  57966. * The Axes viewer will show 3 axes in a specific point in space
  57967. */
  57968. export class AxesViewer {
  57969. private _xAxis;
  57970. private _yAxis;
  57971. private _zAxis;
  57972. private _scaleLinesFactor;
  57973. private _instanced;
  57974. /**
  57975. * Gets the hosting scene
  57976. */
  57977. scene: Nullable<Scene>;
  57978. /**
  57979. * Gets or sets a number used to scale line length
  57980. */
  57981. scaleLines: number;
  57982. /** Gets the node hierarchy used to render x-axis */
  57983. get xAxis(): TransformNode;
  57984. /** Gets the node hierarchy used to render y-axis */
  57985. get yAxis(): TransformNode;
  57986. /** Gets the node hierarchy used to render z-axis */
  57987. get zAxis(): TransformNode;
  57988. /**
  57989. * Creates a new AxesViewer
  57990. * @param scene defines the hosting scene
  57991. * @param scaleLines defines a number used to scale line length (1 by default)
  57992. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57993. * @param xAxis defines the node hierarchy used to render the x-axis
  57994. * @param yAxis defines the node hierarchy used to render the y-axis
  57995. * @param zAxis defines the node hierarchy used to render the z-axis
  57996. */
  57997. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57998. /**
  57999. * Force the viewer to update
  58000. * @param position defines the position of the viewer
  58001. * @param xaxis defines the x axis of the viewer
  58002. * @param yaxis defines the y axis of the viewer
  58003. * @param zaxis defines the z axis of the viewer
  58004. */
  58005. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  58006. /**
  58007. * Creates an instance of this axes viewer.
  58008. * @returns a new axes viewer with instanced meshes
  58009. */
  58010. createInstance(): AxesViewer;
  58011. /** Releases resources */
  58012. dispose(): void;
  58013. private static _SetRenderingGroupId;
  58014. }
  58015. }
  58016. declare module BABYLON.Debug {
  58017. /**
  58018. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  58019. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  58020. */
  58021. export class BoneAxesViewer extends AxesViewer {
  58022. /**
  58023. * Gets or sets the target mesh where to display the axes viewer
  58024. */
  58025. mesh: Nullable<Mesh>;
  58026. /**
  58027. * Gets or sets the target bone where to display the axes viewer
  58028. */
  58029. bone: Nullable<Bone>;
  58030. /** Gets current position */
  58031. pos: Vector3;
  58032. /** Gets direction of X axis */
  58033. xaxis: Vector3;
  58034. /** Gets direction of Y axis */
  58035. yaxis: Vector3;
  58036. /** Gets direction of Z axis */
  58037. zaxis: Vector3;
  58038. /**
  58039. * Creates a new BoneAxesViewer
  58040. * @param scene defines the hosting scene
  58041. * @param bone defines the target bone
  58042. * @param mesh defines the target mesh
  58043. * @param scaleLines defines a scaling factor for line length (1 by default)
  58044. */
  58045. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58046. /**
  58047. * Force the viewer to update
  58048. */
  58049. update(): void;
  58050. /** Releases resources */
  58051. dispose(): void;
  58052. }
  58053. }
  58054. declare module BABYLON {
  58055. /**
  58056. * Interface used to define scene explorer extensibility option
  58057. */
  58058. export interface IExplorerExtensibilityOption {
  58059. /**
  58060. * Define the option label
  58061. */
  58062. label: string;
  58063. /**
  58064. * Defines the action to execute on click
  58065. */
  58066. action: (entity: any) => void;
  58067. }
  58068. /**
  58069. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58070. */
  58071. export interface IExplorerExtensibilityGroup {
  58072. /**
  58073. * Defines a predicate to test if a given type mut be extended
  58074. */
  58075. predicate: (entity: any) => boolean;
  58076. /**
  58077. * Gets the list of options added to a type
  58078. */
  58079. entries: IExplorerExtensibilityOption[];
  58080. }
  58081. /**
  58082. * Interface used to define the options to use to create the Inspector
  58083. */
  58084. export interface IInspectorOptions {
  58085. /**
  58086. * Display in overlay mode (default: false)
  58087. */
  58088. overlay?: boolean;
  58089. /**
  58090. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58091. */
  58092. globalRoot?: HTMLElement;
  58093. /**
  58094. * Display the Scene explorer
  58095. */
  58096. showExplorer?: boolean;
  58097. /**
  58098. * Display the property inspector
  58099. */
  58100. showInspector?: boolean;
  58101. /**
  58102. * Display in embed mode (both panes on the right)
  58103. */
  58104. embedMode?: boolean;
  58105. /**
  58106. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58107. */
  58108. handleResize?: boolean;
  58109. /**
  58110. * Allow the panes to popup (default: true)
  58111. */
  58112. enablePopup?: boolean;
  58113. /**
  58114. * Allow the panes to be closed by users (default: true)
  58115. */
  58116. enableClose?: boolean;
  58117. /**
  58118. * Optional list of extensibility entries
  58119. */
  58120. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58121. /**
  58122. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58123. */
  58124. inspectorURL?: string;
  58125. /**
  58126. * Optional initial tab (default to DebugLayerTab.Properties)
  58127. */
  58128. initialTab?: DebugLayerTab;
  58129. }
  58130. interface Scene {
  58131. /**
  58132. * @hidden
  58133. * Backing field
  58134. */
  58135. _debugLayer: DebugLayer;
  58136. /**
  58137. * Gets the debug layer (aka Inspector) associated with the scene
  58138. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58139. */
  58140. debugLayer: DebugLayer;
  58141. }
  58142. /**
  58143. * Enum of inspector action tab
  58144. */
  58145. export enum DebugLayerTab {
  58146. /**
  58147. * Properties tag (default)
  58148. */
  58149. Properties = 0,
  58150. /**
  58151. * Debug tab
  58152. */
  58153. Debug = 1,
  58154. /**
  58155. * Statistics tab
  58156. */
  58157. Statistics = 2,
  58158. /**
  58159. * Tools tab
  58160. */
  58161. Tools = 3,
  58162. /**
  58163. * Settings tab
  58164. */
  58165. Settings = 4
  58166. }
  58167. /**
  58168. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58169. * what is happening in your scene
  58170. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58171. */
  58172. export class DebugLayer {
  58173. /**
  58174. * Define the url to get the inspector script from.
  58175. * By default it uses the babylonjs CDN.
  58176. * @ignoreNaming
  58177. */
  58178. static InspectorURL: string;
  58179. private _scene;
  58180. private BJSINSPECTOR;
  58181. private _onPropertyChangedObservable?;
  58182. /**
  58183. * Observable triggered when a property is changed through the inspector.
  58184. */
  58185. get onPropertyChangedObservable(): any;
  58186. /**
  58187. * Instantiates a new debug layer.
  58188. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58189. * what is happening in your scene
  58190. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58191. * @param scene Defines the scene to inspect
  58192. */
  58193. constructor(scene: Scene);
  58194. /** Creates the inspector window. */
  58195. private _createInspector;
  58196. /**
  58197. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58198. * @param entity defines the entity to select
  58199. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58200. */
  58201. select(entity: any, lineContainerTitles?: string | string[]): void;
  58202. /** Get the inspector from bundle or global */
  58203. private _getGlobalInspector;
  58204. /**
  58205. * Get if the inspector is visible or not.
  58206. * @returns true if visible otherwise, false
  58207. */
  58208. isVisible(): boolean;
  58209. /**
  58210. * Hide the inspector and close its window.
  58211. */
  58212. hide(): void;
  58213. /**
  58214. * Update the scene in the inspector
  58215. */
  58216. setAsActiveScene(): void;
  58217. /**
  58218. * Launch the debugLayer.
  58219. * @param config Define the configuration of the inspector
  58220. * @return a promise fulfilled when the debug layer is visible
  58221. */
  58222. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58223. }
  58224. }
  58225. declare module BABYLON.Debug {
  58226. /**
  58227. * Used to show the physics impostor around the specific mesh
  58228. */
  58229. export class PhysicsViewer {
  58230. /** @hidden */
  58231. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58232. /** @hidden */
  58233. protected _meshes: Array<Nullable<AbstractMesh>>;
  58234. /** @hidden */
  58235. protected _scene: Nullable<Scene>;
  58236. /** @hidden */
  58237. protected _numMeshes: number;
  58238. /** @hidden */
  58239. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58240. private _renderFunction;
  58241. private _utilityLayer;
  58242. private _debugBoxMesh;
  58243. private _debugSphereMesh;
  58244. private _debugCylinderMesh;
  58245. private _debugMaterial;
  58246. private _debugMeshMeshes;
  58247. /**
  58248. * Creates a new PhysicsViewer
  58249. * @param scene defines the hosting scene
  58250. */
  58251. constructor(scene: Scene);
  58252. /** @hidden */
  58253. protected _updateDebugMeshes(): void;
  58254. /**
  58255. * Renders a specified physic impostor
  58256. * @param impostor defines the impostor to render
  58257. * @param targetMesh defines the mesh represented by the impostor
  58258. * @returns the new debug mesh used to render the impostor
  58259. */
  58260. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58261. /**
  58262. * Hides a specified physic impostor
  58263. * @param impostor defines the impostor to hide
  58264. */
  58265. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58266. private _getDebugMaterial;
  58267. private _getDebugBoxMesh;
  58268. private _getDebugSphereMesh;
  58269. private _getDebugCylinderMesh;
  58270. private _getDebugMeshMesh;
  58271. private _getDebugMesh;
  58272. /** Releases all resources */
  58273. dispose(): void;
  58274. }
  58275. }
  58276. declare module BABYLON {
  58277. /**
  58278. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58279. * in order to better appreciate the issue one might have.
  58280. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58281. */
  58282. export class RayHelper {
  58283. /**
  58284. * Defines the ray we are currently tryin to visualize.
  58285. */
  58286. ray: Nullable<Ray>;
  58287. private _renderPoints;
  58288. private _renderLine;
  58289. private _renderFunction;
  58290. private _scene;
  58291. private _onAfterRenderObserver;
  58292. private _onAfterStepObserver;
  58293. private _attachedToMesh;
  58294. private _meshSpaceDirection;
  58295. private _meshSpaceOrigin;
  58296. /**
  58297. * Helper function to create a colored helper in a scene in one line.
  58298. * @param ray Defines the ray we are currently tryin to visualize
  58299. * @param scene Defines the scene the ray is used in
  58300. * @param color Defines the color we want to see the ray in
  58301. * @returns The newly created ray helper.
  58302. */
  58303. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58304. /**
  58305. * Instantiate a new ray helper.
  58306. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58307. * in order to better appreciate the issue one might have.
  58308. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58309. * @param ray Defines the ray we are currently tryin to visualize
  58310. */
  58311. constructor(ray: Ray);
  58312. /**
  58313. * Shows the ray we are willing to debug.
  58314. * @param scene Defines the scene the ray needs to be rendered in
  58315. * @param color Defines the color the ray needs to be rendered in
  58316. */
  58317. show(scene: Scene, color?: Color3): void;
  58318. /**
  58319. * Hides the ray we are debugging.
  58320. */
  58321. hide(): void;
  58322. private _render;
  58323. /**
  58324. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58325. * @param mesh Defines the mesh we want the helper attached to
  58326. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58327. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58328. * @param length Defines the length of the ray
  58329. */
  58330. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58331. /**
  58332. * Detach the ray helper from the mesh it has previously been attached to.
  58333. */
  58334. detachFromMesh(): void;
  58335. private _updateToMesh;
  58336. /**
  58337. * Dispose the helper and release its associated resources.
  58338. */
  58339. dispose(): void;
  58340. }
  58341. }
  58342. declare module BABYLON {
  58343. /**
  58344. * Defines the options associated with the creation of a SkeletonViewer.
  58345. */
  58346. export interface ISkeletonViewerOptions {
  58347. /** Should the system pause animations before building the Viewer? */
  58348. pauseAnimations: boolean;
  58349. /** Should the system return the skeleton to rest before building? */
  58350. returnToRest: boolean;
  58351. /** public Display Mode of the Viewer */
  58352. displayMode: number;
  58353. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58354. displayOptions: ISkeletonViewerDisplayOptions;
  58355. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58356. computeBonesUsingShaders: boolean;
  58357. /** Flag ignore non weighted bones */
  58358. useAllBones: boolean;
  58359. }
  58360. /**
  58361. * Defines how to display the various bone meshes for the viewer.
  58362. */
  58363. export interface ISkeletonViewerDisplayOptions {
  58364. /** How far down to start tapering the bone spurs */
  58365. midStep?: number;
  58366. /** How big is the midStep? */
  58367. midStepFactor?: number;
  58368. /** Base for the Sphere Size */
  58369. sphereBaseSize?: number;
  58370. /** The ratio of the sphere to the longest bone in units */
  58371. sphereScaleUnit?: number;
  58372. /** Ratio for the Sphere Size */
  58373. sphereFactor?: number;
  58374. /** Whether a spur should attach its far end to the child bone position */
  58375. spurFollowsChild?: boolean;
  58376. /** Whether to show local axes or not */
  58377. showLocalAxes?: boolean;
  58378. /** Length of each local axis */
  58379. localAxesSize?: number;
  58380. }
  58381. /**
  58382. * Defines the constructor options for the BoneWeight Shader.
  58383. */
  58384. export interface IBoneWeightShaderOptions {
  58385. /** Skeleton to Map */
  58386. skeleton: Skeleton;
  58387. /** Colors for Uninfluenced bones */
  58388. colorBase?: Color3;
  58389. /** Colors for 0.0-0.25 Weight bones */
  58390. colorZero?: Color3;
  58391. /** Color for 0.25-0.5 Weight Influence */
  58392. colorQuarter?: Color3;
  58393. /** Color for 0.5-0.75 Weight Influence */
  58394. colorHalf?: Color3;
  58395. /** Color for 0.75-1 Weight Influence */
  58396. colorFull?: Color3;
  58397. /** Color for Zero Weight Influence */
  58398. targetBoneIndex?: number;
  58399. }
  58400. /**
  58401. * Simple structure of the gradient steps for the Color Map.
  58402. */
  58403. export interface ISkeletonMapShaderColorMapKnot {
  58404. /** Color of the Knot */
  58405. color: Color3;
  58406. /** Location of the Knot */
  58407. location: number;
  58408. }
  58409. /**
  58410. * Defines the constructor options for the SkeletonMap Shader.
  58411. */
  58412. export interface ISkeletonMapShaderOptions {
  58413. /** Skeleton to Map */
  58414. skeleton: Skeleton;
  58415. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58416. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58417. }
  58418. }
  58419. declare module BABYLON {
  58420. /**
  58421. * Class containing static functions to help procedurally build meshes
  58422. */
  58423. export class RibbonBuilder {
  58424. /**
  58425. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58426. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58427. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58428. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58429. * * 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
  58430. * * 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
  58431. * * 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
  58432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58433. * * 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
  58434. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58435. * * 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
  58436. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58437. * * 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
  58438. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58440. * @param name defines the name of the mesh
  58441. * @param options defines the options used to create the mesh
  58442. * @param scene defines the hosting scene
  58443. * @returns the ribbon mesh
  58444. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58445. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58446. */
  58447. static CreateRibbon(name: string, options: {
  58448. pathArray: Vector3[][];
  58449. closeArray?: boolean;
  58450. closePath?: boolean;
  58451. offset?: number;
  58452. updatable?: boolean;
  58453. sideOrientation?: number;
  58454. frontUVs?: Vector4;
  58455. backUVs?: Vector4;
  58456. instance?: Mesh;
  58457. invertUV?: boolean;
  58458. uvs?: Vector2[];
  58459. colors?: Color4[];
  58460. }, scene?: Nullable<Scene>): Mesh;
  58461. }
  58462. }
  58463. declare module BABYLON {
  58464. /**
  58465. * Class containing static functions to help procedurally build meshes
  58466. */
  58467. export class ShapeBuilder {
  58468. /**
  58469. * 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.
  58470. * * 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.
  58471. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58472. * * 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.
  58473. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58474. * * 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
  58475. * * 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
  58476. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58478. * * 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
  58479. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58481. * @param name defines the name of the mesh
  58482. * @param options defines the options used to create the mesh
  58483. * @param scene defines the hosting scene
  58484. * @returns the extruded shape mesh
  58485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58487. */
  58488. static ExtrudeShape(name: string, options: {
  58489. shape: Vector3[];
  58490. path: Vector3[];
  58491. scale?: number;
  58492. rotation?: number;
  58493. cap?: number;
  58494. updatable?: boolean;
  58495. sideOrientation?: number;
  58496. frontUVs?: Vector4;
  58497. backUVs?: Vector4;
  58498. instance?: Mesh;
  58499. invertUV?: boolean;
  58500. }, scene?: Nullable<Scene>): Mesh;
  58501. /**
  58502. * Creates an custom extruded shape mesh.
  58503. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58504. * * 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.
  58505. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58506. * * 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
  58507. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58508. * * 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
  58509. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58510. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58511. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58512. * * 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
  58513. * * 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
  58514. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58516. * * 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
  58517. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58519. * @param name defines the name of the mesh
  58520. * @param options defines the options used to create the mesh
  58521. * @param scene defines the hosting scene
  58522. * @returns the custom extruded shape mesh
  58523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58524. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58526. */
  58527. static ExtrudeShapeCustom(name: string, options: {
  58528. shape: Vector3[];
  58529. path: Vector3[];
  58530. scaleFunction?: any;
  58531. rotationFunction?: any;
  58532. ribbonCloseArray?: boolean;
  58533. ribbonClosePath?: boolean;
  58534. cap?: number;
  58535. updatable?: boolean;
  58536. sideOrientation?: number;
  58537. frontUVs?: Vector4;
  58538. backUVs?: Vector4;
  58539. instance?: Mesh;
  58540. invertUV?: boolean;
  58541. }, scene?: Nullable<Scene>): Mesh;
  58542. private static _ExtrudeShapeGeneric;
  58543. }
  58544. }
  58545. declare module BABYLON.Debug {
  58546. /**
  58547. * Class used to render a debug view of a given skeleton
  58548. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58549. */
  58550. export class SkeletonViewer {
  58551. /** defines the skeleton to render */
  58552. skeleton: Skeleton;
  58553. /** defines the mesh attached to the skeleton */
  58554. mesh: AbstractMesh;
  58555. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58556. autoUpdateBonesMatrices: boolean;
  58557. /** defines the rendering group id to use with the viewer */
  58558. renderingGroupId: number;
  58559. /** is the options for the viewer */
  58560. options: Partial<ISkeletonViewerOptions>;
  58561. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58562. static readonly DISPLAY_LINES: number;
  58563. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58564. static readonly DISPLAY_SPHERES: number;
  58565. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58566. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58567. /** public static method to create a BoneWeight Shader
  58568. * @param options The constructor options
  58569. * @param scene The scene that the shader is scoped to
  58570. * @returns The created ShaderMaterial
  58571. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58572. */
  58573. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58574. /** public static method to create a BoneWeight Shader
  58575. * @param options The constructor options
  58576. * @param scene The scene that the shader is scoped to
  58577. * @returns The created ShaderMaterial
  58578. */
  58579. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58580. /** private static method to create a BoneWeight Shader
  58581. * @param size The size of the buffer to create (usually the bone count)
  58582. * @param colorMap The gradient data to generate
  58583. * @param scene The scene that the shader is scoped to
  58584. * @returns an Array of floats from the color gradient values
  58585. */
  58586. private static _CreateBoneMapColorBuffer;
  58587. /** If SkeletonViewer scene scope. */
  58588. private _scene;
  58589. /** Gets or sets the color used to render the skeleton */
  58590. color: Color3;
  58591. /** Array of the points of the skeleton fo the line view. */
  58592. private _debugLines;
  58593. /** The SkeletonViewers Mesh. */
  58594. private _debugMesh;
  58595. /** The local axes Meshes. */
  58596. private _localAxes;
  58597. /** If SkeletonViewer is enabled. */
  58598. private _isEnabled;
  58599. /** If SkeletonViewer is ready. */
  58600. private _ready;
  58601. /** SkeletonViewer render observable. */
  58602. private _obs;
  58603. /** The Utility Layer to render the gizmos in. */
  58604. private _utilityLayer;
  58605. private _boneIndices;
  58606. /** Gets the Scene. */
  58607. get scene(): Scene;
  58608. /** Gets the utilityLayer. */
  58609. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58610. /** Checks Ready Status. */
  58611. get isReady(): Boolean;
  58612. /** Sets Ready Status. */
  58613. set ready(value: boolean);
  58614. /** Gets the debugMesh */
  58615. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58616. /** Sets the debugMesh */
  58617. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58618. /** Gets the displayMode */
  58619. get displayMode(): number;
  58620. /** Sets the displayMode */
  58621. set displayMode(value: number);
  58622. /**
  58623. * Creates a new SkeletonViewer
  58624. * @param skeleton defines the skeleton to render
  58625. * @param mesh defines the mesh attached to the skeleton
  58626. * @param scene defines the hosting scene
  58627. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58628. * @param renderingGroupId defines the rendering group id to use with the viewer
  58629. * @param options All of the extra constructor options for the SkeletonViewer
  58630. */
  58631. constructor(
  58632. /** defines the skeleton to render */
  58633. skeleton: Skeleton,
  58634. /** defines the mesh attached to the skeleton */
  58635. mesh: AbstractMesh,
  58636. /** The Scene scope*/
  58637. scene: Scene,
  58638. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58639. autoUpdateBonesMatrices?: boolean,
  58640. /** defines the rendering group id to use with the viewer */
  58641. renderingGroupId?: number,
  58642. /** is the options for the viewer */
  58643. options?: Partial<ISkeletonViewerOptions>);
  58644. /** The Dynamic bindings for the update functions */
  58645. private _bindObs;
  58646. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58647. update(): void;
  58648. /** Gets or sets a boolean indicating if the viewer is enabled */
  58649. set isEnabled(value: boolean);
  58650. get isEnabled(): boolean;
  58651. private _getBonePosition;
  58652. private _getLinesForBonesWithLength;
  58653. private _getLinesForBonesNoLength;
  58654. /** function to revert the mesh and scene back to the initial state. */
  58655. private _revert;
  58656. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58657. private _getAbsoluteBindPoseToRef;
  58658. /** function to build and bind sphere joint points and spur bone representations. */
  58659. private _buildSpheresAndSpurs;
  58660. private _buildLocalAxes;
  58661. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58662. private _displayLinesUpdate;
  58663. /** Changes the displayMode of the skeleton viewer
  58664. * @param mode The displayMode numerical value
  58665. */
  58666. changeDisplayMode(mode: number): void;
  58667. /** Sets a display option of the skeleton viewer
  58668. *
  58669. * | Option | Type | Default | Description |
  58670. * | ---------------- | ------- | ------- | ----------- |
  58671. * | 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`. |
  58672. * | 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`. |
  58673. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58674. * | 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`. |
  58675. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58676. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58677. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58678. *
  58679. * @param option String of the option name
  58680. * @param value The numerical option value
  58681. */
  58682. changeDisplayOptions(option: string, value: number): void;
  58683. /** Release associated resources */
  58684. dispose(): void;
  58685. }
  58686. }
  58687. declare module BABYLON {
  58688. /**
  58689. * Enum for Device Types
  58690. */
  58691. export enum DeviceType {
  58692. /** Generic */
  58693. Generic = 0,
  58694. /** Keyboard */
  58695. Keyboard = 1,
  58696. /** Mouse */
  58697. Mouse = 2,
  58698. /** Touch Pointers */
  58699. Touch = 3,
  58700. /** PS4 Dual Shock */
  58701. DualShock = 4,
  58702. /** Xbox */
  58703. Xbox = 5,
  58704. /** Switch Controller */
  58705. Switch = 6
  58706. }
  58707. /**
  58708. * Enum for All Pointers (Touch/Mouse)
  58709. */
  58710. export enum PointerInput {
  58711. /** Horizontal Axis */
  58712. Horizontal = 0,
  58713. /** Vertical Axis */
  58714. Vertical = 1,
  58715. /** Left Click or Touch */
  58716. LeftClick = 2,
  58717. /** Middle Click */
  58718. MiddleClick = 3,
  58719. /** Right Click */
  58720. RightClick = 4,
  58721. /** Browser Back */
  58722. BrowserBack = 5,
  58723. /** Browser Forward */
  58724. BrowserForward = 6
  58725. }
  58726. /**
  58727. * Enum for Dual Shock Gamepad
  58728. */
  58729. export enum DualShockInput {
  58730. /** Cross */
  58731. Cross = 0,
  58732. /** Circle */
  58733. Circle = 1,
  58734. /** Square */
  58735. Square = 2,
  58736. /** Triangle */
  58737. Triangle = 3,
  58738. /** L1 */
  58739. L1 = 4,
  58740. /** R1 */
  58741. R1 = 5,
  58742. /** L2 */
  58743. L2 = 6,
  58744. /** R2 */
  58745. R2 = 7,
  58746. /** Share */
  58747. Share = 8,
  58748. /** Options */
  58749. Options = 9,
  58750. /** L3 */
  58751. L3 = 10,
  58752. /** R3 */
  58753. R3 = 11,
  58754. /** DPadUp */
  58755. DPadUp = 12,
  58756. /** DPadDown */
  58757. DPadDown = 13,
  58758. /** DPadLeft */
  58759. DPadLeft = 14,
  58760. /** DRight */
  58761. DPadRight = 15,
  58762. /** Home */
  58763. Home = 16,
  58764. /** TouchPad */
  58765. TouchPad = 17,
  58766. /** LStickXAxis */
  58767. LStickXAxis = 18,
  58768. /** LStickYAxis */
  58769. LStickYAxis = 19,
  58770. /** RStickXAxis */
  58771. RStickXAxis = 20,
  58772. /** RStickYAxis */
  58773. RStickYAxis = 21
  58774. }
  58775. /**
  58776. * Enum for Xbox Gamepad
  58777. */
  58778. export enum XboxInput {
  58779. /** A */
  58780. A = 0,
  58781. /** B */
  58782. B = 1,
  58783. /** X */
  58784. X = 2,
  58785. /** Y */
  58786. Y = 3,
  58787. /** LB */
  58788. LB = 4,
  58789. /** RB */
  58790. RB = 5,
  58791. /** LT */
  58792. LT = 6,
  58793. /** RT */
  58794. RT = 7,
  58795. /** Back */
  58796. Back = 8,
  58797. /** Start */
  58798. Start = 9,
  58799. /** LS */
  58800. LS = 10,
  58801. /** RS */
  58802. RS = 11,
  58803. /** DPadUp */
  58804. DPadUp = 12,
  58805. /** DPadDown */
  58806. DPadDown = 13,
  58807. /** DPadLeft */
  58808. DPadLeft = 14,
  58809. /** DRight */
  58810. DPadRight = 15,
  58811. /** Home */
  58812. Home = 16,
  58813. /** LStickXAxis */
  58814. LStickXAxis = 17,
  58815. /** LStickYAxis */
  58816. LStickYAxis = 18,
  58817. /** RStickXAxis */
  58818. RStickXAxis = 19,
  58819. /** RStickYAxis */
  58820. RStickYAxis = 20
  58821. }
  58822. /**
  58823. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58824. */
  58825. export enum SwitchInput {
  58826. /** B */
  58827. B = 0,
  58828. /** A */
  58829. A = 1,
  58830. /** Y */
  58831. Y = 2,
  58832. /** X */
  58833. X = 3,
  58834. /** L */
  58835. L = 4,
  58836. /** R */
  58837. R = 5,
  58838. /** ZL */
  58839. ZL = 6,
  58840. /** ZR */
  58841. ZR = 7,
  58842. /** Minus */
  58843. Minus = 8,
  58844. /** Plus */
  58845. Plus = 9,
  58846. /** LS */
  58847. LS = 10,
  58848. /** RS */
  58849. RS = 11,
  58850. /** DPadUp */
  58851. DPadUp = 12,
  58852. /** DPadDown */
  58853. DPadDown = 13,
  58854. /** DPadLeft */
  58855. DPadLeft = 14,
  58856. /** DRight */
  58857. DPadRight = 15,
  58858. /** Home */
  58859. Home = 16,
  58860. /** Capture */
  58861. Capture = 17,
  58862. /** LStickXAxis */
  58863. LStickXAxis = 18,
  58864. /** LStickYAxis */
  58865. LStickYAxis = 19,
  58866. /** RStickXAxis */
  58867. RStickXAxis = 20,
  58868. /** RStickYAxis */
  58869. RStickYAxis = 21
  58870. }
  58871. }
  58872. declare module BABYLON {
  58873. /**
  58874. * This class will take all inputs from Keyboard, Pointer, and
  58875. * any Gamepads and provide a polling system that all devices
  58876. * will use. This class assumes that there will only be one
  58877. * pointer device and one keyboard.
  58878. */
  58879. export class DeviceInputSystem implements IDisposable {
  58880. /**
  58881. * Returns onDeviceConnected callback property
  58882. * @returns Callback with function to execute when a device is connected
  58883. */
  58884. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58885. /**
  58886. * Sets callback function when a device is connected and executes against all connected devices
  58887. * @param callback Function to execute when a device is connected
  58888. */
  58889. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58890. /**
  58891. * Callback to be triggered when a device is disconnected
  58892. */
  58893. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58894. /**
  58895. * Callback to be triggered when event driven input is updated
  58896. */
  58897. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58898. private _inputs;
  58899. private _gamepads;
  58900. private _keyboardActive;
  58901. private _pointerActive;
  58902. private _elementToAttachTo;
  58903. private _keyboardDownEvent;
  58904. private _keyboardUpEvent;
  58905. private _pointerMoveEvent;
  58906. private _pointerDownEvent;
  58907. private _pointerUpEvent;
  58908. private _gamepadConnectedEvent;
  58909. private _gamepadDisconnectedEvent;
  58910. private _onDeviceConnected;
  58911. private static _MAX_KEYCODES;
  58912. private static _MAX_POINTER_INPUTS;
  58913. private constructor();
  58914. /**
  58915. * Creates a new DeviceInputSystem instance
  58916. * @param engine Engine to pull input element from
  58917. * @returns The new instance
  58918. */
  58919. static Create(engine: Engine): DeviceInputSystem;
  58920. /**
  58921. * Checks for current device input value, given an id and input index
  58922. * @param deviceName Id of connected device
  58923. * @param inputIndex Index of device input
  58924. * @returns Current value of input
  58925. */
  58926. /**
  58927. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58928. * @param deviceType Enum specifiying device type
  58929. * @param deviceSlot "Slot" or index that device is referenced in
  58930. * @param inputIndex Id of input to be checked
  58931. * @returns Current value of input
  58932. */
  58933. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58934. /**
  58935. * Dispose of all the eventlisteners
  58936. */
  58937. dispose(): void;
  58938. /**
  58939. * Checks for existing connections to devices and register them, if necessary
  58940. * Currently handles gamepads and mouse
  58941. */
  58942. private _checkForConnectedDevices;
  58943. /**
  58944. * Add a gamepad to the DeviceInputSystem
  58945. * @param gamepad A single DOM Gamepad object
  58946. */
  58947. private _addGamePad;
  58948. /**
  58949. * Add pointer device to DeviceInputSystem
  58950. * @param deviceType Type of Pointer to add
  58951. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58952. * @param currentX Current X at point of adding
  58953. * @param currentY Current Y at point of adding
  58954. */
  58955. private _addPointerDevice;
  58956. /**
  58957. * Add device and inputs to device array
  58958. * @param deviceType Enum specifiying device type
  58959. * @param deviceSlot "Slot" or index that device is referenced in
  58960. * @param numberOfInputs Number of input entries to create for given device
  58961. */
  58962. private _registerDevice;
  58963. /**
  58964. * Given a specific device name, remove that device from the device map
  58965. * @param deviceType Enum specifiying device type
  58966. * @param deviceSlot "Slot" or index that device is referenced in
  58967. */
  58968. private _unregisterDevice;
  58969. /**
  58970. * Handle all actions that come from keyboard interaction
  58971. */
  58972. private _handleKeyActions;
  58973. /**
  58974. * Handle all actions that come from pointer interaction
  58975. */
  58976. private _handlePointerActions;
  58977. /**
  58978. * Handle all actions that come from gamepad interaction
  58979. */
  58980. private _handleGamepadActions;
  58981. /**
  58982. * Update all non-event based devices with each frame
  58983. * @param deviceType Enum specifiying device type
  58984. * @param deviceSlot "Slot" or index that device is referenced in
  58985. * @param inputIndex Id of input to be checked
  58986. */
  58987. private _updateDevice;
  58988. /**
  58989. * Gets DeviceType from the device name
  58990. * @param deviceName Name of Device from DeviceInputSystem
  58991. * @returns DeviceType enum value
  58992. */
  58993. private _getGamepadDeviceType;
  58994. }
  58995. }
  58996. declare module BABYLON {
  58997. /**
  58998. * Type to handle enforcement of inputs
  58999. */
  59000. 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;
  59001. }
  59002. declare module BABYLON {
  59003. /**
  59004. * Class that handles all input for a specific device
  59005. */
  59006. export class DeviceSource<T extends DeviceType> {
  59007. /** Type of device */
  59008. readonly deviceType: DeviceType;
  59009. /** "Slot" or index that device is referenced in */
  59010. readonly deviceSlot: number;
  59011. /**
  59012. * Observable to handle device input changes per device
  59013. */
  59014. readonly onInputChangedObservable: Observable<{
  59015. inputIndex: DeviceInput<T>;
  59016. previousState: Nullable<number>;
  59017. currentState: Nullable<number>;
  59018. }>;
  59019. private readonly _deviceInputSystem;
  59020. /**
  59021. * Default Constructor
  59022. * @param deviceInputSystem Reference to DeviceInputSystem
  59023. * @param deviceType Type of device
  59024. * @param deviceSlot "Slot" or index that device is referenced in
  59025. */
  59026. constructor(deviceInputSystem: DeviceInputSystem,
  59027. /** Type of device */
  59028. deviceType: DeviceType,
  59029. /** "Slot" or index that device is referenced in */
  59030. deviceSlot?: number);
  59031. /**
  59032. * Get input for specific input
  59033. * @param inputIndex index of specific input on device
  59034. * @returns Input value from DeviceInputSystem
  59035. */
  59036. getInput(inputIndex: DeviceInput<T>): number;
  59037. }
  59038. /**
  59039. * Class to keep track of devices
  59040. */
  59041. export class DeviceSourceManager implements IDisposable {
  59042. /**
  59043. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59044. */
  59045. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59046. /**
  59047. * Observable to be triggered when after a device is disconnected
  59048. */
  59049. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59050. private readonly _devices;
  59051. private readonly _firstDevice;
  59052. private readonly _deviceInputSystem;
  59053. /**
  59054. * Default Constructor
  59055. * @param engine engine to pull input element from
  59056. */
  59057. constructor(engine: Engine);
  59058. /**
  59059. * Gets a DeviceSource, given a type and slot
  59060. * @param deviceType Enum specifying device type
  59061. * @param deviceSlot "Slot" or index that device is referenced in
  59062. * @returns DeviceSource object
  59063. */
  59064. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59065. /**
  59066. * Gets an array of DeviceSource objects for a given device type
  59067. * @param deviceType Enum specifying device type
  59068. * @returns Array of DeviceSource objects
  59069. */
  59070. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59071. /**
  59072. * Returns a read-only list of all available devices
  59073. * @returns Read-only array with active devices
  59074. */
  59075. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59076. /**
  59077. * Dispose of DeviceInputSystem and other parts
  59078. */
  59079. dispose(): void;
  59080. /**
  59081. * Function to add device name to device list
  59082. * @param deviceType Enum specifying device type
  59083. * @param deviceSlot "Slot" or index that device is referenced in
  59084. */
  59085. private _addDevice;
  59086. /**
  59087. * Function to remove device name to device list
  59088. * @param deviceType Enum specifying device type
  59089. * @param deviceSlot "Slot" or index that device is referenced in
  59090. */
  59091. private _removeDevice;
  59092. /**
  59093. * Updates array storing first connected device of each type
  59094. * @param type Type of Device
  59095. */
  59096. private _updateFirstDevices;
  59097. }
  59098. }
  59099. declare module BABYLON {
  59100. /**
  59101. * Options to create the null engine
  59102. */
  59103. export class NullEngineOptions {
  59104. /**
  59105. * Render width (Default: 512)
  59106. */
  59107. renderWidth: number;
  59108. /**
  59109. * Render height (Default: 256)
  59110. */
  59111. renderHeight: number;
  59112. /**
  59113. * Texture size (Default: 512)
  59114. */
  59115. textureSize: number;
  59116. /**
  59117. * If delta time between frames should be constant
  59118. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59119. */
  59120. deterministicLockstep: boolean;
  59121. /**
  59122. * Maximum about of steps between frames (Default: 4)
  59123. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59124. */
  59125. lockstepMaxSteps: number;
  59126. /**
  59127. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59128. */
  59129. useHighPrecisionMatrix?: boolean;
  59130. }
  59131. /**
  59132. * The null engine class provides support for headless version of babylon.js.
  59133. * This can be used in server side scenario or for testing purposes
  59134. */
  59135. export class NullEngine extends Engine {
  59136. private _options;
  59137. /**
  59138. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59139. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59140. * @returns true if engine is in deterministic lock step mode
  59141. */
  59142. isDeterministicLockStep(): boolean;
  59143. /**
  59144. * Gets the max steps when engine is running in deterministic lock step
  59145. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59146. * @returns the max steps
  59147. */
  59148. getLockstepMaxSteps(): number;
  59149. /**
  59150. * Gets the current hardware scaling level.
  59151. * By default the hardware scaling level is computed from the window device ratio.
  59152. * 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.
  59153. * @returns a number indicating the current hardware scaling level
  59154. */
  59155. getHardwareScalingLevel(): number;
  59156. constructor(options?: NullEngineOptions);
  59157. /**
  59158. * Creates a vertex buffer
  59159. * @param vertices the data for the vertex buffer
  59160. * @returns the new WebGL static buffer
  59161. */
  59162. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59163. /**
  59164. * Creates a new index buffer
  59165. * @param indices defines the content of the index buffer
  59166. * @param updatable defines if the index buffer must be updatable
  59167. * @returns a new webGL buffer
  59168. */
  59169. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59170. /**
  59171. * Clear the current render buffer or the current render target (if any is set up)
  59172. * @param color defines the color to use
  59173. * @param backBuffer defines if the back buffer must be cleared
  59174. * @param depth defines if the depth buffer must be cleared
  59175. * @param stencil defines if the stencil buffer must be cleared
  59176. */
  59177. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59178. /**
  59179. * Gets the current render width
  59180. * @param useScreen defines if screen size must be used (or the current render target if any)
  59181. * @returns a number defining the current render width
  59182. */
  59183. getRenderWidth(useScreen?: boolean): number;
  59184. /**
  59185. * Gets the current render height
  59186. * @param useScreen defines if screen size must be used (or the current render target if any)
  59187. * @returns a number defining the current render height
  59188. */
  59189. getRenderHeight(useScreen?: boolean): number;
  59190. /**
  59191. * Set the WebGL's viewport
  59192. * @param viewport defines the viewport element to be used
  59193. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59194. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59195. */
  59196. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59197. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59198. /**
  59199. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59200. * @param pipelineContext defines the pipeline context to use
  59201. * @param uniformsNames defines the list of uniform names
  59202. * @returns an array of webGL uniform locations
  59203. */
  59204. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59205. /**
  59206. * Gets the lsit of active attributes for a given webGL program
  59207. * @param pipelineContext defines the pipeline context to use
  59208. * @param attributesNames defines the list of attribute names to get
  59209. * @returns an array of indices indicating the offset of each attribute
  59210. */
  59211. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59212. /**
  59213. * Binds an effect to the webGL context
  59214. * @param effect defines the effect to bind
  59215. */
  59216. bindSamplers(effect: Effect): void;
  59217. /**
  59218. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  59219. * @param effect defines the effect to activate
  59220. */
  59221. enableEffect(effect: Effect): void;
  59222. /**
  59223. * Set various states to the webGL context
  59224. * @param culling defines backface culling state
  59225. * @param zOffset defines the value to apply to zOffset (0 by default)
  59226. * @param force defines if states must be applied even if cache is up to date
  59227. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59228. */
  59229. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59230. /**
  59231. * Set the value of an uniform to an array of int32
  59232. * @param uniform defines the webGL uniform location where to store the value
  59233. * @param array defines the array of int32 to store
  59234. * @returns true if value was set
  59235. */
  59236. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59237. /**
  59238. * Set the value of an uniform to an array of int32 (stored as vec2)
  59239. * @param uniform defines the webGL uniform location where to store the value
  59240. * @param array defines the array of int32 to store
  59241. * @returns true if value was set
  59242. */
  59243. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59244. /**
  59245. * Set the value of an uniform to an array of int32 (stored as vec3)
  59246. * @param uniform defines the webGL uniform location where to store the value
  59247. * @param array defines the array of int32 to store
  59248. * @returns true if value was set
  59249. */
  59250. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59251. /**
  59252. * Set the value of an uniform to an array of int32 (stored as vec4)
  59253. * @param uniform defines the webGL uniform location where to store the value
  59254. * @param array defines the array of int32 to store
  59255. * @returns true if value was set
  59256. */
  59257. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59258. /**
  59259. * Set the value of an uniform to an array of float32
  59260. * @param uniform defines the webGL uniform location where to store the value
  59261. * @param array defines the array of float32 to store
  59262. * @returns true if value was set
  59263. */
  59264. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59265. /**
  59266. * Set the value of an uniform to an array of float32 (stored as vec2)
  59267. * @param uniform defines the webGL uniform location where to store the value
  59268. * @param array defines the array of float32 to store
  59269. * @returns true if value was set
  59270. */
  59271. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59272. /**
  59273. * Set the value of an uniform to an array of float32 (stored as vec3)
  59274. * @param uniform defines the webGL uniform location where to store the value
  59275. * @param array defines the array of float32 to store
  59276. * @returns true if value was set
  59277. */
  59278. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59279. /**
  59280. * Set the value of an uniform to an array of float32 (stored as vec4)
  59281. * @param uniform defines the webGL uniform location where to store the value
  59282. * @param array defines the array of float32 to store
  59283. * @returns true if value was set
  59284. */
  59285. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59286. /**
  59287. * Set the value of an uniform to an array of number
  59288. * @param uniform defines the webGL uniform location where to store the value
  59289. * @param array defines the array of number to store
  59290. * @returns true if value was set
  59291. */
  59292. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59293. /**
  59294. * Set the value of an uniform to an array of number (stored as vec2)
  59295. * @param uniform defines the webGL uniform location where to store the value
  59296. * @param array defines the array of number to store
  59297. * @returns true if value was set
  59298. */
  59299. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59300. /**
  59301. * Set the value of an uniform to an array of number (stored as vec3)
  59302. * @param uniform defines the webGL uniform location where to store the value
  59303. * @param array defines the array of number to store
  59304. * @returns true if value was set
  59305. */
  59306. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59307. /**
  59308. * Set the value of an uniform to an array of number (stored as vec4)
  59309. * @param uniform defines the webGL uniform location where to store the value
  59310. * @param array defines the array of number to store
  59311. * @returns true if value was set
  59312. */
  59313. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59314. /**
  59315. * Set the value of an uniform to an array of float32 (stored as matrices)
  59316. * @param uniform defines the webGL uniform location where to store the value
  59317. * @param matrices defines the array of float32 to store
  59318. * @returns true if value was set
  59319. */
  59320. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59321. /**
  59322. * Set the value of an uniform to a matrix (3x3)
  59323. * @param uniform defines the webGL uniform location where to store the value
  59324. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59325. * @returns true if value was set
  59326. */
  59327. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59328. /**
  59329. * Set the value of an uniform to a matrix (2x2)
  59330. * @param uniform defines the webGL uniform location where to store the value
  59331. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59332. * @returns true if value was set
  59333. */
  59334. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59335. /**
  59336. * Set the value of an uniform to a number (float)
  59337. * @param uniform defines the webGL uniform location where to store the value
  59338. * @param value defines the float number to store
  59339. * @returns true if value was set
  59340. */
  59341. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59342. /**
  59343. * Set the value of an uniform to a vec2
  59344. * @param uniform defines the webGL uniform location where to store the value
  59345. * @param x defines the 1st component of the value
  59346. * @param y defines the 2nd component of the value
  59347. * @returns true if value was set
  59348. */
  59349. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59350. /**
  59351. * Set the value of an uniform to a vec3
  59352. * @param uniform defines the webGL uniform location where to store the value
  59353. * @param x defines the 1st component of the value
  59354. * @param y defines the 2nd component of the value
  59355. * @param z defines the 3rd component of the value
  59356. * @returns true if value was set
  59357. */
  59358. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59359. /**
  59360. * Set the value of an uniform to a boolean
  59361. * @param uniform defines the webGL uniform location where to store the value
  59362. * @param bool defines the boolean to store
  59363. * @returns true if value was set
  59364. */
  59365. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59366. /**
  59367. * Set the value of an uniform to a vec4
  59368. * @param uniform defines the webGL uniform location where to store the value
  59369. * @param x defines the 1st component of the value
  59370. * @param y defines the 2nd component of the value
  59371. * @param z defines the 3rd component of the value
  59372. * @param w defines the 4th component of the value
  59373. * @returns true if value was set
  59374. */
  59375. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59376. /**
  59377. * Sets the current alpha mode
  59378. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59379. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59380. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59381. */
  59382. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59383. /**
  59384. * Bind webGl buffers directly to the webGL context
  59385. * @param vertexBuffers defines the vertex buffer to bind
  59386. * @param indexBuffer defines the index buffer to bind
  59387. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59388. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59389. * @param effect defines the effect associated with the vertex buffer
  59390. */
  59391. bindBuffers(vertexBuffers: {
  59392. [key: string]: VertexBuffer;
  59393. }, indexBuffer: DataBuffer, effect: Effect): void;
  59394. /**
  59395. * Force the entire cache to be cleared
  59396. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59397. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59398. */
  59399. wipeCaches(bruteForce?: boolean): void;
  59400. /**
  59401. * Send a draw order
  59402. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59403. * @param indexStart defines the starting index
  59404. * @param indexCount defines the number of index to draw
  59405. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59406. */
  59407. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59408. /**
  59409. * Draw a list of indexed primitives
  59410. * @param fillMode defines the primitive to use
  59411. * @param indexStart defines the starting index
  59412. * @param indexCount defines the number of index to draw
  59413. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59414. */
  59415. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59416. /**
  59417. * Draw a list of unindexed primitives
  59418. * @param fillMode defines the primitive to use
  59419. * @param verticesStart defines the index of first vertex to draw
  59420. * @param verticesCount defines the count of vertices to draw
  59421. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59422. */
  59423. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59424. /** @hidden */
  59425. protected _createTexture(): WebGLTexture;
  59426. /** @hidden */
  59427. _releaseTexture(texture: InternalTexture): void;
  59428. /**
  59429. * Usually called from Texture.ts.
  59430. * Passed information to create a WebGLTexture
  59431. * @param urlArg defines a value which contains one of the following:
  59432. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59433. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59434. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59435. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59436. * @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)
  59437. * @param scene needed for loading to the correct scene
  59438. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59439. * @param onLoad optional callback to be called upon successful completion
  59440. * @param onError optional callback to be called upon failure
  59441. * @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
  59442. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59443. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59444. * @param forcedExtension defines the extension to use to pick the right loader
  59445. * @param mimeType defines an optional mime type
  59446. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59447. */
  59448. 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;
  59449. /**
  59450. * Creates a new render target texture
  59451. * @param size defines the size of the texture
  59452. * @param options defines the options used to create the texture
  59453. * @returns a new render target texture stored in an InternalTexture
  59454. */
  59455. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59456. /**
  59457. * Update the sampling mode of a given texture
  59458. * @param samplingMode defines the required sampling mode
  59459. * @param texture defines the texture to update
  59460. */
  59461. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59462. /**
  59463. * Binds the frame buffer to the specified texture.
  59464. * @param texture The texture to render to or null for the default canvas
  59465. * @param faceIndex The face of the texture to render to in case of cube texture
  59466. * @param requiredWidth The width of the target to render to
  59467. * @param requiredHeight The height of the target to render to
  59468. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59469. * @param lodLevel defines le lod level to bind to the frame buffer
  59470. */
  59471. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59472. /**
  59473. * Unbind the current render target texture from the webGL context
  59474. * @param texture defines the render target texture to unbind
  59475. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59476. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59477. */
  59478. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59479. /**
  59480. * Creates a dynamic vertex buffer
  59481. * @param vertices the data for the dynamic vertex buffer
  59482. * @returns the new WebGL dynamic buffer
  59483. */
  59484. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59485. /**
  59486. * Update the content of a dynamic texture
  59487. * @param texture defines the texture to update
  59488. * @param canvas defines the canvas containing the source
  59489. * @param invertY defines if data must be stored with Y axis inverted
  59490. * @param premulAlpha defines if alpha is stored as premultiplied
  59491. * @param format defines the format of the data
  59492. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59493. */
  59494. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59495. /**
  59496. * Gets a boolean indicating if all created effects are ready
  59497. * @returns true if all effects are ready
  59498. */
  59499. areAllEffectsReady(): boolean;
  59500. /**
  59501. * @hidden
  59502. * Get the current error code of the webGL context
  59503. * @returns the error code
  59504. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59505. */
  59506. getError(): number;
  59507. /** @hidden */
  59508. _getUnpackAlignement(): number;
  59509. /** @hidden */
  59510. _unpackFlipY(value: boolean): void;
  59511. /**
  59512. * Update a dynamic index buffer
  59513. * @param indexBuffer defines the target index buffer
  59514. * @param indices defines the data to update
  59515. * @param offset defines the offset in the target index buffer where update should start
  59516. */
  59517. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59518. /**
  59519. * Updates a dynamic vertex buffer.
  59520. * @param vertexBuffer the vertex buffer to update
  59521. * @param vertices the data used to update the vertex buffer
  59522. * @param byteOffset the byte offset of the data (optional)
  59523. * @param byteLength the byte length of the data (optional)
  59524. */
  59525. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59526. /** @hidden */
  59527. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59528. /** @hidden */
  59529. _bindTexture(channel: number, texture: InternalTexture): void;
  59530. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59531. /**
  59532. * 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
  59533. */
  59534. releaseEffects(): void;
  59535. displayLoadingUI(): void;
  59536. hideLoadingUI(): void;
  59537. /** @hidden */
  59538. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59539. /** @hidden */
  59540. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59541. /** @hidden */
  59542. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59543. /** @hidden */
  59544. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59545. }
  59546. }
  59547. declare module BABYLON {
  59548. /** @hidden */
  59549. export class _OcclusionDataStorage {
  59550. /** @hidden */
  59551. occlusionInternalRetryCounter: number;
  59552. /** @hidden */
  59553. isOcclusionQueryInProgress: boolean;
  59554. /** @hidden */
  59555. isOccluded: boolean;
  59556. /** @hidden */
  59557. occlusionRetryCount: number;
  59558. /** @hidden */
  59559. occlusionType: number;
  59560. /** @hidden */
  59561. occlusionQueryAlgorithmType: number;
  59562. }
  59563. interface Engine {
  59564. /**
  59565. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59566. * @return the new query
  59567. */
  59568. createQuery(): WebGLQuery;
  59569. /**
  59570. * Delete and release a webGL query
  59571. * @param query defines the query to delete
  59572. * @return the current engine
  59573. */
  59574. deleteQuery(query: WebGLQuery): Engine;
  59575. /**
  59576. * Check if a given query has resolved and got its value
  59577. * @param query defines the query to check
  59578. * @returns true if the query got its value
  59579. */
  59580. isQueryResultAvailable(query: WebGLQuery): boolean;
  59581. /**
  59582. * Gets the value of a given query
  59583. * @param query defines the query to check
  59584. * @returns the value of the query
  59585. */
  59586. getQueryResult(query: WebGLQuery): number;
  59587. /**
  59588. * Initiates an occlusion query
  59589. * @param algorithmType defines the algorithm to use
  59590. * @param query defines the query to use
  59591. * @returns the current engine
  59592. * @see https://doc.babylonjs.com/features/occlusionquery
  59593. */
  59594. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59595. /**
  59596. * Ends an occlusion query
  59597. * @see https://doc.babylonjs.com/features/occlusionquery
  59598. * @param algorithmType defines the algorithm to use
  59599. * @returns the current engine
  59600. */
  59601. endOcclusionQuery(algorithmType: number): Engine;
  59602. /**
  59603. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59604. * Please note that only one query can be issued at a time
  59605. * @returns a time token used to track the time span
  59606. */
  59607. startTimeQuery(): Nullable<_TimeToken>;
  59608. /**
  59609. * Ends a time query
  59610. * @param token defines the token used to measure the time span
  59611. * @returns the time spent (in ns)
  59612. */
  59613. endTimeQuery(token: _TimeToken): int;
  59614. /** @hidden */
  59615. _currentNonTimestampToken: Nullable<_TimeToken>;
  59616. /** @hidden */
  59617. _createTimeQuery(): WebGLQuery;
  59618. /** @hidden */
  59619. _deleteTimeQuery(query: WebGLQuery): void;
  59620. /** @hidden */
  59621. _getGlAlgorithmType(algorithmType: number): number;
  59622. /** @hidden */
  59623. _getTimeQueryResult(query: WebGLQuery): any;
  59624. /** @hidden */
  59625. _getTimeQueryAvailability(query: WebGLQuery): any;
  59626. }
  59627. interface AbstractMesh {
  59628. /**
  59629. * Backing filed
  59630. * @hidden
  59631. */
  59632. __occlusionDataStorage: _OcclusionDataStorage;
  59633. /**
  59634. * Access property
  59635. * @hidden
  59636. */
  59637. _occlusionDataStorage: _OcclusionDataStorage;
  59638. /**
  59639. * 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.
  59640. * The default value is -1 which means don't break the query and wait till the result
  59641. * @see https://doc.babylonjs.com/features/occlusionquery
  59642. */
  59643. occlusionRetryCount: number;
  59644. /**
  59645. * 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:
  59646. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59647. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59648. * * 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.
  59649. * @see https://doc.babylonjs.com/features/occlusionquery
  59650. */
  59651. occlusionType: number;
  59652. /**
  59653. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59654. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59655. * * 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.
  59656. * @see https://doc.babylonjs.com/features/occlusionquery
  59657. */
  59658. occlusionQueryAlgorithmType: number;
  59659. /**
  59660. * 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
  59661. * @see https://doc.babylonjs.com/features/occlusionquery
  59662. */
  59663. isOccluded: boolean;
  59664. /**
  59665. * Flag to check the progress status of the query
  59666. * @see https://doc.babylonjs.com/features/occlusionquery
  59667. */
  59668. isOcclusionQueryInProgress: boolean;
  59669. }
  59670. }
  59671. declare module BABYLON {
  59672. /** @hidden */
  59673. export var _forceTransformFeedbackToBundle: boolean;
  59674. interface Engine {
  59675. /**
  59676. * Creates a webGL transform feedback object
  59677. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59678. * @returns the webGL transform feedback object
  59679. */
  59680. createTransformFeedback(): WebGLTransformFeedback;
  59681. /**
  59682. * Delete a webGL transform feedback object
  59683. * @param value defines the webGL transform feedback object to delete
  59684. */
  59685. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59686. /**
  59687. * Bind a webGL transform feedback object to the webgl context
  59688. * @param value defines the webGL transform feedback object to bind
  59689. */
  59690. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59691. /**
  59692. * Begins a transform feedback operation
  59693. * @param usePoints defines if points or triangles must be used
  59694. */
  59695. beginTransformFeedback(usePoints: boolean): void;
  59696. /**
  59697. * Ends a transform feedback operation
  59698. */
  59699. endTransformFeedback(): void;
  59700. /**
  59701. * Specify the varyings to use with transform feedback
  59702. * @param program defines the associated webGL program
  59703. * @param value defines the list of strings representing the varying names
  59704. */
  59705. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59706. /**
  59707. * Bind a webGL buffer for a transform feedback operation
  59708. * @param value defines the webGL buffer to bind
  59709. */
  59710. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59711. }
  59712. }
  59713. declare module BABYLON {
  59714. /**
  59715. * Class used to define an additional view for the engine
  59716. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59717. */
  59718. export class EngineView {
  59719. /** Defines the canvas where to render the view */
  59720. target: HTMLCanvasElement;
  59721. /** Defines an optional camera used to render the view (will use active camera else) */
  59722. camera?: Camera;
  59723. }
  59724. interface Engine {
  59725. /**
  59726. * Gets or sets the HTML element to use for attaching events
  59727. */
  59728. inputElement: Nullable<HTMLElement>;
  59729. /**
  59730. * Gets the current engine view
  59731. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59732. */
  59733. activeView: Nullable<EngineView>;
  59734. /** Gets or sets the list of views */
  59735. views: EngineView[];
  59736. /**
  59737. * Register a new child canvas
  59738. * @param canvas defines the canvas to register
  59739. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59740. * @returns the associated view
  59741. */
  59742. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59743. /**
  59744. * Remove a registered child canvas
  59745. * @param canvas defines the canvas to remove
  59746. * @returns the current engine
  59747. */
  59748. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59749. }
  59750. }
  59751. declare module BABYLON {
  59752. interface Engine {
  59753. /** @hidden */
  59754. _excludedCompressedTextures: string[];
  59755. /** @hidden */
  59756. _textureFormatInUse: string;
  59757. /**
  59758. * Gets the list of texture formats supported
  59759. */
  59760. readonly texturesSupported: Array<string>;
  59761. /**
  59762. * Gets the texture format in use
  59763. */
  59764. readonly textureFormatInUse: Nullable<string>;
  59765. /**
  59766. * Set the compressed texture extensions or file names to skip.
  59767. *
  59768. * @param skippedFiles defines the list of those texture files you want to skip
  59769. * Example: [".dds", ".env", "myfile.png"]
  59770. */
  59771. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59772. /**
  59773. * Set the compressed texture format to use, based on the formats you have, and the formats
  59774. * supported by the hardware / browser.
  59775. *
  59776. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59777. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59778. * to API arguments needed to compressed textures. This puts the burden on the container
  59779. * generator to house the arcane code for determining these for current & future formats.
  59780. *
  59781. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59782. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59783. *
  59784. * Note: The result of this call is not taken into account when a texture is base64.
  59785. *
  59786. * @param formatsAvailable defines the list of those format families you have created
  59787. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59788. *
  59789. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59790. * @returns The extension selected.
  59791. */
  59792. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59793. }
  59794. }
  59795. declare module BABYLON {
  59796. /** @hidden */
  59797. export var rgbdEncodePixelShader: {
  59798. name: string;
  59799. shader: string;
  59800. };
  59801. }
  59802. declare module BABYLON {
  59803. /**
  59804. * Raw texture data and descriptor sufficient for WebGL texture upload
  59805. */
  59806. export interface EnvironmentTextureInfo {
  59807. /**
  59808. * Version of the environment map
  59809. */
  59810. version: number;
  59811. /**
  59812. * Width of image
  59813. */
  59814. width: number;
  59815. /**
  59816. * Irradiance information stored in the file.
  59817. */
  59818. irradiance: any;
  59819. /**
  59820. * Specular information stored in the file.
  59821. */
  59822. specular: any;
  59823. }
  59824. /**
  59825. * Defines One Image in the file. It requires only the position in the file
  59826. * as well as the length.
  59827. */
  59828. interface BufferImageData {
  59829. /**
  59830. * Length of the image data.
  59831. */
  59832. length: number;
  59833. /**
  59834. * Position of the data from the null terminator delimiting the end of the JSON.
  59835. */
  59836. position: number;
  59837. }
  59838. /**
  59839. * Defines the specular data enclosed in the file.
  59840. * This corresponds to the version 1 of the data.
  59841. */
  59842. export interface EnvironmentTextureSpecularInfoV1 {
  59843. /**
  59844. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59845. */
  59846. specularDataPosition?: number;
  59847. /**
  59848. * This contains all the images data needed to reconstruct the cubemap.
  59849. */
  59850. mipmaps: Array<BufferImageData>;
  59851. /**
  59852. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59853. */
  59854. lodGenerationScale: number;
  59855. }
  59856. /**
  59857. * Sets of helpers addressing the serialization and deserialization of environment texture
  59858. * stored in a BabylonJS env file.
  59859. * Those files are usually stored as .env files.
  59860. */
  59861. export class EnvironmentTextureTools {
  59862. /**
  59863. * Magic number identifying the env file.
  59864. */
  59865. private static _MagicBytes;
  59866. /**
  59867. * Gets the environment info from an env file.
  59868. * @param data The array buffer containing the .env bytes.
  59869. * @returns the environment file info (the json header) if successfully parsed.
  59870. */
  59871. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59872. /**
  59873. * Creates an environment texture from a loaded cube texture.
  59874. * @param texture defines the cube texture to convert in env file
  59875. * @return a promise containing the environment data if succesfull.
  59876. */
  59877. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59878. /**
  59879. * Creates a JSON representation of the spherical data.
  59880. * @param texture defines the texture containing the polynomials
  59881. * @return the JSON representation of the spherical info
  59882. */
  59883. private static _CreateEnvTextureIrradiance;
  59884. /**
  59885. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59886. * @param data the image data
  59887. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59888. * @return the views described by info providing access to the underlying buffer
  59889. */
  59890. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59891. /**
  59892. * Uploads the texture info contained in the env file to the GPU.
  59893. * @param texture defines the internal texture to upload to
  59894. * @param data defines the data to load
  59895. * @param info defines the texture info retrieved through the GetEnvInfo method
  59896. * @returns a promise
  59897. */
  59898. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59899. private static _OnImageReadyAsync;
  59900. /**
  59901. * Uploads the levels of image data to the GPU.
  59902. * @param texture defines the internal texture to upload to
  59903. * @param imageData defines the array buffer views of image data [mipmap][face]
  59904. * @returns a promise
  59905. */
  59906. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59907. /**
  59908. * Uploads spherical polynomials information to the texture.
  59909. * @param texture defines the texture we are trying to upload the information to
  59910. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59911. */
  59912. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59913. /** @hidden */
  59914. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59915. }
  59916. }
  59917. declare module BABYLON {
  59918. /**
  59919. * Container for accessors for natively-stored mesh data buffers.
  59920. */
  59921. class NativeDataBuffer extends DataBuffer {
  59922. /**
  59923. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59924. */
  59925. nativeIndexBuffer?: any;
  59926. /**
  59927. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59928. */
  59929. nativeVertexBuffer?: any;
  59930. }
  59931. /** @hidden */
  59932. class NativeTexture extends InternalTexture {
  59933. getInternalTexture(): InternalTexture;
  59934. getViewCount(): number;
  59935. }
  59936. /** @hidden */
  59937. export class NativeEngine extends Engine {
  59938. private readonly _native;
  59939. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59940. private readonly INVALID_HANDLE;
  59941. private _boundBuffersVertexArray;
  59942. private _currentDepthTest;
  59943. getHardwareScalingLevel(): number;
  59944. constructor();
  59945. dispose(): void;
  59946. /**
  59947. * Can be used to override the current requestAnimationFrame requester.
  59948. * @hidden
  59949. */
  59950. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59951. /**
  59952. * Override default engine behavior.
  59953. * @param color
  59954. * @param backBuffer
  59955. * @param depth
  59956. * @param stencil
  59957. */
  59958. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59959. /**
  59960. * Gets host document
  59961. * @returns the host document object
  59962. */
  59963. getHostDocument(): Nullable<Document>;
  59964. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59965. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59966. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59967. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59968. [key: string]: VertexBuffer;
  59969. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59970. bindBuffers(vertexBuffers: {
  59971. [key: string]: VertexBuffer;
  59972. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59973. recordVertexArrayObject(vertexBuffers: {
  59974. [key: string]: VertexBuffer;
  59975. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59976. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59977. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59978. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59979. /**
  59980. * Draw a list of indexed primitives
  59981. * @param fillMode defines the primitive to use
  59982. * @param indexStart defines the starting index
  59983. * @param indexCount defines the number of index to draw
  59984. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59985. */
  59986. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59987. /**
  59988. * Draw a list of unindexed primitives
  59989. * @param fillMode defines the primitive to use
  59990. * @param verticesStart defines the index of first vertex to draw
  59991. * @param verticesCount defines the count of vertices to draw
  59992. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59993. */
  59994. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59995. createPipelineContext(): IPipelineContext;
  59996. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59997. /** @hidden */
  59998. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59999. /** @hidden */
  60000. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  60001. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60002. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60003. protected _setProgram(program: WebGLProgram): void;
  60004. _releaseEffect(effect: Effect): void;
  60005. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  60006. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  60007. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  60008. bindSamplers(effect: Effect): void;
  60009. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  60010. getRenderWidth(useScreen?: boolean): number;
  60011. getRenderHeight(useScreen?: boolean): number;
  60012. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60013. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60014. /**
  60015. * Set the z offset to apply to current rendering
  60016. * @param value defines the offset to apply
  60017. */
  60018. setZOffset(value: number): void;
  60019. /**
  60020. * Gets the current value of the zOffset
  60021. * @returns the current zOffset state
  60022. */
  60023. getZOffset(): number;
  60024. /**
  60025. * Enable or disable depth buffering
  60026. * @param enable defines the state to set
  60027. */
  60028. setDepthBuffer(enable: boolean): void;
  60029. /**
  60030. * Gets a boolean indicating if depth writing is enabled
  60031. * @returns the current depth writing state
  60032. */
  60033. getDepthWrite(): boolean;
  60034. setDepthFunctionToGreater(): void;
  60035. setDepthFunctionToGreaterOrEqual(): void;
  60036. setDepthFunctionToLess(): void;
  60037. setDepthFunctionToLessOrEqual(): void;
  60038. /**
  60039. * Enable or disable depth writing
  60040. * @param enable defines the state to set
  60041. */
  60042. setDepthWrite(enable: boolean): void;
  60043. /**
  60044. * Enable or disable color writing
  60045. * @param enable defines the state to set
  60046. */
  60047. setColorWrite(enable: boolean): void;
  60048. /**
  60049. * Gets a boolean indicating if color writing is enabled
  60050. * @returns the current color writing state
  60051. */
  60052. getColorWrite(): boolean;
  60053. /**
  60054. * Sets alpha constants used by some alpha blending modes
  60055. * @param r defines the red component
  60056. * @param g defines the green component
  60057. * @param b defines the blue component
  60058. * @param a defines the alpha component
  60059. */
  60060. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60061. /**
  60062. * Sets the current alpha mode
  60063. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60064. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60065. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60066. */
  60067. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60068. /**
  60069. * Gets the current alpha mode
  60070. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60071. * @returns the current alpha mode
  60072. */
  60073. getAlphaMode(): number;
  60074. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60075. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60076. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60077. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60078. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60079. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60080. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60081. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60082. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60083. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60084. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60085. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60086. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60087. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60088. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60089. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60090. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60091. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60092. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60093. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60094. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60095. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60096. wipeCaches(bruteForce?: boolean): void;
  60097. protected _createTexture(): WebGLTexture;
  60098. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60099. /**
  60100. * Update the content of a dynamic texture
  60101. * @param texture defines the texture to update
  60102. * @param canvas defines the canvas containing the source
  60103. * @param invertY defines if data must be stored with Y axis inverted
  60104. * @param premulAlpha defines if alpha is stored as premultiplied
  60105. * @param format defines the format of the data
  60106. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60107. */
  60108. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60109. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60110. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60111. /**
  60112. * Usually called from Texture.ts.
  60113. * Passed information to create a WebGLTexture
  60114. * @param url defines a value which contains one of the following:
  60115. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60116. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60117. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60118. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60119. * @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)
  60120. * @param scene needed for loading to the correct scene
  60121. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60122. * @param onLoad optional callback to be called upon successful completion
  60123. * @param onError optional callback to be called upon failure
  60124. * @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
  60125. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60126. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60127. * @param forcedExtension defines the extension to use to pick the right loader
  60128. * @param mimeType defines an optional mime type
  60129. * @param loaderOptions options to be passed to the loader
  60130. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60131. */
  60132. 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;
  60133. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60134. _releaseFramebufferObjects(texture: InternalTexture): void;
  60135. /**
  60136. * Creates a cube texture
  60137. * @param rootUrl defines the url where the files to load is located
  60138. * @param scene defines the current scene
  60139. * @param files defines the list of files to load (1 per face)
  60140. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60141. * @param onLoad defines an optional callback raised when the texture is loaded
  60142. * @param onError defines an optional callback raised if there is an issue to load the texture
  60143. * @param format defines the format of the data
  60144. * @param forcedExtension defines the extension to use to pick the right loader
  60145. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60146. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60147. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60148. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60149. * @returns the cube texture as an InternalTexture
  60150. */
  60151. 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;
  60152. createRenderTargetTexture(size: number | {
  60153. width: number;
  60154. height: number;
  60155. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60156. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60157. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60158. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60159. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60160. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60161. /**
  60162. * Updates a dynamic vertex buffer.
  60163. * @param vertexBuffer the vertex buffer to update
  60164. * @param data the data used to update the vertex buffer
  60165. * @param byteOffset the byte offset of the data (optional)
  60166. * @param byteLength the byte length of the data (optional)
  60167. */
  60168. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60169. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60170. private _updateAnisotropicLevel;
  60171. private _getAddressMode;
  60172. /** @hidden */
  60173. _bindTexture(channel: number, texture: InternalTexture): void;
  60174. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60175. releaseEffects(): void;
  60176. /** @hidden */
  60177. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60178. /** @hidden */
  60179. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60180. /** @hidden */
  60181. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60182. /** @hidden */
  60183. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60184. private _getNativeSamplingMode;
  60185. private _getNativeTextureFormat;
  60186. private _getNativeAlphaMode;
  60187. private _getNativeAttribType;
  60188. }
  60189. }
  60190. declare module BABYLON {
  60191. /**
  60192. * Helper class to create the best engine depending on the current hardware
  60193. */
  60194. export class EngineFactory {
  60195. /**
  60196. * Creates an engine based on the capabilities of the underlying hardware
  60197. * @param canvas Defines the canvas to use to display the result
  60198. * @param options Defines the options passed to the engine to create the context dependencies
  60199. * @returns a promise that resolves with the created engine
  60200. */
  60201. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60202. }
  60203. }
  60204. declare module BABYLON {
  60205. /**
  60206. * Gather the list of clipboard event types as constants.
  60207. */
  60208. export class ClipboardEventTypes {
  60209. /**
  60210. * The clipboard event is fired when a copy command is active (pressed).
  60211. */
  60212. static readonly COPY: number;
  60213. /**
  60214. * The clipboard event is fired when a cut command is active (pressed).
  60215. */
  60216. static readonly CUT: number;
  60217. /**
  60218. * The clipboard event is fired when a paste command is active (pressed).
  60219. */
  60220. static readonly PASTE: number;
  60221. }
  60222. /**
  60223. * This class is used to store clipboard related info for the onClipboardObservable event.
  60224. */
  60225. export class ClipboardInfo {
  60226. /**
  60227. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60228. */
  60229. type: number;
  60230. /**
  60231. * Defines the related dom event
  60232. */
  60233. event: ClipboardEvent;
  60234. /**
  60235. *Creates an instance of ClipboardInfo.
  60236. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60237. * @param event Defines the related dom event
  60238. */
  60239. constructor(
  60240. /**
  60241. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60242. */
  60243. type: number,
  60244. /**
  60245. * Defines the related dom event
  60246. */
  60247. event: ClipboardEvent);
  60248. /**
  60249. * Get the clipboard event's type from the keycode.
  60250. * @param keyCode Defines the keyCode for the current keyboard event.
  60251. * @return {number}
  60252. */
  60253. static GetTypeFromCharacter(keyCode: number): number;
  60254. }
  60255. }
  60256. declare module BABYLON {
  60257. /**
  60258. * Google Daydream controller
  60259. */
  60260. export class DaydreamController extends WebVRController {
  60261. /**
  60262. * Base Url for the controller model.
  60263. */
  60264. static MODEL_BASE_URL: string;
  60265. /**
  60266. * File name for the controller model.
  60267. */
  60268. static MODEL_FILENAME: string;
  60269. /**
  60270. * Gamepad Id prefix used to identify Daydream Controller.
  60271. */
  60272. static readonly GAMEPAD_ID_PREFIX: string;
  60273. /**
  60274. * Creates a new DaydreamController from a gamepad
  60275. * @param vrGamepad the gamepad that the controller should be created from
  60276. */
  60277. constructor(vrGamepad: any);
  60278. /**
  60279. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60280. * @param scene scene in which to add meshes
  60281. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60282. */
  60283. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60284. /**
  60285. * Called once for each button that changed state since the last frame
  60286. * @param buttonIdx Which button index changed
  60287. * @param state New state of the button
  60288. * @param changes Which properties on the state changed since last frame
  60289. */
  60290. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60291. }
  60292. }
  60293. declare module BABYLON {
  60294. /**
  60295. * Gear VR Controller
  60296. */
  60297. export class GearVRController extends WebVRController {
  60298. /**
  60299. * Base Url for the controller model.
  60300. */
  60301. static MODEL_BASE_URL: string;
  60302. /**
  60303. * File name for the controller model.
  60304. */
  60305. static MODEL_FILENAME: string;
  60306. /**
  60307. * Gamepad Id prefix used to identify this controller.
  60308. */
  60309. static readonly GAMEPAD_ID_PREFIX: string;
  60310. private readonly _buttonIndexToObservableNameMap;
  60311. /**
  60312. * Creates a new GearVRController from a gamepad
  60313. * @param vrGamepad the gamepad that the controller should be created from
  60314. */
  60315. constructor(vrGamepad: any);
  60316. /**
  60317. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60318. * @param scene scene in which to add meshes
  60319. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60320. */
  60321. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60322. /**
  60323. * Called once for each button that changed state since the last frame
  60324. * @param buttonIdx Which button index changed
  60325. * @param state New state of the button
  60326. * @param changes Which properties on the state changed since last frame
  60327. */
  60328. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60329. }
  60330. }
  60331. declare module BABYLON {
  60332. /**
  60333. * Generic Controller
  60334. */
  60335. export class GenericController extends WebVRController {
  60336. /**
  60337. * Base Url for the controller model.
  60338. */
  60339. static readonly MODEL_BASE_URL: string;
  60340. /**
  60341. * File name for the controller model.
  60342. */
  60343. static readonly MODEL_FILENAME: string;
  60344. /**
  60345. * Creates a new GenericController from a gamepad
  60346. * @param vrGamepad the gamepad that the controller should be created from
  60347. */
  60348. constructor(vrGamepad: any);
  60349. /**
  60350. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60351. * @param scene scene in which to add meshes
  60352. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60353. */
  60354. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60355. /**
  60356. * Called once for each button that changed state since the last frame
  60357. * @param buttonIdx Which button index changed
  60358. * @param state New state of the button
  60359. * @param changes Which properties on the state changed since last frame
  60360. */
  60361. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60362. }
  60363. }
  60364. declare module BABYLON {
  60365. /**
  60366. * Oculus Touch Controller
  60367. */
  60368. export class OculusTouchController extends WebVRController {
  60369. /**
  60370. * Base Url for the controller model.
  60371. */
  60372. static MODEL_BASE_URL: string;
  60373. /**
  60374. * File name for the left controller model.
  60375. */
  60376. static MODEL_LEFT_FILENAME: string;
  60377. /**
  60378. * File name for the right controller model.
  60379. */
  60380. static MODEL_RIGHT_FILENAME: string;
  60381. /**
  60382. * Base Url for the Quest controller model.
  60383. */
  60384. static QUEST_MODEL_BASE_URL: string;
  60385. /**
  60386. * @hidden
  60387. * If the controllers are running on a device that needs the updated Quest controller models
  60388. */
  60389. static _IsQuest: boolean;
  60390. /**
  60391. * Fired when the secondary trigger on this controller is modified
  60392. */
  60393. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60394. /**
  60395. * Fired when the thumb rest on this controller is modified
  60396. */
  60397. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60398. /**
  60399. * Creates a new OculusTouchController from a gamepad
  60400. * @param vrGamepad the gamepad that the controller should be created from
  60401. */
  60402. constructor(vrGamepad: any);
  60403. /**
  60404. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60405. * @param scene scene in which to add meshes
  60406. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60407. */
  60408. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60409. /**
  60410. * Fired when the A button on this controller is modified
  60411. */
  60412. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60413. /**
  60414. * Fired when the B button on this controller is modified
  60415. */
  60416. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60417. /**
  60418. * Fired when the X button on this controller is modified
  60419. */
  60420. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60421. /**
  60422. * Fired when the Y button on this controller is modified
  60423. */
  60424. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60425. /**
  60426. * Called once for each button that changed state since the last frame
  60427. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60428. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60429. * 2) secondary trigger (same)
  60430. * 3) A (right) X (left), touch, pressed = value
  60431. * 4) B / Y
  60432. * 5) thumb rest
  60433. * @param buttonIdx Which button index changed
  60434. * @param state New state of the button
  60435. * @param changes Which properties on the state changed since last frame
  60436. */
  60437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60438. }
  60439. }
  60440. declare module BABYLON {
  60441. /**
  60442. * Vive Controller
  60443. */
  60444. export class ViveController extends WebVRController {
  60445. /**
  60446. * Base Url for the controller model.
  60447. */
  60448. static MODEL_BASE_URL: string;
  60449. /**
  60450. * File name for the controller model.
  60451. */
  60452. static MODEL_FILENAME: string;
  60453. /**
  60454. * Creates a new ViveController from a gamepad
  60455. * @param vrGamepad the gamepad that the controller should be created from
  60456. */
  60457. constructor(vrGamepad: any);
  60458. /**
  60459. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60460. * @param scene scene in which to add meshes
  60461. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60462. */
  60463. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60464. /**
  60465. * Fired when the left button on this controller is modified
  60466. */
  60467. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60468. /**
  60469. * Fired when the right button on this controller is modified
  60470. */
  60471. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60472. /**
  60473. * Fired when the menu button on this controller is modified
  60474. */
  60475. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60476. /**
  60477. * Called once for each button that changed state since the last frame
  60478. * Vive mapping:
  60479. * 0: touchpad
  60480. * 1: trigger
  60481. * 2: left AND right buttons
  60482. * 3: menu button
  60483. * @param buttonIdx Which button index changed
  60484. * @param state New state of the button
  60485. * @param changes Which properties on the state changed since last frame
  60486. */
  60487. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60488. }
  60489. }
  60490. declare module BABYLON {
  60491. /**
  60492. * Defines the WindowsMotionController object that the state of the windows motion controller
  60493. */
  60494. export class WindowsMotionController extends WebVRController {
  60495. /**
  60496. * The base url used to load the left and right controller models
  60497. */
  60498. static MODEL_BASE_URL: string;
  60499. /**
  60500. * The name of the left controller model file
  60501. */
  60502. static MODEL_LEFT_FILENAME: string;
  60503. /**
  60504. * The name of the right controller model file
  60505. */
  60506. static MODEL_RIGHT_FILENAME: string;
  60507. /**
  60508. * The controller name prefix for this controller type
  60509. */
  60510. static readonly GAMEPAD_ID_PREFIX: string;
  60511. /**
  60512. * The controller id pattern for this controller type
  60513. */
  60514. private static readonly GAMEPAD_ID_PATTERN;
  60515. private _loadedMeshInfo;
  60516. protected readonly _mapping: {
  60517. buttons: string[];
  60518. buttonMeshNames: {
  60519. trigger: string;
  60520. menu: string;
  60521. grip: string;
  60522. thumbstick: string;
  60523. trackpad: string;
  60524. };
  60525. buttonObservableNames: {
  60526. trigger: string;
  60527. menu: string;
  60528. grip: string;
  60529. thumbstick: string;
  60530. trackpad: string;
  60531. };
  60532. axisMeshNames: string[];
  60533. pointingPoseMeshName: string;
  60534. };
  60535. /**
  60536. * Fired when the trackpad on this controller is clicked
  60537. */
  60538. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60539. /**
  60540. * Fired when the trackpad on this controller is modified
  60541. */
  60542. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60543. /**
  60544. * The current x and y values of this controller's trackpad
  60545. */
  60546. trackpad: StickValues;
  60547. /**
  60548. * Creates a new WindowsMotionController from a gamepad
  60549. * @param vrGamepad the gamepad that the controller should be created from
  60550. */
  60551. constructor(vrGamepad: any);
  60552. /**
  60553. * Fired when the trigger on this controller is modified
  60554. */
  60555. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60556. /**
  60557. * Fired when the menu button on this controller is modified
  60558. */
  60559. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60560. /**
  60561. * Fired when the grip button on this controller is modified
  60562. */
  60563. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60564. /**
  60565. * Fired when the thumbstick button on this controller is modified
  60566. */
  60567. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60568. /**
  60569. * Fired when the touchpad button on this controller is modified
  60570. */
  60571. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60572. /**
  60573. * Fired when the touchpad values on this controller are modified
  60574. */
  60575. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60576. protected _updateTrackpad(): void;
  60577. /**
  60578. * Called once per frame by the engine.
  60579. */
  60580. update(): void;
  60581. /**
  60582. * Called once for each button that changed state since the last frame
  60583. * @param buttonIdx Which button index changed
  60584. * @param state New state of the button
  60585. * @param changes Which properties on the state changed since last frame
  60586. */
  60587. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60588. /**
  60589. * Moves the buttons on the controller mesh based on their current state
  60590. * @param buttonName the name of the button to move
  60591. * @param buttonValue the value of the button which determines the buttons new position
  60592. */
  60593. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60594. /**
  60595. * Moves the axis on the controller mesh based on its current state
  60596. * @param axis the index of the axis
  60597. * @param axisValue the value of the axis which determines the meshes new position
  60598. * @hidden
  60599. */
  60600. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60601. /**
  60602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60603. * @param scene scene in which to add meshes
  60604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60605. */
  60606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60607. /**
  60608. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60609. * can be transformed by button presses and axes values, based on this._mapping.
  60610. *
  60611. * @param scene scene in which the meshes exist
  60612. * @param meshes list of meshes that make up the controller model to process
  60613. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60614. */
  60615. private processModel;
  60616. private createMeshInfo;
  60617. /**
  60618. * Gets the ray of the controller in the direction the controller is pointing
  60619. * @param length the length the resulting ray should be
  60620. * @returns a ray in the direction the controller is pointing
  60621. */
  60622. getForwardRay(length?: number): Ray;
  60623. /**
  60624. * Disposes of the controller
  60625. */
  60626. dispose(): void;
  60627. }
  60628. /**
  60629. * This class represents a new windows motion controller in XR.
  60630. */
  60631. export class XRWindowsMotionController extends WindowsMotionController {
  60632. /**
  60633. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60634. */
  60635. protected readonly _mapping: {
  60636. buttons: string[];
  60637. buttonMeshNames: {
  60638. trigger: string;
  60639. menu: string;
  60640. grip: string;
  60641. thumbstick: string;
  60642. trackpad: string;
  60643. };
  60644. buttonObservableNames: {
  60645. trigger: string;
  60646. menu: string;
  60647. grip: string;
  60648. thumbstick: string;
  60649. trackpad: string;
  60650. };
  60651. axisMeshNames: string[];
  60652. pointingPoseMeshName: string;
  60653. };
  60654. /**
  60655. * Construct a new XR-Based windows motion controller
  60656. *
  60657. * @param gamepadInfo the gamepad object from the browser
  60658. */
  60659. constructor(gamepadInfo: any);
  60660. /**
  60661. * holds the thumbstick values (X,Y)
  60662. */
  60663. thumbstickValues: StickValues;
  60664. /**
  60665. * Fired when the thumbstick on this controller is clicked
  60666. */
  60667. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60668. /**
  60669. * Fired when the thumbstick on this controller is modified
  60670. */
  60671. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60672. /**
  60673. * Fired when the touchpad button on this controller is modified
  60674. */
  60675. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60676. /**
  60677. * Fired when the touchpad values on this controller are modified
  60678. */
  60679. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60680. /**
  60681. * Fired when the thumbstick button on this controller is modified
  60682. * here to prevent breaking changes
  60683. */
  60684. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60685. /**
  60686. * updating the thumbstick(!) and not the trackpad.
  60687. * This is named this way due to the difference between WebVR and XR and to avoid
  60688. * changing the parent class.
  60689. */
  60690. protected _updateTrackpad(): void;
  60691. /**
  60692. * Disposes the class with joy
  60693. */
  60694. dispose(): void;
  60695. }
  60696. }
  60697. declare module BABYLON {
  60698. /**
  60699. * A directional light is defined by a direction (what a surprise!).
  60700. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60701. * 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.
  60702. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60703. */
  60704. export class DirectionalLight extends ShadowLight {
  60705. private _shadowFrustumSize;
  60706. /**
  60707. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60708. */
  60709. get shadowFrustumSize(): number;
  60710. /**
  60711. * Specifies a fix frustum size for the shadow generation.
  60712. */
  60713. set shadowFrustumSize(value: number);
  60714. private _shadowOrthoScale;
  60715. /**
  60716. * Gets the shadow projection scale against the optimal computed one.
  60717. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60718. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60719. */
  60720. get shadowOrthoScale(): number;
  60721. /**
  60722. * Sets the shadow projection scale against the optimal computed one.
  60723. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60724. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60725. */
  60726. set shadowOrthoScale(value: number);
  60727. /**
  60728. * Automatically compute the projection matrix to best fit (including all the casters)
  60729. * on each frame.
  60730. */
  60731. autoUpdateExtends: boolean;
  60732. /**
  60733. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60734. * on each frame. autoUpdateExtends must be set to true for this to work
  60735. */
  60736. autoCalcShadowZBounds: boolean;
  60737. private _orthoLeft;
  60738. private _orthoRight;
  60739. private _orthoTop;
  60740. private _orthoBottom;
  60741. /**
  60742. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60743. * The directional light is emitted from everywhere in the given direction.
  60744. * It can cast shadows.
  60745. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60746. * @param name The friendly name of the light
  60747. * @param direction The direction of the light
  60748. * @param scene The scene the light belongs to
  60749. */
  60750. constructor(name: string, direction: Vector3, scene: Scene);
  60751. /**
  60752. * Returns the string "DirectionalLight".
  60753. * @return The class name
  60754. */
  60755. getClassName(): string;
  60756. /**
  60757. * Returns the integer 1.
  60758. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60759. */
  60760. getTypeID(): number;
  60761. /**
  60762. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60763. * Returns the DirectionalLight Shadow projection matrix.
  60764. */
  60765. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60766. /**
  60767. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60768. * Returns the DirectionalLight Shadow projection matrix.
  60769. */
  60770. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60771. /**
  60772. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60773. * Returns the DirectionalLight Shadow projection matrix.
  60774. */
  60775. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60776. protected _buildUniformLayout(): void;
  60777. /**
  60778. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60779. * @param effect The effect to update
  60780. * @param lightIndex The index of the light in the effect to update
  60781. * @returns The directional light
  60782. */
  60783. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60784. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60785. /**
  60786. * Gets the minZ used for shadow according to both the scene and the light.
  60787. *
  60788. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60789. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60790. * @param activeCamera The camera we are returning the min for
  60791. * @returns the depth min z
  60792. */
  60793. getDepthMinZ(activeCamera: Camera): number;
  60794. /**
  60795. * Gets the maxZ used for shadow according to both the scene and the light.
  60796. *
  60797. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60798. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60799. * @param activeCamera The camera we are returning the max for
  60800. * @returns the depth max z
  60801. */
  60802. getDepthMaxZ(activeCamera: Camera): number;
  60803. /**
  60804. * Prepares the list of defines specific to the light type.
  60805. * @param defines the list of defines
  60806. * @param lightIndex defines the index of the light for the effect
  60807. */
  60808. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60809. }
  60810. }
  60811. declare module BABYLON {
  60812. /**
  60813. * Class containing static functions to help procedurally build meshes
  60814. */
  60815. export class HemisphereBuilder {
  60816. /**
  60817. * Creates a hemisphere mesh
  60818. * @param name defines the name of the mesh
  60819. * @param options defines the options used to create the mesh
  60820. * @param scene defines the hosting scene
  60821. * @returns the hemisphere mesh
  60822. */
  60823. static CreateHemisphere(name: string, options: {
  60824. segments?: number;
  60825. diameter?: number;
  60826. sideOrientation?: number;
  60827. }, scene: any): Mesh;
  60828. }
  60829. }
  60830. declare module BABYLON {
  60831. /**
  60832. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60833. * These values define a cone of light starting from the position, emitting toward the direction.
  60834. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60835. * and the exponent defines the speed of the decay of the light with distance (reach).
  60836. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60837. */
  60838. export class SpotLight extends ShadowLight {
  60839. private _angle;
  60840. private _innerAngle;
  60841. private _cosHalfAngle;
  60842. private _lightAngleScale;
  60843. private _lightAngleOffset;
  60844. /**
  60845. * Gets the cone angle of the spot light in Radians.
  60846. */
  60847. get angle(): number;
  60848. /**
  60849. * Sets the cone angle of the spot light in Radians.
  60850. */
  60851. set angle(value: number);
  60852. /**
  60853. * Only used in gltf falloff mode, this defines the angle where
  60854. * the directional falloff will start before cutting at angle which could be seen
  60855. * as outer angle.
  60856. */
  60857. get innerAngle(): number;
  60858. /**
  60859. * Only used in gltf falloff mode, this defines the angle where
  60860. * the directional falloff will start before cutting at angle which could be seen
  60861. * as outer angle.
  60862. */
  60863. set innerAngle(value: number);
  60864. private _shadowAngleScale;
  60865. /**
  60866. * Allows scaling the angle of the light for shadow generation only.
  60867. */
  60868. get shadowAngleScale(): number;
  60869. /**
  60870. * Allows scaling the angle of the light for shadow generation only.
  60871. */
  60872. set shadowAngleScale(value: number);
  60873. /**
  60874. * The light decay speed with the distance from the emission spot.
  60875. */
  60876. exponent: number;
  60877. private _projectionTextureMatrix;
  60878. /**
  60879. * Allows reading the projecton texture
  60880. */
  60881. get projectionTextureMatrix(): Matrix;
  60882. protected _projectionTextureLightNear: number;
  60883. /**
  60884. * Gets the near clip of the Spotlight for texture projection.
  60885. */
  60886. get projectionTextureLightNear(): number;
  60887. /**
  60888. * Sets the near clip of the Spotlight for texture projection.
  60889. */
  60890. set projectionTextureLightNear(value: number);
  60891. protected _projectionTextureLightFar: number;
  60892. /**
  60893. * Gets the far clip of the Spotlight for texture projection.
  60894. */
  60895. get projectionTextureLightFar(): number;
  60896. /**
  60897. * Sets the far clip of the Spotlight for texture projection.
  60898. */
  60899. set projectionTextureLightFar(value: number);
  60900. protected _projectionTextureUpDirection: Vector3;
  60901. /**
  60902. * Gets the Up vector of the Spotlight for texture projection.
  60903. */
  60904. get projectionTextureUpDirection(): Vector3;
  60905. /**
  60906. * Sets the Up vector of the Spotlight for texture projection.
  60907. */
  60908. set projectionTextureUpDirection(value: Vector3);
  60909. private _projectionTexture;
  60910. /**
  60911. * Gets the projection texture of the light.
  60912. */
  60913. get projectionTexture(): Nullable<BaseTexture>;
  60914. /**
  60915. * Sets the projection texture of the light.
  60916. */
  60917. set projectionTexture(value: Nullable<BaseTexture>);
  60918. private static _IsProceduralTexture;
  60919. private static _IsTexture;
  60920. private _projectionTextureViewLightDirty;
  60921. private _projectionTextureProjectionLightDirty;
  60922. private _projectionTextureDirty;
  60923. private _projectionTextureViewTargetVector;
  60924. private _projectionTextureViewLightMatrix;
  60925. private _projectionTextureProjectionLightMatrix;
  60926. private _projectionTextureScalingMatrix;
  60927. /**
  60928. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60929. * It can cast shadows.
  60930. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60931. * @param name The light friendly name
  60932. * @param position The position of the spot light in the scene
  60933. * @param direction The direction of the light in the scene
  60934. * @param angle The cone angle of the light in Radians
  60935. * @param exponent The light decay speed with the distance from the emission spot
  60936. * @param scene The scene the lights belongs to
  60937. */
  60938. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60939. /**
  60940. * Returns the string "SpotLight".
  60941. * @returns the class name
  60942. */
  60943. getClassName(): string;
  60944. /**
  60945. * Returns the integer 2.
  60946. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60947. */
  60948. getTypeID(): number;
  60949. /**
  60950. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60951. */
  60952. protected _setDirection(value: Vector3): void;
  60953. /**
  60954. * Overrides the position setter to recompute the projection texture view light Matrix.
  60955. */
  60956. protected _setPosition(value: Vector3): void;
  60957. /**
  60958. * 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.
  60959. * Returns the SpotLight.
  60960. */
  60961. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60962. protected _computeProjectionTextureViewLightMatrix(): void;
  60963. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60964. /**
  60965. * Main function for light texture projection matrix computing.
  60966. */
  60967. protected _computeProjectionTextureMatrix(): void;
  60968. protected _buildUniformLayout(): void;
  60969. private _computeAngleValues;
  60970. /**
  60971. * Sets the passed Effect "effect" with the Light textures.
  60972. * @param effect The effect to update
  60973. * @param lightIndex The index of the light in the effect to update
  60974. * @returns The light
  60975. */
  60976. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60977. /**
  60978. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60979. * @param effect The effect to update
  60980. * @param lightIndex The index of the light in the effect to update
  60981. * @returns The spot light
  60982. */
  60983. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60984. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60985. /**
  60986. * Disposes the light and the associated resources.
  60987. */
  60988. dispose(): void;
  60989. /**
  60990. * Prepares the list of defines specific to the light type.
  60991. * @param defines the list of defines
  60992. * @param lightIndex defines the index of the light for the effect
  60993. */
  60994. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60995. }
  60996. }
  60997. declare module BABYLON {
  60998. /**
  60999. * Gizmo that enables viewing a light
  61000. */
  61001. export class LightGizmo extends Gizmo {
  61002. private _lightMesh;
  61003. private _material;
  61004. private _cachedPosition;
  61005. private _cachedForward;
  61006. private _attachedMeshParent;
  61007. private _pointerObserver;
  61008. /**
  61009. * Event that fires each time the gizmo is clicked
  61010. */
  61011. onClickedObservable: Observable<Light>;
  61012. /**
  61013. * Creates a LightGizmo
  61014. * @param gizmoLayer The utility layer the gizmo will be added to
  61015. */
  61016. constructor(gizmoLayer?: UtilityLayerRenderer);
  61017. private _light;
  61018. /**
  61019. * The light that the gizmo is attached to
  61020. */
  61021. set light(light: Nullable<Light>);
  61022. get light(): Nullable<Light>;
  61023. /**
  61024. * Gets the material used to render the light gizmo
  61025. */
  61026. get material(): StandardMaterial;
  61027. /**
  61028. * @hidden
  61029. * Updates the gizmo to match the attached mesh's position/rotation
  61030. */
  61031. protected _update(): void;
  61032. private static _Scale;
  61033. /**
  61034. * Creates the lines for a light mesh
  61035. */
  61036. private static _CreateLightLines;
  61037. /**
  61038. * Disposes of the light gizmo
  61039. */
  61040. dispose(): void;
  61041. private static _CreateHemisphericLightMesh;
  61042. private static _CreatePointLightMesh;
  61043. private static _CreateSpotLightMesh;
  61044. private static _CreateDirectionalLightMesh;
  61045. }
  61046. }
  61047. declare module BABYLON {
  61048. /**
  61049. * Gizmo that enables viewing a camera
  61050. */
  61051. export class CameraGizmo extends Gizmo {
  61052. private _cameraMesh;
  61053. private _cameraLinesMesh;
  61054. private _material;
  61055. private _pointerObserver;
  61056. /**
  61057. * Event that fires each time the gizmo is clicked
  61058. */
  61059. onClickedObservable: Observable<Camera>;
  61060. /**
  61061. * Creates a CameraGizmo
  61062. * @param gizmoLayer The utility layer the gizmo will be added to
  61063. */
  61064. constructor(gizmoLayer?: UtilityLayerRenderer);
  61065. private _camera;
  61066. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61067. get displayFrustum(): boolean;
  61068. set displayFrustum(value: boolean);
  61069. /**
  61070. * The camera that the gizmo is attached to
  61071. */
  61072. set camera(camera: Nullable<Camera>);
  61073. get camera(): Nullable<Camera>;
  61074. /**
  61075. * Gets the material used to render the camera gizmo
  61076. */
  61077. get material(): StandardMaterial;
  61078. /**
  61079. * @hidden
  61080. * Updates the gizmo to match the attached mesh's position/rotation
  61081. */
  61082. protected _update(): void;
  61083. private static _Scale;
  61084. private _invProjection;
  61085. /**
  61086. * Disposes of the camera gizmo
  61087. */
  61088. dispose(): void;
  61089. private static _CreateCameraMesh;
  61090. private static _CreateCameraFrustum;
  61091. }
  61092. }
  61093. declare module BABYLON {
  61094. /** @hidden */
  61095. export var backgroundFragmentDeclaration: {
  61096. name: string;
  61097. shader: string;
  61098. };
  61099. }
  61100. declare module BABYLON {
  61101. /** @hidden */
  61102. export var backgroundUboDeclaration: {
  61103. name: string;
  61104. shader: string;
  61105. };
  61106. }
  61107. declare module BABYLON {
  61108. /** @hidden */
  61109. export var backgroundPixelShader: {
  61110. name: string;
  61111. shader: string;
  61112. };
  61113. }
  61114. declare module BABYLON {
  61115. /** @hidden */
  61116. export var backgroundVertexDeclaration: {
  61117. name: string;
  61118. shader: string;
  61119. };
  61120. }
  61121. declare module BABYLON {
  61122. /** @hidden */
  61123. export var backgroundVertexShader: {
  61124. name: string;
  61125. shader: string;
  61126. };
  61127. }
  61128. declare module BABYLON {
  61129. /**
  61130. * Background material used to create an efficient environement around your scene.
  61131. */
  61132. export class BackgroundMaterial extends PushMaterial {
  61133. /**
  61134. * Standard reflectance value at parallel view angle.
  61135. */
  61136. static StandardReflectance0: number;
  61137. /**
  61138. * Standard reflectance value at grazing angle.
  61139. */
  61140. static StandardReflectance90: number;
  61141. protected _primaryColor: Color3;
  61142. /**
  61143. * Key light Color (multiply against the environement texture)
  61144. */
  61145. primaryColor: Color3;
  61146. protected __perceptualColor: Nullable<Color3>;
  61147. /**
  61148. * Experimental Internal Use Only.
  61149. *
  61150. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61151. * This acts as a helper to set the primary color to a more "human friendly" value.
  61152. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61153. * output color as close as possible from the chosen value.
  61154. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61155. * part of lighting setup.)
  61156. */
  61157. get _perceptualColor(): Nullable<Color3>;
  61158. set _perceptualColor(value: Nullable<Color3>);
  61159. protected _primaryColorShadowLevel: float;
  61160. /**
  61161. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61162. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61163. */
  61164. get primaryColorShadowLevel(): float;
  61165. set primaryColorShadowLevel(value: float);
  61166. protected _primaryColorHighlightLevel: float;
  61167. /**
  61168. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  61169. * The primary color is used at the level chosen to define what the white area would look.
  61170. */
  61171. get primaryColorHighlightLevel(): float;
  61172. set primaryColorHighlightLevel(value: float);
  61173. protected _reflectionTexture: Nullable<BaseTexture>;
  61174. /**
  61175. * Reflection Texture used in the material.
  61176. * Should be author in a specific way for the best result (refer to the documentation).
  61177. */
  61178. reflectionTexture: Nullable<BaseTexture>;
  61179. protected _reflectionBlur: float;
  61180. /**
  61181. * Reflection Texture level of blur.
  61182. *
  61183. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61184. * texture twice.
  61185. */
  61186. reflectionBlur: float;
  61187. protected _diffuseTexture: Nullable<BaseTexture>;
  61188. /**
  61189. * Diffuse Texture used in the material.
  61190. * Should be author in a specific way for the best result (refer to the documentation).
  61191. */
  61192. diffuseTexture: Nullable<BaseTexture>;
  61193. protected _shadowLights: Nullable<IShadowLight[]>;
  61194. /**
  61195. * Specify the list of lights casting shadow on the material.
  61196. * All scene shadow lights will be included if null.
  61197. */
  61198. shadowLights: Nullable<IShadowLight[]>;
  61199. protected _shadowLevel: float;
  61200. /**
  61201. * Helps adjusting the shadow to a softer level if required.
  61202. * 0 means black shadows and 1 means no shadows.
  61203. */
  61204. shadowLevel: float;
  61205. protected _sceneCenter: Vector3;
  61206. /**
  61207. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61208. * It is usually zero but might be interesting to modify according to your setup.
  61209. */
  61210. sceneCenter: Vector3;
  61211. protected _opacityFresnel: boolean;
  61212. /**
  61213. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61214. * This helps ensuring a nice transition when the camera goes under the ground.
  61215. */
  61216. opacityFresnel: boolean;
  61217. protected _reflectionFresnel: boolean;
  61218. /**
  61219. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61220. * This helps adding a mirror texture on the ground.
  61221. */
  61222. reflectionFresnel: boolean;
  61223. protected _reflectionFalloffDistance: number;
  61224. /**
  61225. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61226. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61227. */
  61228. reflectionFalloffDistance: number;
  61229. protected _reflectionAmount: number;
  61230. /**
  61231. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61232. */
  61233. reflectionAmount: number;
  61234. protected _reflectionReflectance0: number;
  61235. /**
  61236. * This specifies the weight of the reflection at grazing angle.
  61237. */
  61238. reflectionReflectance0: number;
  61239. protected _reflectionReflectance90: number;
  61240. /**
  61241. * This specifies the weight of the reflection at a perpendicular point of view.
  61242. */
  61243. reflectionReflectance90: number;
  61244. /**
  61245. * Sets the reflection reflectance fresnel values according to the default standard
  61246. * empirically know to work well :-)
  61247. */
  61248. set reflectionStandardFresnelWeight(value: number);
  61249. protected _useRGBColor: boolean;
  61250. /**
  61251. * Helps to directly use the maps channels instead of their level.
  61252. */
  61253. useRGBColor: boolean;
  61254. protected _enableNoise: boolean;
  61255. /**
  61256. * This helps reducing the banding effect that could occur on the background.
  61257. */
  61258. enableNoise: boolean;
  61259. /**
  61260. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61261. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61262. * Recommended to be keep at 1.0 except for special cases.
  61263. */
  61264. get fovMultiplier(): number;
  61265. set fovMultiplier(value: number);
  61266. private _fovMultiplier;
  61267. /**
  61268. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61269. */
  61270. useEquirectangularFOV: boolean;
  61271. private _maxSimultaneousLights;
  61272. /**
  61273. * Number of Simultaneous lights allowed on the material.
  61274. */
  61275. maxSimultaneousLights: int;
  61276. private _shadowOnly;
  61277. /**
  61278. * Make the material only render shadows
  61279. */
  61280. shadowOnly: boolean;
  61281. /**
  61282. * Default configuration related to image processing available in the Background Material.
  61283. */
  61284. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61285. /**
  61286. * Keep track of the image processing observer to allow dispose and replace.
  61287. */
  61288. private _imageProcessingObserver;
  61289. /**
  61290. * Attaches a new image processing configuration to the PBR Material.
  61291. * @param configuration (if null the scene configuration will be use)
  61292. */
  61293. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61294. /**
  61295. * Gets the image processing configuration used either in this material.
  61296. */
  61297. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61298. /**
  61299. * Sets the Default image processing configuration used either in the this material.
  61300. *
  61301. * If sets to null, the scene one is in use.
  61302. */
  61303. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61304. /**
  61305. * Gets wether the color curves effect is enabled.
  61306. */
  61307. get cameraColorCurvesEnabled(): boolean;
  61308. /**
  61309. * Sets wether the color curves effect is enabled.
  61310. */
  61311. set cameraColorCurvesEnabled(value: boolean);
  61312. /**
  61313. * Gets wether the color grading effect is enabled.
  61314. */
  61315. get cameraColorGradingEnabled(): boolean;
  61316. /**
  61317. * Gets wether the color grading effect is enabled.
  61318. */
  61319. set cameraColorGradingEnabled(value: boolean);
  61320. /**
  61321. * Gets wether tonemapping is enabled or not.
  61322. */
  61323. get cameraToneMappingEnabled(): boolean;
  61324. /**
  61325. * Sets wether tonemapping is enabled or not
  61326. */
  61327. set cameraToneMappingEnabled(value: boolean);
  61328. /**
  61329. * The camera exposure used on this material.
  61330. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61331. * This corresponds to a photographic exposure.
  61332. */
  61333. get cameraExposure(): float;
  61334. /**
  61335. * The camera exposure used on this material.
  61336. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61337. * This corresponds to a photographic exposure.
  61338. */
  61339. set cameraExposure(value: float);
  61340. /**
  61341. * Gets The camera contrast used on this material.
  61342. */
  61343. get cameraContrast(): float;
  61344. /**
  61345. * Sets The camera contrast used on this material.
  61346. */
  61347. set cameraContrast(value: float);
  61348. /**
  61349. * Gets the Color Grading 2D Lookup Texture.
  61350. */
  61351. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61352. /**
  61353. * Sets the Color Grading 2D Lookup Texture.
  61354. */
  61355. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61356. /**
  61357. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61358. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61359. * 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;
  61360. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61361. */
  61362. get cameraColorCurves(): Nullable<ColorCurves>;
  61363. /**
  61364. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61365. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61366. * 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;
  61367. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61368. */
  61369. set cameraColorCurves(value: Nullable<ColorCurves>);
  61370. /**
  61371. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61372. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61373. */
  61374. switchToBGR: boolean;
  61375. private _renderTargets;
  61376. private _reflectionControls;
  61377. private _white;
  61378. private _primaryShadowColor;
  61379. private _primaryHighlightColor;
  61380. /**
  61381. * Instantiates a Background Material in the given scene
  61382. * @param name The friendly name of the material
  61383. * @param scene The scene to add the material to
  61384. */
  61385. constructor(name: string, scene: Scene);
  61386. /**
  61387. * Gets a boolean indicating that current material needs to register RTT
  61388. */
  61389. get hasRenderTargetTextures(): boolean;
  61390. /**
  61391. * The entire material has been created in order to prevent overdraw.
  61392. * @returns false
  61393. */
  61394. needAlphaTesting(): boolean;
  61395. /**
  61396. * The entire material has been created in order to prevent overdraw.
  61397. * @returns true if blending is enable
  61398. */
  61399. needAlphaBlending(): boolean;
  61400. /**
  61401. * Checks wether the material is ready to be rendered for a given mesh.
  61402. * @param mesh The mesh to render
  61403. * @param subMesh The submesh to check against
  61404. * @param useInstances Specify wether or not the material is used with instances
  61405. * @returns true if all the dependencies are ready (Textures, Effects...)
  61406. */
  61407. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61408. /**
  61409. * Compute the primary color according to the chosen perceptual color.
  61410. */
  61411. private _computePrimaryColorFromPerceptualColor;
  61412. /**
  61413. * Compute the highlights and shadow colors according to their chosen levels.
  61414. */
  61415. private _computePrimaryColors;
  61416. /**
  61417. * Build the uniform buffer used in the material.
  61418. */
  61419. buildUniformLayout(): void;
  61420. /**
  61421. * Unbind the material.
  61422. */
  61423. unbind(): void;
  61424. /**
  61425. * Bind only the world matrix to the material.
  61426. * @param world The world matrix to bind.
  61427. */
  61428. bindOnlyWorldMatrix(world: Matrix): void;
  61429. /**
  61430. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61431. * @param world The world matrix to bind.
  61432. * @param subMesh The submesh to bind for.
  61433. */
  61434. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61435. /**
  61436. * Checks to see if a texture is used in the material.
  61437. * @param texture - Base texture to use.
  61438. * @returns - Boolean specifying if a texture is used in the material.
  61439. */
  61440. hasTexture(texture: BaseTexture): boolean;
  61441. /**
  61442. * Dispose the material.
  61443. * @param forceDisposeEffect Force disposal of the associated effect.
  61444. * @param forceDisposeTextures Force disposal of the associated textures.
  61445. */
  61446. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61447. /**
  61448. * Clones the material.
  61449. * @param name The cloned name.
  61450. * @returns The cloned material.
  61451. */
  61452. clone(name: string): BackgroundMaterial;
  61453. /**
  61454. * Serializes the current material to its JSON representation.
  61455. * @returns The JSON representation.
  61456. */
  61457. serialize(): any;
  61458. /**
  61459. * Gets the class name of the material
  61460. * @returns "BackgroundMaterial"
  61461. */
  61462. getClassName(): string;
  61463. /**
  61464. * Parse a JSON input to create back a background material.
  61465. * @param source The JSON data to parse
  61466. * @param scene The scene to create the parsed material in
  61467. * @param rootUrl The root url of the assets the material depends upon
  61468. * @returns the instantiated BackgroundMaterial.
  61469. */
  61470. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61471. }
  61472. }
  61473. declare module BABYLON {
  61474. /**
  61475. * Represents the different options available during the creation of
  61476. * a Environment helper.
  61477. *
  61478. * This can control the default ground, skybox and image processing setup of your scene.
  61479. */
  61480. export interface IEnvironmentHelperOptions {
  61481. /**
  61482. * Specifies whether or not to create a ground.
  61483. * True by default.
  61484. */
  61485. createGround: boolean;
  61486. /**
  61487. * Specifies the ground size.
  61488. * 15 by default.
  61489. */
  61490. groundSize: number;
  61491. /**
  61492. * The texture used on the ground for the main color.
  61493. * Comes from the BabylonJS CDN by default.
  61494. *
  61495. * Remarks: Can be either a texture or a url.
  61496. */
  61497. groundTexture: string | BaseTexture;
  61498. /**
  61499. * The color mixed in the ground texture by default.
  61500. * BabylonJS clearColor by default.
  61501. */
  61502. groundColor: Color3;
  61503. /**
  61504. * Specifies the ground opacity.
  61505. * 1 by default.
  61506. */
  61507. groundOpacity: number;
  61508. /**
  61509. * Enables the ground to receive shadows.
  61510. * True by default.
  61511. */
  61512. enableGroundShadow: boolean;
  61513. /**
  61514. * Helps preventing the shadow to be fully black on the ground.
  61515. * 0.5 by default.
  61516. */
  61517. groundShadowLevel: number;
  61518. /**
  61519. * Creates a mirror texture attach to the ground.
  61520. * false by default.
  61521. */
  61522. enableGroundMirror: boolean;
  61523. /**
  61524. * Specifies the ground mirror size ratio.
  61525. * 0.3 by default as the default kernel is 64.
  61526. */
  61527. groundMirrorSizeRatio: number;
  61528. /**
  61529. * Specifies the ground mirror blur kernel size.
  61530. * 64 by default.
  61531. */
  61532. groundMirrorBlurKernel: number;
  61533. /**
  61534. * Specifies the ground mirror visibility amount.
  61535. * 1 by default
  61536. */
  61537. groundMirrorAmount: number;
  61538. /**
  61539. * Specifies the ground mirror reflectance weight.
  61540. * This uses the standard weight of the background material to setup the fresnel effect
  61541. * of the mirror.
  61542. * 1 by default.
  61543. */
  61544. groundMirrorFresnelWeight: number;
  61545. /**
  61546. * Specifies the ground mirror Falloff distance.
  61547. * This can helps reducing the size of the reflection.
  61548. * 0 by Default.
  61549. */
  61550. groundMirrorFallOffDistance: number;
  61551. /**
  61552. * Specifies the ground mirror texture type.
  61553. * Unsigned Int by Default.
  61554. */
  61555. groundMirrorTextureType: number;
  61556. /**
  61557. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61558. * the shown objects.
  61559. */
  61560. groundYBias: number;
  61561. /**
  61562. * Specifies whether or not to create a skybox.
  61563. * True by default.
  61564. */
  61565. createSkybox: boolean;
  61566. /**
  61567. * Specifies the skybox size.
  61568. * 20 by default.
  61569. */
  61570. skyboxSize: number;
  61571. /**
  61572. * The texture used on the skybox for the main color.
  61573. * Comes from the BabylonJS CDN by default.
  61574. *
  61575. * Remarks: Can be either a texture or a url.
  61576. */
  61577. skyboxTexture: string | BaseTexture;
  61578. /**
  61579. * The color mixed in the skybox texture by default.
  61580. * BabylonJS clearColor by default.
  61581. */
  61582. skyboxColor: Color3;
  61583. /**
  61584. * The background rotation around the Y axis of the scene.
  61585. * This helps aligning the key lights of your scene with the background.
  61586. * 0 by default.
  61587. */
  61588. backgroundYRotation: number;
  61589. /**
  61590. * Compute automatically the size of the elements to best fit with the scene.
  61591. */
  61592. sizeAuto: boolean;
  61593. /**
  61594. * Default position of the rootMesh if autoSize is not true.
  61595. */
  61596. rootPosition: Vector3;
  61597. /**
  61598. * Sets up the image processing in the scene.
  61599. * true by default.
  61600. */
  61601. setupImageProcessing: boolean;
  61602. /**
  61603. * The texture used as your environment texture in the scene.
  61604. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61605. *
  61606. * Remarks: Can be either a texture or a url.
  61607. */
  61608. environmentTexture: string | BaseTexture;
  61609. /**
  61610. * The value of the exposure to apply to the scene.
  61611. * 0.6 by default if setupImageProcessing is true.
  61612. */
  61613. cameraExposure: number;
  61614. /**
  61615. * The value of the contrast to apply to the scene.
  61616. * 1.6 by default if setupImageProcessing is true.
  61617. */
  61618. cameraContrast: number;
  61619. /**
  61620. * Specifies whether or not tonemapping should be enabled in the scene.
  61621. * true by default if setupImageProcessing is true.
  61622. */
  61623. toneMappingEnabled: boolean;
  61624. }
  61625. /**
  61626. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61627. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61628. * It also helps with the default setup of your imageProcessing configuration.
  61629. */
  61630. export class EnvironmentHelper {
  61631. /**
  61632. * Default ground texture URL.
  61633. */
  61634. private static _groundTextureCDNUrl;
  61635. /**
  61636. * Default skybox texture URL.
  61637. */
  61638. private static _skyboxTextureCDNUrl;
  61639. /**
  61640. * Default environment texture URL.
  61641. */
  61642. private static _environmentTextureCDNUrl;
  61643. /**
  61644. * Creates the default options for the helper.
  61645. */
  61646. private static _getDefaultOptions;
  61647. private _rootMesh;
  61648. /**
  61649. * Gets the root mesh created by the helper.
  61650. */
  61651. get rootMesh(): Mesh;
  61652. private _skybox;
  61653. /**
  61654. * Gets the skybox created by the helper.
  61655. */
  61656. get skybox(): Nullable<Mesh>;
  61657. private _skyboxTexture;
  61658. /**
  61659. * Gets the skybox texture created by the helper.
  61660. */
  61661. get skyboxTexture(): Nullable<BaseTexture>;
  61662. private _skyboxMaterial;
  61663. /**
  61664. * Gets the skybox material created by the helper.
  61665. */
  61666. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61667. private _ground;
  61668. /**
  61669. * Gets the ground mesh created by the helper.
  61670. */
  61671. get ground(): Nullable<Mesh>;
  61672. private _groundTexture;
  61673. /**
  61674. * Gets the ground texture created by the helper.
  61675. */
  61676. get groundTexture(): Nullable<BaseTexture>;
  61677. private _groundMirror;
  61678. /**
  61679. * Gets the ground mirror created by the helper.
  61680. */
  61681. get groundMirror(): Nullable<MirrorTexture>;
  61682. /**
  61683. * Gets the ground mirror render list to helps pushing the meshes
  61684. * you wish in the ground reflection.
  61685. */
  61686. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61687. private _groundMaterial;
  61688. /**
  61689. * Gets the ground material created by the helper.
  61690. */
  61691. get groundMaterial(): Nullable<BackgroundMaterial>;
  61692. /**
  61693. * Stores the creation options.
  61694. */
  61695. private readonly _scene;
  61696. private _options;
  61697. /**
  61698. * This observable will be notified with any error during the creation of the environment,
  61699. * mainly texture creation errors.
  61700. */
  61701. onErrorObservable: Observable<{
  61702. message?: string;
  61703. exception?: any;
  61704. }>;
  61705. /**
  61706. * constructor
  61707. * @param options Defines the options we want to customize the helper
  61708. * @param scene The scene to add the material to
  61709. */
  61710. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61711. /**
  61712. * Updates the background according to the new options
  61713. * @param options
  61714. */
  61715. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61716. /**
  61717. * Sets the primary color of all the available elements.
  61718. * @param color the main color to affect to the ground and the background
  61719. */
  61720. setMainColor(color: Color3): void;
  61721. /**
  61722. * Setup the image processing according to the specified options.
  61723. */
  61724. private _setupImageProcessing;
  61725. /**
  61726. * Setup the environment texture according to the specified options.
  61727. */
  61728. private _setupEnvironmentTexture;
  61729. /**
  61730. * Setup the background according to the specified options.
  61731. */
  61732. private _setupBackground;
  61733. /**
  61734. * Get the scene sizes according to the setup.
  61735. */
  61736. private _getSceneSize;
  61737. /**
  61738. * Setup the ground according to the specified options.
  61739. */
  61740. private _setupGround;
  61741. /**
  61742. * Setup the ground material according to the specified options.
  61743. */
  61744. private _setupGroundMaterial;
  61745. /**
  61746. * Setup the ground diffuse texture according to the specified options.
  61747. */
  61748. private _setupGroundDiffuseTexture;
  61749. /**
  61750. * Setup the ground mirror texture according to the specified options.
  61751. */
  61752. private _setupGroundMirrorTexture;
  61753. /**
  61754. * Setup the ground to receive the mirror texture.
  61755. */
  61756. private _setupMirrorInGroundMaterial;
  61757. /**
  61758. * Setup the skybox according to the specified options.
  61759. */
  61760. private _setupSkybox;
  61761. /**
  61762. * Setup the skybox material according to the specified options.
  61763. */
  61764. private _setupSkyboxMaterial;
  61765. /**
  61766. * Setup the skybox reflection texture according to the specified options.
  61767. */
  61768. private _setupSkyboxReflectionTexture;
  61769. private _errorHandler;
  61770. /**
  61771. * Dispose all the elements created by the Helper.
  61772. */
  61773. dispose(): void;
  61774. }
  61775. }
  61776. declare module BABYLON {
  61777. /**
  61778. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61779. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61780. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61781. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61782. */
  61783. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61784. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61785. /**
  61786. * Define the source as a Monoscopic panoramic 360/180.
  61787. */
  61788. static readonly MODE_MONOSCOPIC: number;
  61789. /**
  61790. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61791. */
  61792. static readonly MODE_TOPBOTTOM: number;
  61793. /**
  61794. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61795. */
  61796. static readonly MODE_SIDEBYSIDE: number;
  61797. private _halfDome;
  61798. private _crossEye;
  61799. protected _useDirectMapping: boolean;
  61800. /**
  61801. * The texture being displayed on the sphere
  61802. */
  61803. protected _texture: T;
  61804. /**
  61805. * Gets the texture being displayed on the sphere
  61806. */
  61807. get texture(): T;
  61808. /**
  61809. * Sets the texture being displayed on the sphere
  61810. */
  61811. set texture(newTexture: T);
  61812. /**
  61813. * The skybox material
  61814. */
  61815. protected _material: BackgroundMaterial;
  61816. /**
  61817. * The surface used for the dome
  61818. */
  61819. protected _mesh: Mesh;
  61820. /**
  61821. * Gets the mesh used for the dome.
  61822. */
  61823. get mesh(): Mesh;
  61824. /**
  61825. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61826. */
  61827. private _halfDomeMask;
  61828. /**
  61829. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61830. * Also see the options.resolution property.
  61831. */
  61832. get fovMultiplier(): number;
  61833. set fovMultiplier(value: number);
  61834. protected _textureMode: number;
  61835. /**
  61836. * Gets or set the current texture mode for the texture. It can be:
  61837. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61838. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61839. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61840. */
  61841. get textureMode(): number;
  61842. /**
  61843. * Sets the current texture mode for the texture. It can be:
  61844. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61845. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61846. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61847. */
  61848. set textureMode(value: number);
  61849. /**
  61850. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61851. */
  61852. get halfDome(): boolean;
  61853. /**
  61854. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61855. */
  61856. set halfDome(enabled: boolean);
  61857. /**
  61858. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61859. */
  61860. set crossEye(enabled: boolean);
  61861. /**
  61862. * Is it a cross-eye texture?
  61863. */
  61864. get crossEye(): boolean;
  61865. /**
  61866. * The background material of this dome.
  61867. */
  61868. get material(): BackgroundMaterial;
  61869. /**
  61870. * Oberserver used in Stereoscopic VR Mode.
  61871. */
  61872. private _onBeforeCameraRenderObserver;
  61873. /**
  61874. * Observable raised when an error occured while loading the 360 image
  61875. */
  61876. onLoadErrorObservable: Observable<string>;
  61877. /**
  61878. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61879. * @param name Element's name, child elements will append suffixes for their own names.
  61880. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61881. * @param options An object containing optional or exposed sub element properties
  61882. */
  61883. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61884. resolution?: number;
  61885. clickToPlay?: boolean;
  61886. autoPlay?: boolean;
  61887. loop?: boolean;
  61888. size?: number;
  61889. poster?: string;
  61890. faceForward?: boolean;
  61891. useDirectMapping?: boolean;
  61892. halfDomeMode?: boolean;
  61893. crossEyeMode?: boolean;
  61894. generateMipMaps?: boolean;
  61895. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61896. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61897. protected _changeTextureMode(value: number): void;
  61898. /**
  61899. * Releases resources associated with this node.
  61900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61902. */
  61903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61904. }
  61905. }
  61906. declare module BABYLON {
  61907. /**
  61908. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61909. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61910. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61911. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61912. */
  61913. export class PhotoDome extends TextureDome<Texture> {
  61914. /**
  61915. * Define the image as a Monoscopic panoramic 360 image.
  61916. */
  61917. static readonly MODE_MONOSCOPIC: number;
  61918. /**
  61919. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61920. */
  61921. static readonly MODE_TOPBOTTOM: number;
  61922. /**
  61923. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61924. */
  61925. static readonly MODE_SIDEBYSIDE: number;
  61926. /**
  61927. * Gets or sets the texture being displayed on the sphere
  61928. */
  61929. get photoTexture(): Texture;
  61930. /**
  61931. * sets the texture being displayed on the sphere
  61932. */
  61933. set photoTexture(value: Texture);
  61934. /**
  61935. * Gets the current video mode for the video. It can be:
  61936. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61937. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61938. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61939. */
  61940. get imageMode(): number;
  61941. /**
  61942. * Sets the current video mode for the video. It can be:
  61943. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61944. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61945. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61946. */
  61947. set imageMode(value: number);
  61948. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61949. }
  61950. }
  61951. declare module BABYLON {
  61952. /**
  61953. * Direct draw surface info
  61954. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61955. */
  61956. export interface DDSInfo {
  61957. /**
  61958. * Width of the texture
  61959. */
  61960. width: number;
  61961. /**
  61962. * Width of the texture
  61963. */
  61964. height: number;
  61965. /**
  61966. * Number of Mipmaps for the texture
  61967. * @see https://en.wikipedia.org/wiki/Mipmap
  61968. */
  61969. mipmapCount: number;
  61970. /**
  61971. * If the textures format is a known fourCC format
  61972. * @see https://www.fourcc.org/
  61973. */
  61974. isFourCC: boolean;
  61975. /**
  61976. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61977. */
  61978. isRGB: boolean;
  61979. /**
  61980. * If the texture is a lumincance format
  61981. */
  61982. isLuminance: boolean;
  61983. /**
  61984. * If this is a cube texture
  61985. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61986. */
  61987. isCube: boolean;
  61988. /**
  61989. * If the texture is a compressed format eg. FOURCC_DXT1
  61990. */
  61991. isCompressed: boolean;
  61992. /**
  61993. * The dxgiFormat of the texture
  61994. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61995. */
  61996. dxgiFormat: number;
  61997. /**
  61998. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61999. */
  62000. textureType: number;
  62001. /**
  62002. * Sphericle polynomial created for the dds texture
  62003. */
  62004. sphericalPolynomial?: SphericalPolynomial;
  62005. }
  62006. /**
  62007. * Class used to provide DDS decompression tools
  62008. */
  62009. export class DDSTools {
  62010. /**
  62011. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62012. */
  62013. static StoreLODInAlphaChannel: boolean;
  62014. /**
  62015. * Gets DDS information from an array buffer
  62016. * @param data defines the array buffer view to read data from
  62017. * @returns the DDS information
  62018. */
  62019. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62020. private static _FloatView;
  62021. private static _Int32View;
  62022. private static _ToHalfFloat;
  62023. private static _FromHalfFloat;
  62024. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62025. private static _GetHalfFloatRGBAArrayBuffer;
  62026. private static _GetFloatRGBAArrayBuffer;
  62027. private static _GetFloatAsUIntRGBAArrayBuffer;
  62028. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62029. private static _GetRGBAArrayBuffer;
  62030. private static _ExtractLongWordOrder;
  62031. private static _GetRGBArrayBuffer;
  62032. private static _GetLuminanceArrayBuffer;
  62033. /**
  62034. * Uploads DDS Levels to a Babylon Texture
  62035. * @hidden
  62036. */
  62037. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62038. }
  62039. interface ThinEngine {
  62040. /**
  62041. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62042. * @param rootUrl defines the url where the file to load is located
  62043. * @param scene defines the current scene
  62044. * @param lodScale defines scale to apply to the mip map selection
  62045. * @param lodOffset defines offset to apply to the mip map selection
  62046. * @param onLoad defines an optional callback raised when the texture is loaded
  62047. * @param onError defines an optional callback raised if there is an issue to load the texture
  62048. * @param format defines the format of the data
  62049. * @param forcedExtension defines the extension to use to pick the right loader
  62050. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62051. * @returns the cube texture as an InternalTexture
  62052. */
  62053. 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;
  62054. }
  62055. }
  62056. declare module BABYLON {
  62057. /**
  62058. * Implementation of the DDS Texture Loader.
  62059. * @hidden
  62060. */
  62061. export class _DDSTextureLoader implements IInternalTextureLoader {
  62062. /**
  62063. * Defines wether the loader supports cascade loading the different faces.
  62064. */
  62065. readonly supportCascades: boolean;
  62066. /**
  62067. * This returns if the loader support the current file information.
  62068. * @param extension defines the file extension of the file being loaded
  62069. * @returns true if the loader can load the specified file
  62070. */
  62071. canLoad(extension: string): boolean;
  62072. /**
  62073. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62074. * @param data contains the texture data
  62075. * @param texture defines the BabylonJS internal texture
  62076. * @param createPolynomials will be true if polynomials have been requested
  62077. * @param onLoad defines the callback to trigger once the texture is ready
  62078. * @param onError defines the callback to trigger in case of error
  62079. */
  62080. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62081. /**
  62082. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62083. * @param data contains the texture data
  62084. * @param texture defines the BabylonJS internal texture
  62085. * @param callback defines the method to call once ready to upload
  62086. */
  62087. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62088. }
  62089. }
  62090. declare module BABYLON {
  62091. /**
  62092. * Implementation of the ENV Texture Loader.
  62093. * @hidden
  62094. */
  62095. export class _ENVTextureLoader implements IInternalTextureLoader {
  62096. /**
  62097. * Defines wether the loader supports cascade loading the different faces.
  62098. */
  62099. readonly supportCascades: boolean;
  62100. /**
  62101. * This returns if the loader support the current file information.
  62102. * @param extension defines the file extension of the file being loaded
  62103. * @returns true if the loader can load the specified file
  62104. */
  62105. canLoad(extension: string): boolean;
  62106. /**
  62107. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62108. * @param data contains the texture data
  62109. * @param texture defines the BabylonJS internal texture
  62110. * @param createPolynomials will be true if polynomials have been requested
  62111. * @param onLoad defines the callback to trigger once the texture is ready
  62112. * @param onError defines the callback to trigger in case of error
  62113. */
  62114. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62115. /**
  62116. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62117. * @param data contains the texture data
  62118. * @param texture defines the BabylonJS internal texture
  62119. * @param callback defines the method to call once ready to upload
  62120. */
  62121. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62122. }
  62123. }
  62124. declare module BABYLON {
  62125. /**
  62126. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62127. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62128. */
  62129. export class KhronosTextureContainer {
  62130. /** contents of the KTX container file */
  62131. data: ArrayBufferView;
  62132. private static HEADER_LEN;
  62133. private static COMPRESSED_2D;
  62134. private static COMPRESSED_3D;
  62135. private static TEX_2D;
  62136. private static TEX_3D;
  62137. /**
  62138. * Gets the openGL type
  62139. */
  62140. glType: number;
  62141. /**
  62142. * Gets the openGL type size
  62143. */
  62144. glTypeSize: number;
  62145. /**
  62146. * Gets the openGL format
  62147. */
  62148. glFormat: number;
  62149. /**
  62150. * Gets the openGL internal format
  62151. */
  62152. glInternalFormat: number;
  62153. /**
  62154. * Gets the base internal format
  62155. */
  62156. glBaseInternalFormat: number;
  62157. /**
  62158. * Gets image width in pixel
  62159. */
  62160. pixelWidth: number;
  62161. /**
  62162. * Gets image height in pixel
  62163. */
  62164. pixelHeight: number;
  62165. /**
  62166. * Gets image depth in pixels
  62167. */
  62168. pixelDepth: number;
  62169. /**
  62170. * Gets the number of array elements
  62171. */
  62172. numberOfArrayElements: number;
  62173. /**
  62174. * Gets the number of faces
  62175. */
  62176. numberOfFaces: number;
  62177. /**
  62178. * Gets the number of mipmap levels
  62179. */
  62180. numberOfMipmapLevels: number;
  62181. /**
  62182. * Gets the bytes of key value data
  62183. */
  62184. bytesOfKeyValueData: number;
  62185. /**
  62186. * Gets the load type
  62187. */
  62188. loadType: number;
  62189. /**
  62190. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62191. */
  62192. isInvalid: boolean;
  62193. /**
  62194. * Creates a new KhronosTextureContainer
  62195. * @param data contents of the KTX container file
  62196. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62197. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62198. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62199. */
  62200. constructor(
  62201. /** contents of the KTX container file */
  62202. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62203. /**
  62204. * Uploads KTX content to a Babylon Texture.
  62205. * It is assumed that the texture has already been created & is currently bound
  62206. * @hidden
  62207. */
  62208. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62209. private _upload2DCompressedLevels;
  62210. /**
  62211. * Checks if the given data starts with a KTX file identifier.
  62212. * @param data the data to check
  62213. * @returns true if the data is a KTX file or false otherwise
  62214. */
  62215. static IsValid(data: ArrayBufferView): boolean;
  62216. }
  62217. }
  62218. declare module BABYLON {
  62219. /**
  62220. * Helper class to push actions to a pool of workers.
  62221. */
  62222. export class WorkerPool implements IDisposable {
  62223. private _workerInfos;
  62224. private _pendingActions;
  62225. /**
  62226. * Constructor
  62227. * @param workers Array of workers to use for actions
  62228. */
  62229. constructor(workers: Array<Worker>);
  62230. /**
  62231. * Terminates all workers and clears any pending actions.
  62232. */
  62233. dispose(): void;
  62234. /**
  62235. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62236. * pended until a worker has completed its action.
  62237. * @param action The action to perform. Call onComplete when the action is complete.
  62238. */
  62239. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62240. private _execute;
  62241. }
  62242. }
  62243. declare module BABYLON {
  62244. /**
  62245. * Class for loading KTX2 files
  62246. */
  62247. export class KhronosTextureContainer2 {
  62248. private static _WorkerPoolPromise?;
  62249. private static _Initialized;
  62250. private static _Ktx2Decoder;
  62251. /**
  62252. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62253. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62254. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62255. * Urls you can change:
  62256. * URLConfig.jsDecoderModule
  62257. * URLConfig.wasmUASTCToASTC
  62258. * URLConfig.wasmUASTCToBC7
  62259. * URLConfig.wasmUASTCToRGBA_UNORM
  62260. * URLConfig.wasmUASTCToRGBA_SRGB
  62261. * URLConfig.jsMSCTranscoder
  62262. * URLConfig.wasmMSCTranscoder
  62263. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62264. */
  62265. static URLConfig: {
  62266. jsDecoderModule: string;
  62267. wasmUASTCToASTC: null;
  62268. wasmUASTCToBC7: null;
  62269. wasmUASTCToRGBA_UNORM: null;
  62270. wasmUASTCToRGBA_SRGB: null;
  62271. jsMSCTranscoder: null;
  62272. wasmMSCTranscoder: null;
  62273. };
  62274. /**
  62275. * Default number of workers used to handle data decoding
  62276. */
  62277. static DefaultNumWorkers: number;
  62278. private static GetDefaultNumWorkers;
  62279. private _engine;
  62280. private static _CreateWorkerPool;
  62281. /**
  62282. * Constructor
  62283. * @param engine The engine to use
  62284. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62285. */
  62286. constructor(engine: ThinEngine, numWorkers?: number);
  62287. /** @hidden */
  62288. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62289. /**
  62290. * Stop all async operations and release resources.
  62291. */
  62292. dispose(): void;
  62293. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62294. /**
  62295. * Checks if the given data starts with a KTX2 file identifier.
  62296. * @param data the data to check
  62297. * @returns true if the data is a KTX2 file or false otherwise
  62298. */
  62299. static IsValid(data: ArrayBufferView): boolean;
  62300. }
  62301. }
  62302. declare module BABYLON {
  62303. /**
  62304. * Implementation of the KTX Texture Loader.
  62305. * @hidden
  62306. */
  62307. export class _KTXTextureLoader implements IInternalTextureLoader {
  62308. /**
  62309. * Defines wether the loader supports cascade loading the different faces.
  62310. */
  62311. readonly supportCascades: boolean;
  62312. /**
  62313. * This returns if the loader support the current file information.
  62314. * @param extension defines the file extension of the file being loaded
  62315. * @param mimeType defines the optional mime type of the file being loaded
  62316. * @returns true if the loader can load the specified file
  62317. */
  62318. canLoad(extension: string, mimeType?: string): boolean;
  62319. /**
  62320. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62321. * @param data contains the texture data
  62322. * @param texture defines the BabylonJS internal texture
  62323. * @param createPolynomials will be true if polynomials have been requested
  62324. * @param onLoad defines the callback to trigger once the texture is ready
  62325. * @param onError defines the callback to trigger in case of error
  62326. */
  62327. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62328. /**
  62329. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62330. * @param data contains the texture data
  62331. * @param texture defines the BabylonJS internal texture
  62332. * @param callback defines the method to call once ready to upload
  62333. */
  62334. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62335. }
  62336. }
  62337. declare module BABYLON {
  62338. /** @hidden */
  62339. export var _forceSceneHelpersToBundle: boolean;
  62340. interface Scene {
  62341. /**
  62342. * Creates a default light for the scene.
  62343. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62344. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62345. */
  62346. createDefaultLight(replace?: boolean): void;
  62347. /**
  62348. * Creates a default camera for the scene.
  62349. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62350. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62351. * @param replace has default false, when true replaces the active camera in the scene
  62352. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62353. */
  62354. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62355. /**
  62356. * Creates a default camera and a default light.
  62357. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62358. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62359. * @param replace has the default false, when true replaces the active camera/light in the scene
  62360. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62361. */
  62362. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62363. /**
  62364. * Creates a new sky box
  62365. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62366. * @param environmentTexture defines the texture to use as environment texture
  62367. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62368. * @param scale defines the overall scale of the skybox
  62369. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62370. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62371. * @returns a new mesh holding the sky box
  62372. */
  62373. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62374. /**
  62375. * Creates a new environment
  62376. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62377. * @param options defines the options you can use to configure the environment
  62378. * @returns the new EnvironmentHelper
  62379. */
  62380. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62381. /**
  62382. * Creates a new VREXperienceHelper
  62383. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62384. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62385. * @returns a new VREXperienceHelper
  62386. */
  62387. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62388. /**
  62389. * Creates a new WebXRDefaultExperience
  62390. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62391. * @param options experience options
  62392. * @returns a promise for a new WebXRDefaultExperience
  62393. */
  62394. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62395. }
  62396. }
  62397. declare module BABYLON {
  62398. /**
  62399. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62400. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62401. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62402. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62403. */
  62404. export class VideoDome extends TextureDome<VideoTexture> {
  62405. /**
  62406. * Define the video source as a Monoscopic panoramic 360 video.
  62407. */
  62408. static readonly MODE_MONOSCOPIC: number;
  62409. /**
  62410. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62411. */
  62412. static readonly MODE_TOPBOTTOM: number;
  62413. /**
  62414. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62415. */
  62416. static readonly MODE_SIDEBYSIDE: number;
  62417. /**
  62418. * Get the video texture associated with this video dome
  62419. */
  62420. get videoTexture(): VideoTexture;
  62421. /**
  62422. * Get the video mode of this dome
  62423. */
  62424. get videoMode(): number;
  62425. /**
  62426. * Set the video mode of this dome.
  62427. * @see textureMode
  62428. */
  62429. set videoMode(value: number);
  62430. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62431. }
  62432. }
  62433. declare module BABYLON {
  62434. /**
  62435. * This class can be used to get instrumentation data from a Babylon engine
  62436. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62437. */
  62438. export class EngineInstrumentation implements IDisposable {
  62439. /**
  62440. * Define the instrumented engine.
  62441. */
  62442. engine: Engine;
  62443. private _captureGPUFrameTime;
  62444. private _gpuFrameTimeToken;
  62445. private _gpuFrameTime;
  62446. private _captureShaderCompilationTime;
  62447. private _shaderCompilationTime;
  62448. private _onBeginFrameObserver;
  62449. private _onEndFrameObserver;
  62450. private _onBeforeShaderCompilationObserver;
  62451. private _onAfterShaderCompilationObserver;
  62452. /**
  62453. * Gets the perf counter used for GPU frame time
  62454. */
  62455. get gpuFrameTimeCounter(): PerfCounter;
  62456. /**
  62457. * Gets the GPU frame time capture status
  62458. */
  62459. get captureGPUFrameTime(): boolean;
  62460. /**
  62461. * Enable or disable the GPU frame time capture
  62462. */
  62463. set captureGPUFrameTime(value: boolean);
  62464. /**
  62465. * Gets the perf counter used for shader compilation time
  62466. */
  62467. get shaderCompilationTimeCounter(): PerfCounter;
  62468. /**
  62469. * Gets the shader compilation time capture status
  62470. */
  62471. get captureShaderCompilationTime(): boolean;
  62472. /**
  62473. * Enable or disable the shader compilation time capture
  62474. */
  62475. set captureShaderCompilationTime(value: boolean);
  62476. /**
  62477. * Instantiates a new engine instrumentation.
  62478. * This class can be used to get instrumentation data from a Babylon engine
  62479. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62480. * @param engine Defines the engine to instrument
  62481. */
  62482. constructor(
  62483. /**
  62484. * Define the instrumented engine.
  62485. */
  62486. engine: Engine);
  62487. /**
  62488. * Dispose and release associated resources.
  62489. */
  62490. dispose(): void;
  62491. }
  62492. }
  62493. declare module BABYLON {
  62494. /**
  62495. * This class can be used to get instrumentation data from a Babylon engine
  62496. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62497. */
  62498. export class SceneInstrumentation implements IDisposable {
  62499. /**
  62500. * Defines the scene to instrument
  62501. */
  62502. scene: Scene;
  62503. private _captureActiveMeshesEvaluationTime;
  62504. private _activeMeshesEvaluationTime;
  62505. private _captureRenderTargetsRenderTime;
  62506. private _renderTargetsRenderTime;
  62507. private _captureFrameTime;
  62508. private _frameTime;
  62509. private _captureRenderTime;
  62510. private _renderTime;
  62511. private _captureInterFrameTime;
  62512. private _interFrameTime;
  62513. private _captureParticlesRenderTime;
  62514. private _particlesRenderTime;
  62515. private _captureSpritesRenderTime;
  62516. private _spritesRenderTime;
  62517. private _capturePhysicsTime;
  62518. private _physicsTime;
  62519. private _captureAnimationsTime;
  62520. private _animationsTime;
  62521. private _captureCameraRenderTime;
  62522. private _cameraRenderTime;
  62523. private _onBeforeActiveMeshesEvaluationObserver;
  62524. private _onAfterActiveMeshesEvaluationObserver;
  62525. private _onBeforeRenderTargetsRenderObserver;
  62526. private _onAfterRenderTargetsRenderObserver;
  62527. private _onAfterRenderObserver;
  62528. private _onBeforeDrawPhaseObserver;
  62529. private _onAfterDrawPhaseObserver;
  62530. private _onBeforeAnimationsObserver;
  62531. private _onBeforeParticlesRenderingObserver;
  62532. private _onAfterParticlesRenderingObserver;
  62533. private _onBeforeSpritesRenderingObserver;
  62534. private _onAfterSpritesRenderingObserver;
  62535. private _onBeforePhysicsObserver;
  62536. private _onAfterPhysicsObserver;
  62537. private _onAfterAnimationsObserver;
  62538. private _onBeforeCameraRenderObserver;
  62539. private _onAfterCameraRenderObserver;
  62540. /**
  62541. * Gets the perf counter used for active meshes evaluation time
  62542. */
  62543. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62544. /**
  62545. * Gets the active meshes evaluation time capture status
  62546. */
  62547. get captureActiveMeshesEvaluationTime(): boolean;
  62548. /**
  62549. * Enable or disable the active meshes evaluation time capture
  62550. */
  62551. set captureActiveMeshesEvaluationTime(value: boolean);
  62552. /**
  62553. * Gets the perf counter used for render targets render time
  62554. */
  62555. get renderTargetsRenderTimeCounter(): PerfCounter;
  62556. /**
  62557. * Gets the render targets render time capture status
  62558. */
  62559. get captureRenderTargetsRenderTime(): boolean;
  62560. /**
  62561. * Enable or disable the render targets render time capture
  62562. */
  62563. set captureRenderTargetsRenderTime(value: boolean);
  62564. /**
  62565. * Gets the perf counter used for particles render time
  62566. */
  62567. get particlesRenderTimeCounter(): PerfCounter;
  62568. /**
  62569. * Gets the particles render time capture status
  62570. */
  62571. get captureParticlesRenderTime(): boolean;
  62572. /**
  62573. * Enable or disable the particles render time capture
  62574. */
  62575. set captureParticlesRenderTime(value: boolean);
  62576. /**
  62577. * Gets the perf counter used for sprites render time
  62578. */
  62579. get spritesRenderTimeCounter(): PerfCounter;
  62580. /**
  62581. * Gets the sprites render time capture status
  62582. */
  62583. get captureSpritesRenderTime(): boolean;
  62584. /**
  62585. * Enable or disable the sprites render time capture
  62586. */
  62587. set captureSpritesRenderTime(value: boolean);
  62588. /**
  62589. * Gets the perf counter used for physics time
  62590. */
  62591. get physicsTimeCounter(): PerfCounter;
  62592. /**
  62593. * Gets the physics time capture status
  62594. */
  62595. get capturePhysicsTime(): boolean;
  62596. /**
  62597. * Enable or disable the physics time capture
  62598. */
  62599. set capturePhysicsTime(value: boolean);
  62600. /**
  62601. * Gets the perf counter used for animations time
  62602. */
  62603. get animationsTimeCounter(): PerfCounter;
  62604. /**
  62605. * Gets the animations time capture status
  62606. */
  62607. get captureAnimationsTime(): boolean;
  62608. /**
  62609. * Enable or disable the animations time capture
  62610. */
  62611. set captureAnimationsTime(value: boolean);
  62612. /**
  62613. * Gets the perf counter used for frame time capture
  62614. */
  62615. get frameTimeCounter(): PerfCounter;
  62616. /**
  62617. * Gets the frame time capture status
  62618. */
  62619. get captureFrameTime(): boolean;
  62620. /**
  62621. * Enable or disable the frame time capture
  62622. */
  62623. set captureFrameTime(value: boolean);
  62624. /**
  62625. * Gets the perf counter used for inter-frames time capture
  62626. */
  62627. get interFrameTimeCounter(): PerfCounter;
  62628. /**
  62629. * Gets the inter-frames time capture status
  62630. */
  62631. get captureInterFrameTime(): boolean;
  62632. /**
  62633. * Enable or disable the inter-frames time capture
  62634. */
  62635. set captureInterFrameTime(value: boolean);
  62636. /**
  62637. * Gets the perf counter used for render time capture
  62638. */
  62639. get renderTimeCounter(): PerfCounter;
  62640. /**
  62641. * Gets the render time capture status
  62642. */
  62643. get captureRenderTime(): boolean;
  62644. /**
  62645. * Enable or disable the render time capture
  62646. */
  62647. set captureRenderTime(value: boolean);
  62648. /**
  62649. * Gets the perf counter used for camera render time capture
  62650. */
  62651. get cameraRenderTimeCounter(): PerfCounter;
  62652. /**
  62653. * Gets the camera render time capture status
  62654. */
  62655. get captureCameraRenderTime(): boolean;
  62656. /**
  62657. * Enable or disable the camera render time capture
  62658. */
  62659. set captureCameraRenderTime(value: boolean);
  62660. /**
  62661. * Gets the perf counter used for draw calls
  62662. */
  62663. get drawCallsCounter(): PerfCounter;
  62664. /**
  62665. * Instantiates a new scene instrumentation.
  62666. * This class can be used to get instrumentation data from a Babylon engine
  62667. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62668. * @param scene Defines the scene to instrument
  62669. */
  62670. constructor(
  62671. /**
  62672. * Defines the scene to instrument
  62673. */
  62674. scene: Scene);
  62675. /**
  62676. * Dispose and release associated resources.
  62677. */
  62678. dispose(): void;
  62679. }
  62680. }
  62681. declare module BABYLON {
  62682. /** @hidden */
  62683. export var glowMapGenerationPixelShader: {
  62684. name: string;
  62685. shader: string;
  62686. };
  62687. }
  62688. declare module BABYLON {
  62689. /** @hidden */
  62690. export var glowMapGenerationVertexShader: {
  62691. name: string;
  62692. shader: string;
  62693. };
  62694. }
  62695. declare module BABYLON {
  62696. /**
  62697. * Effect layer options. This helps customizing the behaviour
  62698. * of the effect layer.
  62699. */
  62700. export interface IEffectLayerOptions {
  62701. /**
  62702. * Multiplication factor apply to the canvas size to compute the render target size
  62703. * used to generated the objects (the smaller the faster).
  62704. */
  62705. mainTextureRatio: number;
  62706. /**
  62707. * Enforces a fixed size texture to ensure effect stability across devices.
  62708. */
  62709. mainTextureFixedSize?: number;
  62710. /**
  62711. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62712. */
  62713. alphaBlendingMode: number;
  62714. /**
  62715. * The camera attached to the layer.
  62716. */
  62717. camera: Nullable<Camera>;
  62718. /**
  62719. * The rendering group to draw the layer in.
  62720. */
  62721. renderingGroupId: number;
  62722. }
  62723. /**
  62724. * The effect layer Helps adding post process effect blended with the main pass.
  62725. *
  62726. * This can be for instance use to generate glow or higlight effects on the scene.
  62727. *
  62728. * The effect layer class can not be used directly and is intented to inherited from to be
  62729. * customized per effects.
  62730. */
  62731. export abstract class EffectLayer {
  62732. private _vertexBuffers;
  62733. private _indexBuffer;
  62734. private _cachedDefines;
  62735. private _effectLayerMapGenerationEffect;
  62736. private _effectLayerOptions;
  62737. private _mergeEffect;
  62738. protected _scene: Scene;
  62739. protected _engine: Engine;
  62740. protected _maxSize: number;
  62741. protected _mainTextureDesiredSize: ISize;
  62742. protected _mainTexture: RenderTargetTexture;
  62743. protected _shouldRender: boolean;
  62744. protected _postProcesses: PostProcess[];
  62745. protected _textures: BaseTexture[];
  62746. protected _emissiveTextureAndColor: {
  62747. texture: Nullable<BaseTexture>;
  62748. color: Color4;
  62749. };
  62750. /**
  62751. * The name of the layer
  62752. */
  62753. name: string;
  62754. /**
  62755. * The clear color of the texture used to generate the glow map.
  62756. */
  62757. neutralColor: Color4;
  62758. /**
  62759. * Specifies whether the highlight layer is enabled or not.
  62760. */
  62761. isEnabled: boolean;
  62762. /**
  62763. * Gets the camera attached to the layer.
  62764. */
  62765. get camera(): Nullable<Camera>;
  62766. /**
  62767. * Gets the rendering group id the layer should render in.
  62768. */
  62769. get renderingGroupId(): number;
  62770. set renderingGroupId(renderingGroupId: number);
  62771. /**
  62772. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62773. */
  62774. disableBoundingBoxesFromEffectLayer: boolean;
  62775. /**
  62776. * An event triggered when the effect layer has been disposed.
  62777. */
  62778. onDisposeObservable: Observable<EffectLayer>;
  62779. /**
  62780. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62781. */
  62782. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62783. /**
  62784. * An event triggered when the generated texture is being merged in the scene.
  62785. */
  62786. onBeforeComposeObservable: Observable<EffectLayer>;
  62787. /**
  62788. * An event triggered when the mesh is rendered into the effect render target.
  62789. */
  62790. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62791. /**
  62792. * An event triggered after the mesh has been rendered into the effect render target.
  62793. */
  62794. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62795. /**
  62796. * An event triggered when the generated texture has been merged in the scene.
  62797. */
  62798. onAfterComposeObservable: Observable<EffectLayer>;
  62799. /**
  62800. * An event triggered when the efffect layer changes its size.
  62801. */
  62802. onSizeChangedObservable: Observable<EffectLayer>;
  62803. /** @hidden */
  62804. static _SceneComponentInitialization: (scene: Scene) => void;
  62805. /**
  62806. * Instantiates a new effect Layer and references it in the scene.
  62807. * @param name The name of the layer
  62808. * @param scene The scene to use the layer in
  62809. */
  62810. constructor(
  62811. /** The Friendly of the effect in the scene */
  62812. name: string, scene: Scene);
  62813. /**
  62814. * Get the effect name of the layer.
  62815. * @return The effect name
  62816. */
  62817. abstract getEffectName(): string;
  62818. /**
  62819. * Checks for the readiness of the element composing the layer.
  62820. * @param subMesh the mesh to check for
  62821. * @param useInstances specify whether or not to use instances to render the mesh
  62822. * @return true if ready otherwise, false
  62823. */
  62824. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62825. /**
  62826. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62827. * @returns true if the effect requires stencil during the main canvas render pass.
  62828. */
  62829. abstract needStencil(): boolean;
  62830. /**
  62831. * Create the merge effect. This is the shader use to blit the information back
  62832. * to the main canvas at the end of the scene rendering.
  62833. * @returns The effect containing the shader used to merge the effect on the main canvas
  62834. */
  62835. protected abstract _createMergeEffect(): Effect;
  62836. /**
  62837. * Creates the render target textures and post processes used in the effect layer.
  62838. */
  62839. protected abstract _createTextureAndPostProcesses(): void;
  62840. /**
  62841. * Implementation specific of rendering the generating effect on the main canvas.
  62842. * @param effect The effect used to render through
  62843. */
  62844. protected abstract _internalRender(effect: Effect): void;
  62845. /**
  62846. * Sets the required values for both the emissive texture and and the main color.
  62847. */
  62848. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62849. /**
  62850. * Free any resources and references associated to a mesh.
  62851. * Internal use
  62852. * @param mesh The mesh to free.
  62853. */
  62854. abstract _disposeMesh(mesh: Mesh): void;
  62855. /**
  62856. * Serializes this layer (Glow or Highlight for example)
  62857. * @returns a serialized layer object
  62858. */
  62859. abstract serialize?(): any;
  62860. /**
  62861. * Initializes the effect layer with the required options.
  62862. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62863. */
  62864. protected _init(options: Partial<IEffectLayerOptions>): void;
  62865. /**
  62866. * Generates the index buffer of the full screen quad blending to the main canvas.
  62867. */
  62868. private _generateIndexBuffer;
  62869. /**
  62870. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62871. */
  62872. private _generateVertexBuffer;
  62873. /**
  62874. * Sets the main texture desired size which is the closest power of two
  62875. * of the engine canvas size.
  62876. */
  62877. private _setMainTextureSize;
  62878. /**
  62879. * Creates the main texture for the effect layer.
  62880. */
  62881. protected _createMainTexture(): void;
  62882. /**
  62883. * Adds specific effects defines.
  62884. * @param defines The defines to add specifics to.
  62885. */
  62886. protected _addCustomEffectDefines(defines: string[]): void;
  62887. /**
  62888. * Checks for the readiness of the element composing the layer.
  62889. * @param subMesh the mesh to check for
  62890. * @param useInstances specify whether or not to use instances to render the mesh
  62891. * @param emissiveTexture the associated emissive texture used to generate the glow
  62892. * @return true if ready otherwise, false
  62893. */
  62894. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62895. /**
  62896. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62897. */
  62898. render(): void;
  62899. /**
  62900. * Determine if a given mesh will be used in the current effect.
  62901. * @param mesh mesh to test
  62902. * @returns true if the mesh will be used
  62903. */
  62904. hasMesh(mesh: AbstractMesh): boolean;
  62905. /**
  62906. * Returns true if the layer contains information to display, otherwise false.
  62907. * @returns true if the glow layer should be rendered
  62908. */
  62909. shouldRender(): boolean;
  62910. /**
  62911. * Returns true if the mesh should render, otherwise false.
  62912. * @param mesh The mesh to render
  62913. * @returns true if it should render otherwise false
  62914. */
  62915. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62916. /**
  62917. * Returns true if the mesh can be rendered, otherwise false.
  62918. * @param mesh The mesh to render
  62919. * @param material The material used on the mesh
  62920. * @returns true if it can be rendered otherwise false
  62921. */
  62922. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62923. /**
  62924. * Returns true if the mesh should render, otherwise false.
  62925. * @param mesh The mesh to render
  62926. * @returns true if it should render otherwise false
  62927. */
  62928. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62929. /**
  62930. * Renders the submesh passed in parameter to the generation map.
  62931. */
  62932. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62933. /**
  62934. * Defines whether the current material of the mesh should be use to render the effect.
  62935. * @param mesh defines the current mesh to render
  62936. */
  62937. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62938. /**
  62939. * Rebuild the required buffers.
  62940. * @hidden Internal use only.
  62941. */
  62942. _rebuild(): void;
  62943. /**
  62944. * Dispose only the render target textures and post process.
  62945. */
  62946. private _disposeTextureAndPostProcesses;
  62947. /**
  62948. * Dispose the highlight layer and free resources.
  62949. */
  62950. dispose(): void;
  62951. /**
  62952. * Gets the class name of the effect layer
  62953. * @returns the string with the class name of the effect layer
  62954. */
  62955. getClassName(): string;
  62956. /**
  62957. * Creates an effect layer from parsed effect layer data
  62958. * @param parsedEffectLayer defines effect layer data
  62959. * @param scene defines the current scene
  62960. * @param rootUrl defines the root URL containing the effect layer information
  62961. * @returns a parsed effect Layer
  62962. */
  62963. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62964. }
  62965. }
  62966. declare module BABYLON {
  62967. interface AbstractScene {
  62968. /**
  62969. * The list of effect layers (highlights/glow) added to the scene
  62970. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62971. * @see https://doc.babylonjs.com/how_to/glow_layer
  62972. */
  62973. effectLayers: Array<EffectLayer>;
  62974. /**
  62975. * Removes the given effect layer from this scene.
  62976. * @param toRemove defines the effect layer to remove
  62977. * @returns the index of the removed effect layer
  62978. */
  62979. removeEffectLayer(toRemove: EffectLayer): number;
  62980. /**
  62981. * Adds the given effect layer to this scene
  62982. * @param newEffectLayer defines the effect layer to add
  62983. */
  62984. addEffectLayer(newEffectLayer: EffectLayer): void;
  62985. }
  62986. /**
  62987. * Defines the layer scene component responsible to manage any effect layers
  62988. * in a given scene.
  62989. */
  62990. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62991. /**
  62992. * The component name helpfull to identify the component in the list of scene components.
  62993. */
  62994. readonly name: string;
  62995. /**
  62996. * The scene the component belongs to.
  62997. */
  62998. scene: Scene;
  62999. private _engine;
  63000. private _renderEffects;
  63001. private _needStencil;
  63002. private _previousStencilState;
  63003. /**
  63004. * Creates a new instance of the component for the given scene
  63005. * @param scene Defines the scene to register the component in
  63006. */
  63007. constructor(scene: Scene);
  63008. /**
  63009. * Registers the component in a given scene
  63010. */
  63011. register(): void;
  63012. /**
  63013. * Rebuilds the elements related to this component in case of
  63014. * context lost for instance.
  63015. */
  63016. rebuild(): void;
  63017. /**
  63018. * Serializes the component data to the specified json object
  63019. * @param serializationObject The object to serialize to
  63020. */
  63021. serialize(serializationObject: any): void;
  63022. /**
  63023. * Adds all the elements from the container to the scene
  63024. * @param container the container holding the elements
  63025. */
  63026. addFromContainer(container: AbstractScene): void;
  63027. /**
  63028. * Removes all the elements in the container from the scene
  63029. * @param container contains the elements to remove
  63030. * @param dispose if the removed element should be disposed (default: false)
  63031. */
  63032. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63033. /**
  63034. * Disposes the component and the associated ressources.
  63035. */
  63036. dispose(): void;
  63037. private _isReadyForMesh;
  63038. private _renderMainTexture;
  63039. private _setStencil;
  63040. private _setStencilBack;
  63041. private _draw;
  63042. private _drawCamera;
  63043. private _drawRenderingGroup;
  63044. }
  63045. }
  63046. declare module BABYLON {
  63047. /** @hidden */
  63048. export var glowMapMergePixelShader: {
  63049. name: string;
  63050. shader: string;
  63051. };
  63052. }
  63053. declare module BABYLON {
  63054. /** @hidden */
  63055. export var glowMapMergeVertexShader: {
  63056. name: string;
  63057. shader: string;
  63058. };
  63059. }
  63060. declare module BABYLON {
  63061. interface AbstractScene {
  63062. /**
  63063. * Return a the first highlight layer of the scene with a given name.
  63064. * @param name The name of the highlight layer to look for.
  63065. * @return The highlight layer if found otherwise null.
  63066. */
  63067. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63068. }
  63069. /**
  63070. * Glow layer options. This helps customizing the behaviour
  63071. * of the glow layer.
  63072. */
  63073. export interface IGlowLayerOptions {
  63074. /**
  63075. * Multiplication factor apply to the canvas size to compute the render target size
  63076. * used to generated the glowing objects (the smaller the faster).
  63077. */
  63078. mainTextureRatio: number;
  63079. /**
  63080. * Enforces a fixed size texture to ensure resize independant blur.
  63081. */
  63082. mainTextureFixedSize?: number;
  63083. /**
  63084. * How big is the kernel of the blur texture.
  63085. */
  63086. blurKernelSize: number;
  63087. /**
  63088. * The camera attached to the layer.
  63089. */
  63090. camera: Nullable<Camera>;
  63091. /**
  63092. * Enable MSAA by chosing the number of samples.
  63093. */
  63094. mainTextureSamples?: number;
  63095. /**
  63096. * The rendering group to draw the layer in.
  63097. */
  63098. renderingGroupId: number;
  63099. }
  63100. /**
  63101. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63102. *
  63103. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63104. *
  63105. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63106. */
  63107. export class GlowLayer extends EffectLayer {
  63108. /**
  63109. * Effect Name of the layer.
  63110. */
  63111. static readonly EffectName: string;
  63112. /**
  63113. * The default blur kernel size used for the glow.
  63114. */
  63115. static DefaultBlurKernelSize: number;
  63116. /**
  63117. * The default texture size ratio used for the glow.
  63118. */
  63119. static DefaultTextureRatio: number;
  63120. /**
  63121. * Sets the kernel size of the blur.
  63122. */
  63123. set blurKernelSize(value: number);
  63124. /**
  63125. * Gets the kernel size of the blur.
  63126. */
  63127. get blurKernelSize(): number;
  63128. /**
  63129. * Sets the glow intensity.
  63130. */
  63131. set intensity(value: number);
  63132. /**
  63133. * Gets the glow intensity.
  63134. */
  63135. get intensity(): number;
  63136. private _options;
  63137. private _intensity;
  63138. private _horizontalBlurPostprocess1;
  63139. private _verticalBlurPostprocess1;
  63140. private _horizontalBlurPostprocess2;
  63141. private _verticalBlurPostprocess2;
  63142. private _blurTexture1;
  63143. private _blurTexture2;
  63144. private _postProcesses1;
  63145. private _postProcesses2;
  63146. private _includedOnlyMeshes;
  63147. private _excludedMeshes;
  63148. private _meshesUsingTheirOwnMaterials;
  63149. /**
  63150. * Callback used to let the user override the color selection on a per mesh basis
  63151. */
  63152. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63153. /**
  63154. * Callback used to let the user override the texture selection on a per mesh basis
  63155. */
  63156. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63157. /**
  63158. * Instantiates a new glow Layer and references it to the scene.
  63159. * @param name The name of the layer
  63160. * @param scene The scene to use the layer in
  63161. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63162. */
  63163. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63164. /**
  63165. * Get the effect name of the layer.
  63166. * @return The effect name
  63167. */
  63168. getEffectName(): string;
  63169. /**
  63170. * Create the merge effect. This is the shader use to blit the information back
  63171. * to the main canvas at the end of the scene rendering.
  63172. */
  63173. protected _createMergeEffect(): Effect;
  63174. /**
  63175. * Creates the render target textures and post processes used in the glow layer.
  63176. */
  63177. protected _createTextureAndPostProcesses(): void;
  63178. /**
  63179. * Checks for the readiness of the element composing the layer.
  63180. * @param subMesh the mesh to check for
  63181. * @param useInstances specify wether or not to use instances to render the mesh
  63182. * @param emissiveTexture the associated emissive texture used to generate the glow
  63183. * @return true if ready otherwise, false
  63184. */
  63185. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63186. /**
  63187. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  63188. */
  63189. needStencil(): boolean;
  63190. /**
  63191. * Returns true if the mesh can be rendered, otherwise false.
  63192. * @param mesh The mesh to render
  63193. * @param material The material used on the mesh
  63194. * @returns true if it can be rendered otherwise false
  63195. */
  63196. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63197. /**
  63198. * Implementation specific of rendering the generating effect on the main canvas.
  63199. * @param effect The effect used to render through
  63200. */
  63201. protected _internalRender(effect: Effect): void;
  63202. /**
  63203. * Sets the required values for both the emissive texture and and the main color.
  63204. */
  63205. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63206. /**
  63207. * Returns true if the mesh should render, otherwise false.
  63208. * @param mesh The mesh to render
  63209. * @returns true if it should render otherwise false
  63210. */
  63211. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63212. /**
  63213. * Adds specific effects defines.
  63214. * @param defines The defines to add specifics to.
  63215. */
  63216. protected _addCustomEffectDefines(defines: string[]): void;
  63217. /**
  63218. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63219. * @param mesh The mesh to exclude from the glow layer
  63220. */
  63221. addExcludedMesh(mesh: Mesh): void;
  63222. /**
  63223. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63224. * @param mesh The mesh to remove
  63225. */
  63226. removeExcludedMesh(mesh: Mesh): void;
  63227. /**
  63228. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63229. * @param mesh The mesh to include in the glow layer
  63230. */
  63231. addIncludedOnlyMesh(mesh: Mesh): void;
  63232. /**
  63233. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63234. * @param mesh The mesh to remove
  63235. */
  63236. removeIncludedOnlyMesh(mesh: Mesh): void;
  63237. /**
  63238. * Determine if a given mesh will be used in the glow layer
  63239. * @param mesh The mesh to test
  63240. * @returns true if the mesh will be highlighted by the current glow layer
  63241. */
  63242. hasMesh(mesh: AbstractMesh): boolean;
  63243. /**
  63244. * Defines whether the current material of the mesh should be use to render the effect.
  63245. * @param mesh defines the current mesh to render
  63246. */
  63247. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63248. /**
  63249. * Add a mesh to be rendered through its own material and not with emissive only.
  63250. * @param mesh The mesh for which we need to use its material
  63251. */
  63252. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63253. /**
  63254. * Remove a mesh from being rendered through its own material and not with emissive only.
  63255. * @param mesh The mesh for which we need to not use its material
  63256. */
  63257. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63258. /**
  63259. * Free any resources and references associated to a mesh.
  63260. * Internal use
  63261. * @param mesh The mesh to free.
  63262. * @hidden
  63263. */
  63264. _disposeMesh(mesh: Mesh): void;
  63265. /**
  63266. * Gets the class name of the effect layer
  63267. * @returns the string with the class name of the effect layer
  63268. */
  63269. getClassName(): string;
  63270. /**
  63271. * Serializes this glow layer
  63272. * @returns a serialized glow layer object
  63273. */
  63274. serialize(): any;
  63275. /**
  63276. * Creates a Glow Layer from parsed glow layer data
  63277. * @param parsedGlowLayer defines glow layer data
  63278. * @param scene defines the current scene
  63279. * @param rootUrl defines the root URL containing the glow layer information
  63280. * @returns a parsed Glow Layer
  63281. */
  63282. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63283. }
  63284. }
  63285. declare module BABYLON {
  63286. /** @hidden */
  63287. export var glowBlurPostProcessPixelShader: {
  63288. name: string;
  63289. shader: string;
  63290. };
  63291. }
  63292. declare module BABYLON {
  63293. interface AbstractScene {
  63294. /**
  63295. * Return a the first highlight layer of the scene with a given name.
  63296. * @param name The name of the highlight layer to look for.
  63297. * @return The highlight layer if found otherwise null.
  63298. */
  63299. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63300. }
  63301. /**
  63302. * Highlight layer options. This helps customizing the behaviour
  63303. * of the highlight layer.
  63304. */
  63305. export interface IHighlightLayerOptions {
  63306. /**
  63307. * Multiplication factor apply to the canvas size to compute the render target size
  63308. * used to generated the glowing objects (the smaller the faster).
  63309. */
  63310. mainTextureRatio: number;
  63311. /**
  63312. * Enforces a fixed size texture to ensure resize independant blur.
  63313. */
  63314. mainTextureFixedSize?: number;
  63315. /**
  63316. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63317. * of the picture to blur (the smaller the faster).
  63318. */
  63319. blurTextureSizeRatio: number;
  63320. /**
  63321. * How big in texel of the blur texture is the vertical blur.
  63322. */
  63323. blurVerticalSize: number;
  63324. /**
  63325. * How big in texel of the blur texture is the horizontal blur.
  63326. */
  63327. blurHorizontalSize: number;
  63328. /**
  63329. * Alpha blending mode used to apply the blur. Default is combine.
  63330. */
  63331. alphaBlendingMode: number;
  63332. /**
  63333. * The camera attached to the layer.
  63334. */
  63335. camera: Nullable<Camera>;
  63336. /**
  63337. * Should we display highlight as a solid stroke?
  63338. */
  63339. isStroke?: boolean;
  63340. /**
  63341. * The rendering group to draw the layer in.
  63342. */
  63343. renderingGroupId: number;
  63344. }
  63345. /**
  63346. * The highlight layer Helps adding a glow effect around a mesh.
  63347. *
  63348. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63349. * glowy meshes to your scene.
  63350. *
  63351. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63352. */
  63353. export class HighlightLayer extends EffectLayer {
  63354. name: string;
  63355. /**
  63356. * Effect Name of the highlight layer.
  63357. */
  63358. static readonly EffectName: string;
  63359. /**
  63360. * The neutral color used during the preparation of the glow effect.
  63361. * This is black by default as the blend operation is a blend operation.
  63362. */
  63363. static NeutralColor: Color4;
  63364. /**
  63365. * Stencil value used for glowing meshes.
  63366. */
  63367. static GlowingMeshStencilReference: number;
  63368. /**
  63369. * Stencil value used for the other meshes in the scene.
  63370. */
  63371. static NormalMeshStencilReference: number;
  63372. /**
  63373. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63374. */
  63375. innerGlow: boolean;
  63376. /**
  63377. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63378. */
  63379. outerGlow: boolean;
  63380. /**
  63381. * Specifies the horizontal size of the blur.
  63382. */
  63383. set blurHorizontalSize(value: number);
  63384. /**
  63385. * Specifies the vertical size of the blur.
  63386. */
  63387. set blurVerticalSize(value: number);
  63388. /**
  63389. * Gets the horizontal size of the blur.
  63390. */
  63391. get blurHorizontalSize(): number;
  63392. /**
  63393. * Gets the vertical size of the blur.
  63394. */
  63395. get blurVerticalSize(): number;
  63396. /**
  63397. * An event triggered when the highlight layer is being blurred.
  63398. */
  63399. onBeforeBlurObservable: Observable<HighlightLayer>;
  63400. /**
  63401. * An event triggered when the highlight layer has been blurred.
  63402. */
  63403. onAfterBlurObservable: Observable<HighlightLayer>;
  63404. private _instanceGlowingMeshStencilReference;
  63405. private _options;
  63406. private _downSamplePostprocess;
  63407. private _horizontalBlurPostprocess;
  63408. private _verticalBlurPostprocess;
  63409. private _blurTexture;
  63410. private _meshes;
  63411. private _excludedMeshes;
  63412. /**
  63413. * Instantiates a new highlight Layer and references it to the scene..
  63414. * @param name The name of the layer
  63415. * @param scene The scene to use the layer in
  63416. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63417. */
  63418. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63419. /**
  63420. * Get the effect name of the layer.
  63421. * @return The effect name
  63422. */
  63423. getEffectName(): string;
  63424. /**
  63425. * Create the merge effect. This is the shader use to blit the information back
  63426. * to the main canvas at the end of the scene rendering.
  63427. */
  63428. protected _createMergeEffect(): Effect;
  63429. /**
  63430. * Creates the render target textures and post processes used in the highlight layer.
  63431. */
  63432. protected _createTextureAndPostProcesses(): void;
  63433. /**
  63434. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63435. */
  63436. needStencil(): boolean;
  63437. /**
  63438. * Checks for the readiness of the element composing the layer.
  63439. * @param subMesh the mesh to check for
  63440. * @param useInstances specify wether or not to use instances to render the mesh
  63441. * @param emissiveTexture the associated emissive texture used to generate the glow
  63442. * @return true if ready otherwise, false
  63443. */
  63444. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63445. /**
  63446. * Implementation specific of rendering the generating effect on the main canvas.
  63447. * @param effect The effect used to render through
  63448. */
  63449. protected _internalRender(effect: Effect): void;
  63450. /**
  63451. * Returns true if the layer contains information to display, otherwise false.
  63452. */
  63453. shouldRender(): boolean;
  63454. /**
  63455. * Returns true if the mesh should render, otherwise false.
  63456. * @param mesh The mesh to render
  63457. * @returns true if it should render otherwise false
  63458. */
  63459. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63460. /**
  63461. * Returns true if the mesh can be rendered, otherwise false.
  63462. * @param mesh The mesh to render
  63463. * @param material The material used on the mesh
  63464. * @returns true if it can be rendered otherwise false
  63465. */
  63466. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63467. /**
  63468. * Adds specific effects defines.
  63469. * @param defines The defines to add specifics to.
  63470. */
  63471. protected _addCustomEffectDefines(defines: string[]): void;
  63472. /**
  63473. * Sets the required values for both the emissive texture and and the main color.
  63474. */
  63475. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63476. /**
  63477. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63478. * @param mesh The mesh to exclude from the highlight layer
  63479. */
  63480. addExcludedMesh(mesh: Mesh): void;
  63481. /**
  63482. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63483. * @param mesh The mesh to highlight
  63484. */
  63485. removeExcludedMesh(mesh: Mesh): void;
  63486. /**
  63487. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63488. * @param mesh mesh to test
  63489. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63490. */
  63491. hasMesh(mesh: AbstractMesh): boolean;
  63492. /**
  63493. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63494. * @param mesh The mesh to highlight
  63495. * @param color The color of the highlight
  63496. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63497. */
  63498. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63499. /**
  63500. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63501. * @param mesh The mesh to highlight
  63502. */
  63503. removeMesh(mesh: Mesh): void;
  63504. /**
  63505. * Remove all the meshes currently referenced in the highlight layer
  63506. */
  63507. removeAllMeshes(): void;
  63508. /**
  63509. * Force the stencil to the normal expected value for none glowing parts
  63510. */
  63511. private _defaultStencilReference;
  63512. /**
  63513. * Free any resources and references associated to a mesh.
  63514. * Internal use
  63515. * @param mesh The mesh to free.
  63516. * @hidden
  63517. */
  63518. _disposeMesh(mesh: Mesh): void;
  63519. /**
  63520. * Dispose the highlight layer and free resources.
  63521. */
  63522. dispose(): void;
  63523. /**
  63524. * Gets the class name of the effect layer
  63525. * @returns the string with the class name of the effect layer
  63526. */
  63527. getClassName(): string;
  63528. /**
  63529. * Serializes this Highlight layer
  63530. * @returns a serialized Highlight layer object
  63531. */
  63532. serialize(): any;
  63533. /**
  63534. * Creates a Highlight layer from parsed Highlight layer data
  63535. * @param parsedHightlightLayer defines the Highlight layer data
  63536. * @param scene defines the current scene
  63537. * @param rootUrl defines the root URL containing the Highlight layer information
  63538. * @returns a parsed Highlight layer
  63539. */
  63540. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63541. }
  63542. }
  63543. declare module BABYLON {
  63544. interface AbstractScene {
  63545. /**
  63546. * The list of layers (background and foreground) of the scene
  63547. */
  63548. layers: Array<Layer>;
  63549. }
  63550. /**
  63551. * Defines the layer scene component responsible to manage any layers
  63552. * in a given scene.
  63553. */
  63554. export class LayerSceneComponent implements ISceneComponent {
  63555. /**
  63556. * The component name helpfull to identify the component in the list of scene components.
  63557. */
  63558. readonly name: string;
  63559. /**
  63560. * The scene the component belongs to.
  63561. */
  63562. scene: Scene;
  63563. private _engine;
  63564. /**
  63565. * Creates a new instance of the component for the given scene
  63566. * @param scene Defines the scene to register the component in
  63567. */
  63568. constructor(scene: Scene);
  63569. /**
  63570. * Registers the component in a given scene
  63571. */
  63572. register(): void;
  63573. /**
  63574. * Rebuilds the elements related to this component in case of
  63575. * context lost for instance.
  63576. */
  63577. rebuild(): void;
  63578. /**
  63579. * Disposes the component and the associated ressources.
  63580. */
  63581. dispose(): void;
  63582. private _draw;
  63583. private _drawCameraPredicate;
  63584. private _drawCameraBackground;
  63585. private _drawCameraForeground;
  63586. private _drawRenderTargetPredicate;
  63587. private _drawRenderTargetBackground;
  63588. private _drawRenderTargetForeground;
  63589. /**
  63590. * Adds all the elements from the container to the scene
  63591. * @param container the container holding the elements
  63592. */
  63593. addFromContainer(container: AbstractScene): void;
  63594. /**
  63595. * Removes all the elements in the container from the scene
  63596. * @param container contains the elements to remove
  63597. * @param dispose if the removed element should be disposed (default: false)
  63598. */
  63599. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63600. }
  63601. }
  63602. declare module BABYLON {
  63603. /** @hidden */
  63604. export var layerPixelShader: {
  63605. name: string;
  63606. shader: string;
  63607. };
  63608. }
  63609. declare module BABYLON {
  63610. /** @hidden */
  63611. export var layerVertexShader: {
  63612. name: string;
  63613. shader: string;
  63614. };
  63615. }
  63616. declare module BABYLON {
  63617. /**
  63618. * This represents a full screen 2d layer.
  63619. * This can be useful to display a picture in the background of your scene for instance.
  63620. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63621. */
  63622. export class Layer {
  63623. /**
  63624. * Define the name of the layer.
  63625. */
  63626. name: string;
  63627. /**
  63628. * Define the texture the layer should display.
  63629. */
  63630. texture: Nullable<Texture>;
  63631. /**
  63632. * Is the layer in background or foreground.
  63633. */
  63634. isBackground: boolean;
  63635. /**
  63636. * Define the color of the layer (instead of texture).
  63637. */
  63638. color: Color4;
  63639. /**
  63640. * Define the scale of the layer in order to zoom in out of the texture.
  63641. */
  63642. scale: Vector2;
  63643. /**
  63644. * Define an offset for the layer in order to shift the texture.
  63645. */
  63646. offset: Vector2;
  63647. /**
  63648. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63649. */
  63650. alphaBlendingMode: number;
  63651. /**
  63652. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63653. * Alpha test will not mix with the background color in case of transparency.
  63654. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63655. */
  63656. alphaTest: boolean;
  63657. /**
  63658. * Define a mask to restrict the layer to only some of the scene cameras.
  63659. */
  63660. layerMask: number;
  63661. /**
  63662. * Define the list of render target the layer is visible into.
  63663. */
  63664. renderTargetTextures: RenderTargetTexture[];
  63665. /**
  63666. * Define if the layer is only used in renderTarget or if it also
  63667. * renders in the main frame buffer of the canvas.
  63668. */
  63669. renderOnlyInRenderTargetTextures: boolean;
  63670. private _scene;
  63671. private _vertexBuffers;
  63672. private _indexBuffer;
  63673. private _effect;
  63674. private _previousDefines;
  63675. /**
  63676. * An event triggered when the layer is disposed.
  63677. */
  63678. onDisposeObservable: Observable<Layer>;
  63679. private _onDisposeObserver;
  63680. /**
  63681. * Back compatibility with callback before the onDisposeObservable existed.
  63682. * The set callback will be triggered when the layer has been disposed.
  63683. */
  63684. set onDispose(callback: () => void);
  63685. /**
  63686. * An event triggered before rendering the scene
  63687. */
  63688. onBeforeRenderObservable: Observable<Layer>;
  63689. private _onBeforeRenderObserver;
  63690. /**
  63691. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63692. * The set callback will be triggered just before rendering the layer.
  63693. */
  63694. set onBeforeRender(callback: () => void);
  63695. /**
  63696. * An event triggered after rendering the scene
  63697. */
  63698. onAfterRenderObservable: Observable<Layer>;
  63699. private _onAfterRenderObserver;
  63700. /**
  63701. * Back compatibility with callback before the onAfterRenderObservable existed.
  63702. * The set callback will be triggered just after rendering the layer.
  63703. */
  63704. set onAfterRender(callback: () => void);
  63705. /**
  63706. * Instantiates a new layer.
  63707. * This represents a full screen 2d layer.
  63708. * This can be useful to display a picture in the background of your scene for instance.
  63709. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63710. * @param name Define the name of the layer in the scene
  63711. * @param imgUrl Define the url of the texture to display in the layer
  63712. * @param scene Define the scene the layer belongs to
  63713. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63714. * @param color Defines a color for the layer
  63715. */
  63716. constructor(
  63717. /**
  63718. * Define the name of the layer.
  63719. */
  63720. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63721. private _createIndexBuffer;
  63722. /** @hidden */
  63723. _rebuild(): void;
  63724. /**
  63725. * Renders the layer in the scene.
  63726. */
  63727. render(): void;
  63728. /**
  63729. * Disposes and releases the associated ressources.
  63730. */
  63731. dispose(): void;
  63732. }
  63733. }
  63734. declare module BABYLON {
  63735. /** @hidden */
  63736. export var lensFlarePixelShader: {
  63737. name: string;
  63738. shader: string;
  63739. };
  63740. }
  63741. declare module BABYLON {
  63742. /** @hidden */
  63743. export var lensFlareVertexShader: {
  63744. name: string;
  63745. shader: string;
  63746. };
  63747. }
  63748. declare module BABYLON {
  63749. /**
  63750. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63751. * It is usually composed of several `lensFlare`.
  63752. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63753. */
  63754. export class LensFlareSystem {
  63755. /**
  63756. * Define the name of the lens flare system
  63757. */
  63758. name: string;
  63759. /**
  63760. * List of lens flares used in this system.
  63761. */
  63762. lensFlares: LensFlare[];
  63763. /**
  63764. * Define a limit from the border the lens flare can be visible.
  63765. */
  63766. borderLimit: number;
  63767. /**
  63768. * Define a viewport border we do not want to see the lens flare in.
  63769. */
  63770. viewportBorder: number;
  63771. /**
  63772. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63773. */
  63774. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63775. /**
  63776. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63777. */
  63778. layerMask: number;
  63779. /**
  63780. * Define the id of the lens flare system in the scene.
  63781. * (equal to name by default)
  63782. */
  63783. id: string;
  63784. private _scene;
  63785. private _emitter;
  63786. private _vertexBuffers;
  63787. private _indexBuffer;
  63788. private _effect;
  63789. private _positionX;
  63790. private _positionY;
  63791. private _isEnabled;
  63792. /** @hidden */
  63793. static _SceneComponentInitialization: (scene: Scene) => void;
  63794. /**
  63795. * Instantiates a lens flare system.
  63796. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63797. * It is usually composed of several `lensFlare`.
  63798. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63799. * @param name Define the name of the lens flare system in the scene
  63800. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63801. * @param scene Define the scene the lens flare system belongs to
  63802. */
  63803. constructor(
  63804. /**
  63805. * Define the name of the lens flare system
  63806. */
  63807. name: string, emitter: any, scene: Scene);
  63808. /**
  63809. * Define if the lens flare system is enabled.
  63810. */
  63811. get isEnabled(): boolean;
  63812. set isEnabled(value: boolean);
  63813. /**
  63814. * Get the scene the effects belongs to.
  63815. * @returns the scene holding the lens flare system
  63816. */
  63817. getScene(): Scene;
  63818. /**
  63819. * Get the emitter of the lens flare system.
  63820. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63821. * @returns the emitter of the lens flare system
  63822. */
  63823. getEmitter(): any;
  63824. /**
  63825. * Set the emitter of the lens flare system.
  63826. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63827. * @param newEmitter Define the new emitter of the system
  63828. */
  63829. setEmitter(newEmitter: any): void;
  63830. /**
  63831. * Get the lens flare system emitter position.
  63832. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63833. * @returns the position
  63834. */
  63835. getEmitterPosition(): Vector3;
  63836. /**
  63837. * @hidden
  63838. */
  63839. computeEffectivePosition(globalViewport: Viewport): boolean;
  63840. /** @hidden */
  63841. _isVisible(): boolean;
  63842. /**
  63843. * @hidden
  63844. */
  63845. render(): boolean;
  63846. /**
  63847. * Dispose and release the lens flare with its associated resources.
  63848. */
  63849. dispose(): void;
  63850. /**
  63851. * Parse a lens flare system from a JSON repressentation
  63852. * @param parsedLensFlareSystem Define the JSON to parse
  63853. * @param scene Define the scene the parsed system should be instantiated in
  63854. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63855. * @returns the parsed system
  63856. */
  63857. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63858. /**
  63859. * Serialize the current Lens Flare System into a JSON representation.
  63860. * @returns the serialized JSON
  63861. */
  63862. serialize(): any;
  63863. }
  63864. }
  63865. declare module BABYLON {
  63866. /**
  63867. * This represents one of the lens effect in a `lensFlareSystem`.
  63868. * It controls one of the indiviual texture used in the effect.
  63869. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63870. */
  63871. export class LensFlare {
  63872. /**
  63873. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63874. */
  63875. size: number;
  63876. /**
  63877. * 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.
  63878. */
  63879. position: number;
  63880. /**
  63881. * Define the lens color.
  63882. */
  63883. color: Color3;
  63884. /**
  63885. * Define the lens texture.
  63886. */
  63887. texture: Nullable<Texture>;
  63888. /**
  63889. * Define the alpha mode to render this particular lens.
  63890. */
  63891. alphaMode: number;
  63892. private _system;
  63893. /**
  63894. * Creates a new Lens Flare.
  63895. * This represents one of the lens effect in a `lensFlareSystem`.
  63896. * It controls one of the indiviual texture used in the effect.
  63897. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63898. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63899. * @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.
  63900. * @param color Define the lens color
  63901. * @param imgUrl Define the lens texture url
  63902. * @param system Define the `lensFlareSystem` this flare is part of
  63903. * @returns The newly created Lens Flare
  63904. */
  63905. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63906. /**
  63907. * Instantiates a new Lens Flare.
  63908. * This represents one of the lens effect in a `lensFlareSystem`.
  63909. * It controls one of the indiviual texture used in the effect.
  63910. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63911. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63912. * @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.
  63913. * @param color Define the lens color
  63914. * @param imgUrl Define the lens texture url
  63915. * @param system Define the `lensFlareSystem` this flare is part of
  63916. */
  63917. constructor(
  63918. /**
  63919. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63920. */
  63921. size: number,
  63922. /**
  63923. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  63924. */
  63925. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63926. /**
  63927. * Dispose and release the lens flare with its associated resources.
  63928. */
  63929. dispose(): void;
  63930. }
  63931. }
  63932. declare module BABYLON {
  63933. interface AbstractScene {
  63934. /**
  63935. * The list of lens flare system added to the scene
  63936. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63937. */
  63938. lensFlareSystems: Array<LensFlareSystem>;
  63939. /**
  63940. * Removes the given lens flare system from this scene.
  63941. * @param toRemove The lens flare system to remove
  63942. * @returns The index of the removed lens flare system
  63943. */
  63944. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63945. /**
  63946. * Adds the given lens flare system to this scene
  63947. * @param newLensFlareSystem The lens flare system to add
  63948. */
  63949. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63950. /**
  63951. * Gets a lens flare system using its name
  63952. * @param name defines the name to look for
  63953. * @returns the lens flare system or null if not found
  63954. */
  63955. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63956. /**
  63957. * Gets a lens flare system using its id
  63958. * @param id defines the id to look for
  63959. * @returns the lens flare system or null if not found
  63960. */
  63961. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63962. }
  63963. /**
  63964. * Defines the lens flare scene component responsible to manage any lens flares
  63965. * in a given scene.
  63966. */
  63967. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63968. /**
  63969. * The component name helpfull to identify the component in the list of scene components.
  63970. */
  63971. readonly name: string;
  63972. /**
  63973. * The scene the component belongs to.
  63974. */
  63975. scene: Scene;
  63976. /**
  63977. * Creates a new instance of the component for the given scene
  63978. * @param scene Defines the scene to register the component in
  63979. */
  63980. constructor(scene: Scene);
  63981. /**
  63982. * Registers the component in a given scene
  63983. */
  63984. register(): void;
  63985. /**
  63986. * Rebuilds the elements related to this component in case of
  63987. * context lost for instance.
  63988. */
  63989. rebuild(): void;
  63990. /**
  63991. * Adds all the elements from the container to the scene
  63992. * @param container the container holding the elements
  63993. */
  63994. addFromContainer(container: AbstractScene): void;
  63995. /**
  63996. * Removes all the elements in the container from the scene
  63997. * @param container contains the elements to remove
  63998. * @param dispose if the removed element should be disposed (default: false)
  63999. */
  64000. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64001. /**
  64002. * Serializes the component data to the specified json object
  64003. * @param serializationObject The object to serialize to
  64004. */
  64005. serialize(serializationObject: any): void;
  64006. /**
  64007. * Disposes the component and the associated ressources.
  64008. */
  64009. dispose(): void;
  64010. private _draw;
  64011. }
  64012. }
  64013. declare module BABYLON {
  64014. /** @hidden */
  64015. export var depthPixelShader: {
  64016. name: string;
  64017. shader: string;
  64018. };
  64019. }
  64020. declare module BABYLON {
  64021. /** @hidden */
  64022. export var depthVertexShader: {
  64023. name: string;
  64024. shader: string;
  64025. };
  64026. }
  64027. declare module BABYLON {
  64028. /**
  64029. * This represents a depth renderer in Babylon.
  64030. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64031. */
  64032. export class DepthRenderer {
  64033. private _scene;
  64034. private _depthMap;
  64035. private _effect;
  64036. private readonly _storeNonLinearDepth;
  64037. private readonly _clearColor;
  64038. /** Get if the depth renderer is using packed depth or not */
  64039. readonly isPacked: boolean;
  64040. private _cachedDefines;
  64041. private _camera;
  64042. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64043. enabled: boolean;
  64044. /**
  64045. * Specifiess that the depth renderer will only be used within
  64046. * the camera it is created for.
  64047. * This can help forcing its rendering during the camera processing.
  64048. */
  64049. useOnlyInActiveCamera: boolean;
  64050. /** @hidden */
  64051. static _SceneComponentInitialization: (scene: Scene) => void;
  64052. /**
  64053. * Instantiates a depth renderer
  64054. * @param scene The scene the renderer belongs to
  64055. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64056. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64057. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64058. */
  64059. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64060. /**
  64061. * Creates the depth rendering effect and checks if the effect is ready.
  64062. * @param subMesh The submesh to be used to render the depth map of
  64063. * @param useInstances If multiple world instances should be used
  64064. * @returns if the depth renderer is ready to render the depth map
  64065. */
  64066. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64067. /**
  64068. * Gets the texture which the depth map will be written to.
  64069. * @returns The depth map texture
  64070. */
  64071. getDepthMap(): RenderTargetTexture;
  64072. /**
  64073. * Disposes of the depth renderer.
  64074. */
  64075. dispose(): void;
  64076. }
  64077. }
  64078. declare module BABYLON {
  64079. /** @hidden */
  64080. export var minmaxReduxPixelShader: {
  64081. name: string;
  64082. shader: string;
  64083. };
  64084. }
  64085. declare module BABYLON {
  64086. /**
  64087. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64088. * and maximum values from all values of the texture.
  64089. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64090. * The source values are read from the red channel of the texture.
  64091. */
  64092. export class MinMaxReducer {
  64093. /**
  64094. * Observable triggered when the computation has been performed
  64095. */
  64096. onAfterReductionPerformed: Observable<{
  64097. min: number;
  64098. max: number;
  64099. }>;
  64100. protected _camera: Camera;
  64101. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64102. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64103. protected _postProcessManager: PostProcessManager;
  64104. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64105. protected _forceFullscreenViewport: boolean;
  64106. /**
  64107. * Creates a min/max reducer
  64108. * @param camera The camera to use for the post processes
  64109. */
  64110. constructor(camera: Camera);
  64111. /**
  64112. * Gets the texture used to read the values from.
  64113. */
  64114. get sourceTexture(): Nullable<RenderTargetTexture>;
  64115. /**
  64116. * Sets the source texture to read the values from.
  64117. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64118. * because in such textures '1' value must not be taken into account to compute the maximum
  64119. * as this value is used to clear the texture.
  64120. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64121. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64122. * @param depthRedux Indicates if the texture is a depth texture or not
  64123. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64124. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64125. */
  64126. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64127. /**
  64128. * Defines the refresh rate of the computation.
  64129. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64130. */
  64131. get refreshRate(): number;
  64132. set refreshRate(value: number);
  64133. protected _activated: boolean;
  64134. /**
  64135. * Gets the activation status of the reducer
  64136. */
  64137. get activated(): boolean;
  64138. /**
  64139. * Activates the reduction computation.
  64140. * When activated, the observers registered in onAfterReductionPerformed are
  64141. * called after the compuation is performed
  64142. */
  64143. activate(): void;
  64144. /**
  64145. * Deactivates the reduction computation.
  64146. */
  64147. deactivate(): void;
  64148. /**
  64149. * Disposes the min/max reducer
  64150. * @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.
  64151. */
  64152. dispose(disposeAll?: boolean): void;
  64153. }
  64154. }
  64155. declare module BABYLON {
  64156. /**
  64157. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64158. */
  64159. export class DepthReducer extends MinMaxReducer {
  64160. private _depthRenderer;
  64161. private _depthRendererId;
  64162. /**
  64163. * Gets the depth renderer used for the computation.
  64164. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64165. */
  64166. get depthRenderer(): Nullable<DepthRenderer>;
  64167. /**
  64168. * Creates a depth reducer
  64169. * @param camera The camera used to render the depth texture
  64170. */
  64171. constructor(camera: Camera);
  64172. /**
  64173. * Sets the depth renderer to use to generate the depth map
  64174. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64175. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64176. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64177. */
  64178. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64179. /** @hidden */
  64180. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64181. /**
  64182. * Activates the reduction computation.
  64183. * When activated, the observers registered in onAfterReductionPerformed are
  64184. * called after the compuation is performed
  64185. */
  64186. activate(): void;
  64187. /**
  64188. * Deactivates the reduction computation.
  64189. */
  64190. deactivate(): void;
  64191. /**
  64192. * Disposes the depth reducer
  64193. * @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.
  64194. */
  64195. dispose(disposeAll?: boolean): void;
  64196. }
  64197. }
  64198. declare module BABYLON {
  64199. /**
  64200. * A CSM implementation allowing casting shadows on large scenes.
  64201. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64202. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64203. */
  64204. export class CascadedShadowGenerator extends ShadowGenerator {
  64205. private static readonly frustumCornersNDCSpace;
  64206. /**
  64207. * Name of the CSM class
  64208. */
  64209. static CLASSNAME: string;
  64210. /**
  64211. * Defines the default number of cascades used by the CSM.
  64212. */
  64213. static readonly DEFAULT_CASCADES_COUNT: number;
  64214. /**
  64215. * Defines the minimum number of cascades used by the CSM.
  64216. */
  64217. static readonly MIN_CASCADES_COUNT: number;
  64218. /**
  64219. * Defines the maximum number of cascades used by the CSM.
  64220. */
  64221. static readonly MAX_CASCADES_COUNT: number;
  64222. protected _validateFilter(filter: number): number;
  64223. /**
  64224. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64225. */
  64226. penumbraDarkness: number;
  64227. private _numCascades;
  64228. /**
  64229. * Gets or set the number of cascades used by the CSM.
  64230. */
  64231. get numCascades(): number;
  64232. set numCascades(value: number);
  64233. /**
  64234. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64235. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64236. */
  64237. stabilizeCascades: boolean;
  64238. private _freezeShadowCastersBoundingInfo;
  64239. private _freezeShadowCastersBoundingInfoObservable;
  64240. /**
  64241. * Enables or disables the shadow casters bounding info computation.
  64242. * If your shadow casters don't move, you can disable this feature.
  64243. * If it is enabled, the bounding box computation is done every frame.
  64244. */
  64245. get freezeShadowCastersBoundingInfo(): boolean;
  64246. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64247. private _scbiMin;
  64248. private _scbiMax;
  64249. protected _computeShadowCastersBoundingInfo(): void;
  64250. protected _shadowCastersBoundingInfo: BoundingInfo;
  64251. /**
  64252. * Gets or sets the shadow casters bounding info.
  64253. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64254. * so that the system won't overwrite the bounds you provide
  64255. */
  64256. get shadowCastersBoundingInfo(): BoundingInfo;
  64257. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64258. protected _breaksAreDirty: boolean;
  64259. protected _minDistance: number;
  64260. protected _maxDistance: number;
  64261. /**
  64262. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64263. *
  64264. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64265. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64266. * @param min minimal distance for the breaks (default to 0.)
  64267. * @param max maximal distance for the breaks (default to 1.)
  64268. */
  64269. setMinMaxDistance(min: number, max: number): void;
  64270. /** Gets the minimal distance used in the cascade break computation */
  64271. get minDistance(): number;
  64272. /** Gets the maximal distance used in the cascade break computation */
  64273. get maxDistance(): number;
  64274. /**
  64275. * Gets the class name of that object
  64276. * @returns "CascadedShadowGenerator"
  64277. */
  64278. getClassName(): string;
  64279. private _cascadeMinExtents;
  64280. private _cascadeMaxExtents;
  64281. /**
  64282. * Gets a cascade minimum extents
  64283. * @param cascadeIndex index of the cascade
  64284. * @returns the minimum cascade extents
  64285. */
  64286. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64287. /**
  64288. * Gets a cascade maximum extents
  64289. * @param cascadeIndex index of the cascade
  64290. * @returns the maximum cascade extents
  64291. */
  64292. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64293. private _cascades;
  64294. private _currentLayer;
  64295. private _viewSpaceFrustumsZ;
  64296. private _viewMatrices;
  64297. private _projectionMatrices;
  64298. private _transformMatrices;
  64299. private _transformMatricesAsArray;
  64300. private _frustumLengths;
  64301. private _lightSizeUVCorrection;
  64302. private _depthCorrection;
  64303. private _frustumCornersWorldSpace;
  64304. private _frustumCenter;
  64305. private _shadowCameraPos;
  64306. private _shadowMaxZ;
  64307. /**
  64308. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64309. * It defaults to camera.maxZ
  64310. */
  64311. get shadowMaxZ(): number;
  64312. /**
  64313. * Sets the shadow max z distance.
  64314. */
  64315. set shadowMaxZ(value: number);
  64316. protected _debug: boolean;
  64317. /**
  64318. * Gets or sets the debug flag.
  64319. * When enabled, the cascades are materialized by different colors on the screen.
  64320. */
  64321. get debug(): boolean;
  64322. set debug(dbg: boolean);
  64323. private _depthClamp;
  64324. /**
  64325. * Gets or sets the depth clamping value.
  64326. *
  64327. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64328. * to account for the shadow casters far away.
  64329. *
  64330. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64331. */
  64332. get depthClamp(): boolean;
  64333. set depthClamp(value: boolean);
  64334. private _cascadeBlendPercentage;
  64335. /**
  64336. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64337. * It defaults to 0.1 (10% blending).
  64338. */
  64339. get cascadeBlendPercentage(): number;
  64340. set cascadeBlendPercentage(value: number);
  64341. private _lambda;
  64342. /**
  64343. * Gets or set the lambda parameter.
  64344. * This parameter is used to split the camera frustum and create the cascades.
  64345. * 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.
  64346. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64347. */
  64348. get lambda(): number;
  64349. set lambda(value: number);
  64350. /**
  64351. * Gets the view matrix corresponding to a given cascade
  64352. * @param cascadeNum cascade to retrieve the view matrix from
  64353. * @returns the cascade view matrix
  64354. */
  64355. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64356. /**
  64357. * Gets the projection matrix corresponding to a given cascade
  64358. * @param cascadeNum cascade to retrieve the projection matrix from
  64359. * @returns the cascade projection matrix
  64360. */
  64361. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64362. /**
  64363. * Gets the transformation matrix corresponding to a given cascade
  64364. * @param cascadeNum cascade to retrieve the transformation matrix from
  64365. * @returns the cascade transformation matrix
  64366. */
  64367. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64368. private _depthRenderer;
  64369. /**
  64370. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64371. *
  64372. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64373. *
  64374. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64375. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64376. * @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
  64377. */
  64378. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64379. private _depthReducer;
  64380. private _autoCalcDepthBounds;
  64381. /**
  64382. * Gets or sets the autoCalcDepthBounds property.
  64383. *
  64384. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64385. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64386. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64387. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64388. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64389. */
  64390. get autoCalcDepthBounds(): boolean;
  64391. set autoCalcDepthBounds(value: boolean);
  64392. /**
  64393. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64394. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64395. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64396. * for setting the refresh rate on the renderer yourself!
  64397. */
  64398. get autoCalcDepthBoundsRefreshRate(): number;
  64399. set autoCalcDepthBoundsRefreshRate(value: number);
  64400. /**
  64401. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64402. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64403. * you change the camera near/far planes!
  64404. */
  64405. splitFrustum(): void;
  64406. private _splitFrustum;
  64407. private _computeMatrices;
  64408. private _computeFrustumInWorldSpace;
  64409. private _computeCascadeFrustum;
  64410. /**
  64411. * Support test.
  64412. */
  64413. static get IsSupported(): boolean;
  64414. /** @hidden */
  64415. static _SceneComponentInitialization: (scene: Scene) => void;
  64416. /**
  64417. * Creates a Cascaded Shadow Generator object.
  64418. * A ShadowGenerator is the required tool to use the shadows.
  64419. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64420. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64421. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64422. * @param light The directional light object generating the shadows.
  64423. * @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.
  64424. */
  64425. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64426. protected _initializeGenerator(): void;
  64427. protected _createTargetRenderTexture(): void;
  64428. protected _initializeShadowMap(): void;
  64429. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64430. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64431. /**
  64432. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64433. * @param defines Defines of the material we want to update
  64434. * @param lightIndex Index of the light in the enabled light list of the material
  64435. */
  64436. prepareDefines(defines: any, lightIndex: number): void;
  64437. /**
  64438. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64439. * defined in the generator but impacting the effect).
  64440. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64441. * @param effect The effect we are binfing the information for
  64442. */
  64443. bindShadowLight(lightIndex: string, effect: Effect): void;
  64444. /**
  64445. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64446. * (eq to view projection * shadow projection matrices)
  64447. * @returns The transform matrix used to create the shadow map
  64448. */
  64449. getTransformMatrix(): Matrix;
  64450. /**
  64451. * Disposes the ShadowGenerator.
  64452. * Returns nothing.
  64453. */
  64454. dispose(): void;
  64455. /**
  64456. * Serializes the shadow generator setup to a json object.
  64457. * @returns The serialized JSON object
  64458. */
  64459. serialize(): any;
  64460. /**
  64461. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64462. * @param parsedShadowGenerator The JSON object to parse
  64463. * @param scene The scene to create the shadow map for
  64464. * @returns The parsed shadow generator
  64465. */
  64466. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64467. }
  64468. }
  64469. declare module BABYLON {
  64470. /**
  64471. * Defines the shadow generator component responsible to manage any shadow generators
  64472. * in a given scene.
  64473. */
  64474. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64475. /**
  64476. * The component name helpfull to identify the component in the list of scene components.
  64477. */
  64478. readonly name: string;
  64479. /**
  64480. * The scene the component belongs to.
  64481. */
  64482. scene: Scene;
  64483. /**
  64484. * Creates a new instance of the component for the given scene
  64485. * @param scene Defines the scene to register the component in
  64486. */
  64487. constructor(scene: Scene);
  64488. /**
  64489. * Registers the component in a given scene
  64490. */
  64491. register(): void;
  64492. /**
  64493. * Rebuilds the elements related to this component in case of
  64494. * context lost for instance.
  64495. */
  64496. rebuild(): void;
  64497. /**
  64498. * Serializes the component data to the specified json object
  64499. * @param serializationObject The object to serialize to
  64500. */
  64501. serialize(serializationObject: any): void;
  64502. /**
  64503. * Adds all the elements from the container to the scene
  64504. * @param container the container holding the elements
  64505. */
  64506. addFromContainer(container: AbstractScene): void;
  64507. /**
  64508. * Removes all the elements in the container from the scene
  64509. * @param container contains the elements to remove
  64510. * @param dispose if the removed element should be disposed (default: false)
  64511. */
  64512. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64513. /**
  64514. * Rebuilds the elements related to this component in case of
  64515. * context lost for instance.
  64516. */
  64517. dispose(): void;
  64518. private _gatherRenderTargets;
  64519. }
  64520. }
  64521. declare module BABYLON {
  64522. /**
  64523. * A point light is a light defined by an unique point in world space.
  64524. * The light is emitted in every direction from this point.
  64525. * A good example of a point light is a standard light bulb.
  64526. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64527. */
  64528. export class PointLight extends ShadowLight {
  64529. private _shadowAngle;
  64530. /**
  64531. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64532. * This specifies what angle the shadow will use to be created.
  64533. *
  64534. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64535. */
  64536. get shadowAngle(): number;
  64537. /**
  64538. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64539. * This specifies what angle the shadow will use to be created.
  64540. *
  64541. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64542. */
  64543. set shadowAngle(value: number);
  64544. /**
  64545. * Gets the direction if it has been set.
  64546. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64547. */
  64548. get direction(): Vector3;
  64549. /**
  64550. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64551. */
  64552. set direction(value: Vector3);
  64553. /**
  64554. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64555. * A PointLight emits the light in every direction.
  64556. * It can cast shadows.
  64557. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64558. * ```javascript
  64559. * var pointLight = new PointLight("pl", camera.position, scene);
  64560. * ```
  64561. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64562. * @param name The light friendly name
  64563. * @param position The position of the point light in the scene
  64564. * @param scene The scene the lights belongs to
  64565. */
  64566. constructor(name: string, position: Vector3, scene: Scene);
  64567. /**
  64568. * Returns the string "PointLight"
  64569. * @returns the class name
  64570. */
  64571. getClassName(): string;
  64572. /**
  64573. * Returns the integer 0.
  64574. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64575. */
  64576. getTypeID(): number;
  64577. /**
  64578. * Specifies wether or not the shadowmap should be a cube texture.
  64579. * @returns true if the shadowmap needs to be a cube texture.
  64580. */
  64581. needCube(): boolean;
  64582. /**
  64583. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64584. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64585. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64586. */
  64587. getShadowDirection(faceIndex?: number): Vector3;
  64588. /**
  64589. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64590. * - fov = PI / 2
  64591. * - aspect ratio : 1.0
  64592. * - z-near and far equal to the active camera minZ and maxZ.
  64593. * Returns the PointLight.
  64594. */
  64595. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64596. protected _buildUniformLayout(): void;
  64597. /**
  64598. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64599. * @param effect The effect to update
  64600. * @param lightIndex The index of the light in the effect to update
  64601. * @returns The point light
  64602. */
  64603. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64604. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64605. /**
  64606. * Prepares the list of defines specific to the light type.
  64607. * @param defines the list of defines
  64608. * @param lightIndex defines the index of the light for the effect
  64609. */
  64610. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64611. }
  64612. }
  64613. declare module BABYLON {
  64614. /**
  64615. * Header information of HDR texture files.
  64616. */
  64617. export interface HDRInfo {
  64618. /**
  64619. * The height of the texture in pixels.
  64620. */
  64621. height: number;
  64622. /**
  64623. * The width of the texture in pixels.
  64624. */
  64625. width: number;
  64626. /**
  64627. * The index of the beginning of the data in the binary file.
  64628. */
  64629. dataPosition: number;
  64630. }
  64631. /**
  64632. * This groups tools to convert HDR texture to native colors array.
  64633. */
  64634. export class HDRTools {
  64635. private static Ldexp;
  64636. private static Rgbe2float;
  64637. private static readStringLine;
  64638. /**
  64639. * Reads header information from an RGBE texture stored in a native array.
  64640. * More information on this format are available here:
  64641. * https://en.wikipedia.org/wiki/RGBE_image_format
  64642. *
  64643. * @param uint8array The binary file stored in native array.
  64644. * @return The header information.
  64645. */
  64646. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64647. /**
  64648. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64649. * This RGBE texture needs to store the information as a panorama.
  64650. *
  64651. * More information on this format are available here:
  64652. * https://en.wikipedia.org/wiki/RGBE_image_format
  64653. *
  64654. * @param buffer The binary file stored in an array buffer.
  64655. * @param size The expected size of the extracted cubemap.
  64656. * @return The Cube Map information.
  64657. */
  64658. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64659. /**
  64660. * Returns the pixels data extracted from an RGBE texture.
  64661. * This pixels will be stored left to right up to down in the R G B order in one array.
  64662. *
  64663. * More information on this format are available here:
  64664. * https://en.wikipedia.org/wiki/RGBE_image_format
  64665. *
  64666. * @param uint8array The binary file stored in an array buffer.
  64667. * @param hdrInfo The header information of the file.
  64668. * @return The pixels data in RGB right to left up to down order.
  64669. */
  64670. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64671. private static RGBE_ReadPixels_RLE;
  64672. private static RGBE_ReadPixels_NOT_RLE;
  64673. }
  64674. }
  64675. declare module BABYLON {
  64676. /**
  64677. * Effect Render Options
  64678. */
  64679. export interface IEffectRendererOptions {
  64680. /**
  64681. * Defines the vertices positions.
  64682. */
  64683. positions?: number[];
  64684. /**
  64685. * Defines the indices.
  64686. */
  64687. indices?: number[];
  64688. }
  64689. /**
  64690. * Helper class to render one or more effects.
  64691. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64692. */
  64693. export class EffectRenderer {
  64694. private engine;
  64695. private static _DefaultOptions;
  64696. private _vertexBuffers;
  64697. private _indexBuffer;
  64698. private _fullscreenViewport;
  64699. /**
  64700. * Creates an effect renderer
  64701. * @param engine the engine to use for rendering
  64702. * @param options defines the options of the effect renderer
  64703. */
  64704. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64705. /**
  64706. * Sets the current viewport in normalized coordinates 0-1
  64707. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64708. */
  64709. setViewport(viewport?: Viewport): void;
  64710. /**
  64711. * Binds the embedded attributes buffer to the effect.
  64712. * @param effect Defines the effect to bind the attributes for
  64713. */
  64714. bindBuffers(effect: Effect): void;
  64715. /**
  64716. * Sets the current effect wrapper to use during draw.
  64717. * The effect needs to be ready before calling this api.
  64718. * This also sets the default full screen position attribute.
  64719. * @param effectWrapper Defines the effect to draw with
  64720. */
  64721. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64722. /**
  64723. * Restores engine states
  64724. */
  64725. restoreStates(): void;
  64726. /**
  64727. * Draws a full screen quad.
  64728. */
  64729. draw(): void;
  64730. private isRenderTargetTexture;
  64731. /**
  64732. * renders one or more effects to a specified texture
  64733. * @param effectWrapper the effect to renderer
  64734. * @param outputTexture texture to draw to, if null it will render to the screen.
  64735. */
  64736. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64737. /**
  64738. * Disposes of the effect renderer
  64739. */
  64740. dispose(): void;
  64741. }
  64742. /**
  64743. * Options to create an EffectWrapper
  64744. */
  64745. interface EffectWrapperCreationOptions {
  64746. /**
  64747. * Engine to use to create the effect
  64748. */
  64749. engine: ThinEngine;
  64750. /**
  64751. * Fragment shader for the effect
  64752. */
  64753. fragmentShader: string;
  64754. /**
  64755. * Use the shader store instead of direct source code
  64756. */
  64757. useShaderStore?: boolean;
  64758. /**
  64759. * Vertex shader for the effect
  64760. */
  64761. vertexShader?: string;
  64762. /**
  64763. * Attributes to use in the shader
  64764. */
  64765. attributeNames?: Array<string>;
  64766. /**
  64767. * Uniforms to use in the shader
  64768. */
  64769. uniformNames?: Array<string>;
  64770. /**
  64771. * Texture sampler names to use in the shader
  64772. */
  64773. samplerNames?: Array<string>;
  64774. /**
  64775. * Defines to use in the shader
  64776. */
  64777. defines?: Array<string>;
  64778. /**
  64779. * Callback when effect is compiled
  64780. */
  64781. onCompiled?: Nullable<(effect: Effect) => void>;
  64782. /**
  64783. * The friendly name of the effect displayed in Spector.
  64784. */
  64785. name?: string;
  64786. }
  64787. /**
  64788. * Wraps an effect to be used for rendering
  64789. */
  64790. export class EffectWrapper {
  64791. /**
  64792. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64793. */
  64794. onApplyObservable: Observable<{}>;
  64795. /**
  64796. * The underlying effect
  64797. */
  64798. effect: Effect;
  64799. /**
  64800. * Creates an effect to be renderer
  64801. * @param creationOptions options to create the effect
  64802. */
  64803. constructor(creationOptions: EffectWrapperCreationOptions);
  64804. /**
  64805. * Disposes of the effect wrapper
  64806. */
  64807. dispose(): void;
  64808. }
  64809. }
  64810. declare module BABYLON {
  64811. /** @hidden */
  64812. export var hdrFilteringVertexShader: {
  64813. name: string;
  64814. shader: string;
  64815. };
  64816. }
  64817. declare module BABYLON {
  64818. /** @hidden */
  64819. export var hdrFilteringPixelShader: {
  64820. name: string;
  64821. shader: string;
  64822. };
  64823. }
  64824. declare module BABYLON {
  64825. /**
  64826. * Options for texture filtering
  64827. */
  64828. interface IHDRFilteringOptions {
  64829. /**
  64830. * Scales pixel intensity for the input HDR map.
  64831. */
  64832. hdrScale?: number;
  64833. /**
  64834. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64835. */
  64836. quality?: number;
  64837. }
  64838. /**
  64839. * Filters HDR maps to get correct renderings of PBR reflections
  64840. */
  64841. export class HDRFiltering {
  64842. private _engine;
  64843. private _effectRenderer;
  64844. private _effectWrapper;
  64845. private _lodGenerationOffset;
  64846. private _lodGenerationScale;
  64847. /**
  64848. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64849. * you care about baking speed.
  64850. */
  64851. quality: number;
  64852. /**
  64853. * Scales pixel intensity for the input HDR map.
  64854. */
  64855. hdrScale: number;
  64856. /**
  64857. * Instantiates HDR filter for reflection maps
  64858. *
  64859. * @param engine Thin engine
  64860. * @param options Options
  64861. */
  64862. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64863. private _createRenderTarget;
  64864. private _prefilterInternal;
  64865. private _createEffect;
  64866. /**
  64867. * Get a value indicating if the filter is ready to be used
  64868. * @param texture Texture to filter
  64869. * @returns true if the filter is ready
  64870. */
  64871. isReady(texture: BaseTexture): boolean;
  64872. /**
  64873. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64874. * Prefiltering will be invoked at the end of next rendering pass.
  64875. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64876. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64877. * @param texture Texture to filter
  64878. * @param onFinished Callback when filtering is done
  64879. * @return Promise called when prefiltering is done
  64880. */
  64881. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  64882. }
  64883. }
  64884. declare module BABYLON {
  64885. /**
  64886. * This represents a texture coming from an HDR input.
  64887. *
  64888. * The only supported format is currently panorama picture stored in RGBE format.
  64889. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64890. */
  64891. export class HDRCubeTexture extends BaseTexture {
  64892. private static _facesMapping;
  64893. private _generateHarmonics;
  64894. private _noMipmap;
  64895. private _prefilterOnLoad;
  64896. private _textureMatrix;
  64897. private _size;
  64898. private _onLoad;
  64899. private _onError;
  64900. /**
  64901. * The texture URL.
  64902. */
  64903. url: string;
  64904. protected _isBlocking: boolean;
  64905. /**
  64906. * Sets wether or not the texture is blocking during loading.
  64907. */
  64908. set isBlocking(value: boolean);
  64909. /**
  64910. * Gets wether or not the texture is blocking during loading.
  64911. */
  64912. get isBlocking(): boolean;
  64913. protected _rotationY: number;
  64914. /**
  64915. * Sets texture matrix rotation angle around Y axis in radians.
  64916. */
  64917. set rotationY(value: number);
  64918. /**
  64919. * Gets texture matrix rotation angle around Y axis radians.
  64920. */
  64921. get rotationY(): number;
  64922. /**
  64923. * Gets or sets the center of the bounding box associated with the cube texture
  64924. * It must define where the camera used to render the texture was set
  64925. */
  64926. boundingBoxPosition: Vector3;
  64927. private _boundingBoxSize;
  64928. /**
  64929. * Gets or sets the size of the bounding box associated with the cube texture
  64930. * When defined, the cubemap will switch to local mode
  64931. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64932. * @example https://www.babylonjs-playground.com/#RNASML
  64933. */
  64934. set boundingBoxSize(value: Vector3);
  64935. get boundingBoxSize(): Vector3;
  64936. /**
  64937. * Instantiates an HDRTexture from the following parameters.
  64938. *
  64939. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64940. * @param sceneOrEngine The scene or engine the texture will be used in
  64941. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64942. * @param noMipmap Forces to not generate the mipmap if true
  64943. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64944. * @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)
  64945. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64946. */
  64947. 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>);
  64948. /**
  64949. * Get the current class name of the texture useful for serialization or dynamic coding.
  64950. * @returns "HDRCubeTexture"
  64951. */
  64952. getClassName(): string;
  64953. /**
  64954. * Occurs when the file is raw .hdr file.
  64955. */
  64956. private loadTexture;
  64957. clone(): HDRCubeTexture;
  64958. delayLoad(): void;
  64959. /**
  64960. * Get the texture reflection matrix used to rotate/transform the reflection.
  64961. * @returns the reflection matrix
  64962. */
  64963. getReflectionTextureMatrix(): Matrix;
  64964. /**
  64965. * Set the texture reflection matrix used to rotate/transform the reflection.
  64966. * @param value Define the reflection matrix to set
  64967. */
  64968. setReflectionTextureMatrix(value: Matrix): void;
  64969. /**
  64970. * Parses a JSON representation of an HDR Texture in order to create the texture
  64971. * @param parsedTexture Define the JSON representation
  64972. * @param scene Define the scene the texture should be created in
  64973. * @param rootUrl Define the root url in case we need to load relative dependencies
  64974. * @returns the newly created texture after parsing
  64975. */
  64976. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64977. serialize(): any;
  64978. }
  64979. }
  64980. declare module BABYLON {
  64981. /**
  64982. * Class used to control physics engine
  64983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64984. */
  64985. export class PhysicsEngine implements IPhysicsEngine {
  64986. private _physicsPlugin;
  64987. /**
  64988. * Global value used to control the smallest number supported by the simulation
  64989. */
  64990. static Epsilon: number;
  64991. private _impostors;
  64992. private _joints;
  64993. private _subTimeStep;
  64994. /**
  64995. * Gets the gravity vector used by the simulation
  64996. */
  64997. gravity: Vector3;
  64998. /**
  64999. * Factory used to create the default physics plugin.
  65000. * @returns The default physics plugin
  65001. */
  65002. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65003. /**
  65004. * Creates a new Physics Engine
  65005. * @param gravity defines the gravity vector used by the simulation
  65006. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65007. */
  65008. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65009. /**
  65010. * Sets the gravity vector used by the simulation
  65011. * @param gravity defines the gravity vector to use
  65012. */
  65013. setGravity(gravity: Vector3): void;
  65014. /**
  65015. * Set the time step of the physics engine.
  65016. * Default is 1/60.
  65017. * To slow it down, enter 1/600 for example.
  65018. * To speed it up, 1/30
  65019. * @param newTimeStep defines the new timestep to apply to this world.
  65020. */
  65021. setTimeStep(newTimeStep?: number): void;
  65022. /**
  65023. * Get the time step of the physics engine.
  65024. * @returns the current time step
  65025. */
  65026. getTimeStep(): number;
  65027. /**
  65028. * Set the sub time step of the physics engine.
  65029. * Default is 0 meaning there is no sub steps
  65030. * To increase physics resolution precision, set a small value (like 1 ms)
  65031. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65032. */
  65033. setSubTimeStep(subTimeStep?: number): void;
  65034. /**
  65035. * Get the sub time step of the physics engine.
  65036. * @returns the current sub time step
  65037. */
  65038. getSubTimeStep(): number;
  65039. /**
  65040. * Release all resources
  65041. */
  65042. dispose(): void;
  65043. /**
  65044. * Gets the name of the current physics plugin
  65045. * @returns the name of the plugin
  65046. */
  65047. getPhysicsPluginName(): string;
  65048. /**
  65049. * Adding a new impostor for the impostor tracking.
  65050. * This will be done by the impostor itself.
  65051. * @param impostor the impostor to add
  65052. */
  65053. addImpostor(impostor: PhysicsImpostor): void;
  65054. /**
  65055. * Remove an impostor from the engine.
  65056. * This impostor and its mesh will not longer be updated by the physics engine.
  65057. * @param impostor the impostor to remove
  65058. */
  65059. removeImpostor(impostor: PhysicsImpostor): void;
  65060. /**
  65061. * Add a joint to the physics engine
  65062. * @param mainImpostor defines the main impostor to which the joint is added.
  65063. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65064. * @param joint defines the joint that will connect both impostors.
  65065. */
  65066. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65067. /**
  65068. * Removes a joint from the simulation
  65069. * @param mainImpostor defines the impostor used with the joint
  65070. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65071. * @param joint defines the joint to remove
  65072. */
  65073. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65074. /**
  65075. * Called by the scene. No need to call it.
  65076. * @param delta defines the timespam between frames
  65077. */
  65078. _step(delta: number): void;
  65079. /**
  65080. * Gets the current plugin used to run the simulation
  65081. * @returns current plugin
  65082. */
  65083. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65084. /**
  65085. * Gets the list of physic impostors
  65086. * @returns an array of PhysicsImpostor
  65087. */
  65088. getImpostors(): Array<PhysicsImpostor>;
  65089. /**
  65090. * Gets the impostor for a physics enabled object
  65091. * @param object defines the object impersonated by the impostor
  65092. * @returns the PhysicsImpostor or null if not found
  65093. */
  65094. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65095. /**
  65096. * Gets the impostor for a physics body object
  65097. * @param body defines physics body used by the impostor
  65098. * @returns the PhysicsImpostor or null if not found
  65099. */
  65100. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65101. /**
  65102. * Does a raycast in the physics world
  65103. * @param from when should the ray start?
  65104. * @param to when should the ray end?
  65105. * @returns PhysicsRaycastResult
  65106. */
  65107. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65108. }
  65109. }
  65110. declare module BABYLON {
  65111. /** @hidden */
  65112. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65113. private _useDeltaForWorldStep;
  65114. world: any;
  65115. name: string;
  65116. private _physicsMaterials;
  65117. private _fixedTimeStep;
  65118. private _cannonRaycastResult;
  65119. private _raycastResult;
  65120. private _physicsBodysToRemoveAfterStep;
  65121. private _firstFrame;
  65122. BJSCANNON: any;
  65123. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65124. setGravity(gravity: Vector3): void;
  65125. setTimeStep(timeStep: number): void;
  65126. getTimeStep(): number;
  65127. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65128. private _removeMarkedPhysicsBodiesFromWorld;
  65129. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65130. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65131. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65132. private _processChildMeshes;
  65133. removePhysicsBody(impostor: PhysicsImpostor): void;
  65134. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65135. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65136. private _addMaterial;
  65137. private _checkWithEpsilon;
  65138. private _createShape;
  65139. private _createHeightmap;
  65140. private _minus90X;
  65141. private _plus90X;
  65142. private _tmpPosition;
  65143. private _tmpDeltaPosition;
  65144. private _tmpUnityRotation;
  65145. private _updatePhysicsBodyTransformation;
  65146. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65147. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65148. isSupported(): boolean;
  65149. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65150. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65151. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65152. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65153. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65154. getBodyMass(impostor: PhysicsImpostor): number;
  65155. getBodyFriction(impostor: PhysicsImpostor): number;
  65156. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65157. getBodyRestitution(impostor: PhysicsImpostor): number;
  65158. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65159. sleepBody(impostor: PhysicsImpostor): void;
  65160. wakeUpBody(impostor: PhysicsImpostor): void;
  65161. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65162. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65163. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65164. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65165. getRadius(impostor: PhysicsImpostor): number;
  65166. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65167. dispose(): void;
  65168. private _extendNamespace;
  65169. /**
  65170. * Does a raycast in the physics world
  65171. * @param from when should the ray start?
  65172. * @param to when should the ray end?
  65173. * @returns PhysicsRaycastResult
  65174. */
  65175. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65176. }
  65177. }
  65178. declare module BABYLON {
  65179. /** @hidden */
  65180. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65181. private _useDeltaForWorldStep;
  65182. world: any;
  65183. name: string;
  65184. BJSOIMO: any;
  65185. private _raycastResult;
  65186. private _fixedTimeStep;
  65187. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65188. setGravity(gravity: Vector3): void;
  65189. setTimeStep(timeStep: number): void;
  65190. getTimeStep(): number;
  65191. private _tmpImpostorsArray;
  65192. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65193. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65194. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65195. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65196. private _tmpPositionVector;
  65197. removePhysicsBody(impostor: PhysicsImpostor): void;
  65198. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65199. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65200. isSupported(): boolean;
  65201. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65202. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65203. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65204. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65205. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65206. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65207. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65208. getBodyMass(impostor: PhysicsImpostor): number;
  65209. getBodyFriction(impostor: PhysicsImpostor): number;
  65210. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65211. getBodyRestitution(impostor: PhysicsImpostor): number;
  65212. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65213. sleepBody(impostor: PhysicsImpostor): void;
  65214. wakeUpBody(impostor: PhysicsImpostor): void;
  65215. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65216. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65217. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65218. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65219. getRadius(impostor: PhysicsImpostor): number;
  65220. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65221. dispose(): void;
  65222. /**
  65223. * Does a raycast in the physics world
  65224. * @param from when should the ray start?
  65225. * @param to when should the ray end?
  65226. * @returns PhysicsRaycastResult
  65227. */
  65228. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65229. }
  65230. }
  65231. declare module BABYLON {
  65232. /**
  65233. * AmmoJS Physics plugin
  65234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65235. * @see https://github.com/kripken/ammo.js/
  65236. */
  65237. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65238. private _useDeltaForWorldStep;
  65239. /**
  65240. * Reference to the Ammo library
  65241. */
  65242. bjsAMMO: any;
  65243. /**
  65244. * Created ammoJS world which physics bodies are added to
  65245. */
  65246. world: any;
  65247. /**
  65248. * Name of the plugin
  65249. */
  65250. name: string;
  65251. private _timeStep;
  65252. private _fixedTimeStep;
  65253. private _maxSteps;
  65254. private _tmpQuaternion;
  65255. private _tmpAmmoTransform;
  65256. private _tmpAmmoQuaternion;
  65257. private _tmpAmmoConcreteContactResultCallback;
  65258. private _collisionConfiguration;
  65259. private _dispatcher;
  65260. private _overlappingPairCache;
  65261. private _solver;
  65262. private _softBodySolver;
  65263. private _tmpAmmoVectorA;
  65264. private _tmpAmmoVectorB;
  65265. private _tmpAmmoVectorC;
  65266. private _tmpAmmoVectorD;
  65267. private _tmpContactCallbackResult;
  65268. private _tmpAmmoVectorRCA;
  65269. private _tmpAmmoVectorRCB;
  65270. private _raycastResult;
  65271. private _tmpContactPoint;
  65272. private static readonly DISABLE_COLLISION_FLAG;
  65273. private static readonly KINEMATIC_FLAG;
  65274. private static readonly DISABLE_DEACTIVATION_FLAG;
  65275. /**
  65276. * Initializes the ammoJS plugin
  65277. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65278. * @param ammoInjection can be used to inject your own ammo reference
  65279. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65280. */
  65281. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65282. /**
  65283. * Sets the gravity of the physics world (m/(s^2))
  65284. * @param gravity Gravity to set
  65285. */
  65286. setGravity(gravity: Vector3): void;
  65287. /**
  65288. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65289. * @param timeStep timestep to use in seconds
  65290. */
  65291. setTimeStep(timeStep: number): void;
  65292. /**
  65293. * 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)
  65294. * @param fixedTimeStep fixedTimeStep to use in seconds
  65295. */
  65296. setFixedTimeStep(fixedTimeStep: number): void;
  65297. /**
  65298. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65299. * @param maxSteps the maximum number of steps by the physics engine per frame
  65300. */
  65301. setMaxSteps(maxSteps: number): void;
  65302. /**
  65303. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65304. * @returns the current timestep in seconds
  65305. */
  65306. getTimeStep(): number;
  65307. /**
  65308. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65309. */
  65310. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65311. private _isImpostorInContact;
  65312. private _isImpostorPairInContact;
  65313. private _stepSimulation;
  65314. /**
  65315. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65316. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65317. * After the step the babylon meshes are set to the position of the physics imposters
  65318. * @param delta amount of time to step forward
  65319. * @param impostors array of imposters to update before/after the step
  65320. */
  65321. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65322. /**
  65323. * Update babylon mesh to match physics world object
  65324. * @param impostor imposter to match
  65325. */
  65326. private _afterSoftStep;
  65327. /**
  65328. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65329. * @param impostor imposter to match
  65330. */
  65331. private _ropeStep;
  65332. /**
  65333. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65334. * @param impostor imposter to match
  65335. */
  65336. private _softbodyOrClothStep;
  65337. private _tmpMatrix;
  65338. /**
  65339. * Applies an impulse on the imposter
  65340. * @param impostor imposter to apply impulse to
  65341. * @param force amount of force to be applied to the imposter
  65342. * @param contactPoint the location to apply the impulse on the imposter
  65343. */
  65344. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65345. /**
  65346. * Applies a force on the imposter
  65347. * @param impostor imposter to apply force
  65348. * @param force amount of force to be applied to the imposter
  65349. * @param contactPoint the location to apply the force on the imposter
  65350. */
  65351. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65352. /**
  65353. * Creates a physics body using the plugin
  65354. * @param impostor the imposter to create the physics body on
  65355. */
  65356. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65357. /**
  65358. * Removes the physics body from the imposter and disposes of the body's memory
  65359. * @param impostor imposter to remove the physics body from
  65360. */
  65361. removePhysicsBody(impostor: PhysicsImpostor): void;
  65362. /**
  65363. * Generates a joint
  65364. * @param impostorJoint the imposter joint to create the joint with
  65365. */
  65366. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65367. /**
  65368. * Removes a joint
  65369. * @param impostorJoint the imposter joint to remove the joint from
  65370. */
  65371. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65372. private _addMeshVerts;
  65373. /**
  65374. * Initialise the soft body vertices to match its object's (mesh) vertices
  65375. * Softbody vertices (nodes) are in world space and to match this
  65376. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65377. * @param impostor to create the softbody for
  65378. */
  65379. private _softVertexData;
  65380. /**
  65381. * Create an impostor's soft body
  65382. * @param impostor to create the softbody for
  65383. */
  65384. private _createSoftbody;
  65385. /**
  65386. * Create cloth for an impostor
  65387. * @param impostor to create the softbody for
  65388. */
  65389. private _createCloth;
  65390. /**
  65391. * Create rope for an impostor
  65392. * @param impostor to create the softbody for
  65393. */
  65394. private _createRope;
  65395. /**
  65396. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65397. * @param impostor to create the custom physics shape for
  65398. */
  65399. private _createCustom;
  65400. private _addHullVerts;
  65401. private _createShape;
  65402. /**
  65403. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65404. * @param impostor imposter containing the physics body and babylon object
  65405. */
  65406. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65407. /**
  65408. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65409. * @param impostor imposter containing the physics body and babylon object
  65410. * @param newPosition new position
  65411. * @param newRotation new rotation
  65412. */
  65413. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65414. /**
  65415. * If this plugin is supported
  65416. * @returns true if its supported
  65417. */
  65418. isSupported(): boolean;
  65419. /**
  65420. * Sets the linear velocity of the physics body
  65421. * @param impostor imposter to set the velocity on
  65422. * @param velocity velocity to set
  65423. */
  65424. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65425. /**
  65426. * Sets the angular velocity of the physics body
  65427. * @param impostor imposter to set the velocity on
  65428. * @param velocity velocity to set
  65429. */
  65430. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65431. /**
  65432. * gets the linear velocity
  65433. * @param impostor imposter to get linear velocity from
  65434. * @returns linear velocity
  65435. */
  65436. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65437. /**
  65438. * gets the angular velocity
  65439. * @param impostor imposter to get angular velocity from
  65440. * @returns angular velocity
  65441. */
  65442. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65443. /**
  65444. * Sets the mass of physics body
  65445. * @param impostor imposter to set the mass on
  65446. * @param mass mass to set
  65447. */
  65448. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65449. /**
  65450. * Gets the mass of the physics body
  65451. * @param impostor imposter to get the mass from
  65452. * @returns mass
  65453. */
  65454. getBodyMass(impostor: PhysicsImpostor): number;
  65455. /**
  65456. * Gets friction of the impostor
  65457. * @param impostor impostor to get friction from
  65458. * @returns friction value
  65459. */
  65460. getBodyFriction(impostor: PhysicsImpostor): number;
  65461. /**
  65462. * Sets friction of the impostor
  65463. * @param impostor impostor to set friction on
  65464. * @param friction friction value
  65465. */
  65466. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65467. /**
  65468. * Gets restitution of the impostor
  65469. * @param impostor impostor to get restitution from
  65470. * @returns restitution value
  65471. */
  65472. getBodyRestitution(impostor: PhysicsImpostor): number;
  65473. /**
  65474. * Sets resitution of the impostor
  65475. * @param impostor impostor to set resitution on
  65476. * @param restitution resitution value
  65477. */
  65478. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65479. /**
  65480. * Gets pressure inside the impostor
  65481. * @param impostor impostor to get pressure from
  65482. * @returns pressure value
  65483. */
  65484. getBodyPressure(impostor: PhysicsImpostor): number;
  65485. /**
  65486. * Sets pressure inside a soft body impostor
  65487. * Cloth and rope must remain 0 pressure
  65488. * @param impostor impostor to set pressure on
  65489. * @param pressure pressure value
  65490. */
  65491. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65492. /**
  65493. * Gets stiffness of the impostor
  65494. * @param impostor impostor to get stiffness from
  65495. * @returns pressure value
  65496. */
  65497. getBodyStiffness(impostor: PhysicsImpostor): number;
  65498. /**
  65499. * Sets stiffness of the impostor
  65500. * @param impostor impostor to set stiffness on
  65501. * @param stiffness stiffness value from 0 to 1
  65502. */
  65503. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65504. /**
  65505. * Gets velocityIterations of the impostor
  65506. * @param impostor impostor to get velocity iterations from
  65507. * @returns velocityIterations value
  65508. */
  65509. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65510. /**
  65511. * Sets velocityIterations of the impostor
  65512. * @param impostor impostor to set velocity iterations on
  65513. * @param velocityIterations velocityIterations value
  65514. */
  65515. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65516. /**
  65517. * Gets positionIterations of the impostor
  65518. * @param impostor impostor to get position iterations from
  65519. * @returns positionIterations value
  65520. */
  65521. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65522. /**
  65523. * Sets positionIterations of the impostor
  65524. * @param impostor impostor to set position on
  65525. * @param positionIterations positionIterations value
  65526. */
  65527. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65528. /**
  65529. * Append an anchor to a cloth object
  65530. * @param impostor is the cloth impostor to add anchor to
  65531. * @param otherImpostor is the rigid impostor to anchor to
  65532. * @param width ratio across width from 0 to 1
  65533. * @param height ratio up height from 0 to 1
  65534. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65535. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65536. */
  65537. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65538. /**
  65539. * Append an hook to a rope object
  65540. * @param impostor is the rope impostor to add hook to
  65541. * @param otherImpostor is the rigid impostor to hook to
  65542. * @param length ratio along the rope from 0 to 1
  65543. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65544. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65545. */
  65546. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65547. /**
  65548. * Sleeps the physics body and stops it from being active
  65549. * @param impostor impostor to sleep
  65550. */
  65551. sleepBody(impostor: PhysicsImpostor): void;
  65552. /**
  65553. * Activates the physics body
  65554. * @param impostor impostor to activate
  65555. */
  65556. wakeUpBody(impostor: PhysicsImpostor): void;
  65557. /**
  65558. * Updates the distance parameters of the joint
  65559. * @param joint joint to update
  65560. * @param maxDistance maximum distance of the joint
  65561. * @param minDistance minimum distance of the joint
  65562. */
  65563. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65564. /**
  65565. * Sets a motor on the joint
  65566. * @param joint joint to set motor on
  65567. * @param speed speed of the motor
  65568. * @param maxForce maximum force of the motor
  65569. * @param motorIndex index of the motor
  65570. */
  65571. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65572. /**
  65573. * Sets the motors limit
  65574. * @param joint joint to set limit on
  65575. * @param upperLimit upper limit
  65576. * @param lowerLimit lower limit
  65577. */
  65578. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65579. /**
  65580. * Syncs the position and rotation of a mesh with the impostor
  65581. * @param mesh mesh to sync
  65582. * @param impostor impostor to update the mesh with
  65583. */
  65584. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65585. /**
  65586. * Gets the radius of the impostor
  65587. * @param impostor impostor to get radius from
  65588. * @returns the radius
  65589. */
  65590. getRadius(impostor: PhysicsImpostor): number;
  65591. /**
  65592. * Gets the box size of the impostor
  65593. * @param impostor impostor to get box size from
  65594. * @param result the resulting box size
  65595. */
  65596. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65597. /**
  65598. * Disposes of the impostor
  65599. */
  65600. dispose(): void;
  65601. /**
  65602. * Does a raycast in the physics world
  65603. * @param from when should the ray start?
  65604. * @param to when should the ray end?
  65605. * @returns PhysicsRaycastResult
  65606. */
  65607. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65608. }
  65609. }
  65610. declare module BABYLON {
  65611. interface AbstractScene {
  65612. /**
  65613. * The list of reflection probes added to the scene
  65614. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65615. */
  65616. reflectionProbes: Array<ReflectionProbe>;
  65617. /**
  65618. * Removes the given reflection probe from this scene.
  65619. * @param toRemove The reflection probe to remove
  65620. * @returns The index of the removed reflection probe
  65621. */
  65622. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65623. /**
  65624. * Adds the given reflection probe to this scene.
  65625. * @param newReflectionProbe The reflection probe to add
  65626. */
  65627. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65628. }
  65629. /**
  65630. * Class used to generate realtime reflection / refraction cube textures
  65631. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65632. */
  65633. export class ReflectionProbe {
  65634. /** defines the name of the probe */
  65635. name: string;
  65636. private _scene;
  65637. private _renderTargetTexture;
  65638. private _projectionMatrix;
  65639. private _viewMatrix;
  65640. private _target;
  65641. private _add;
  65642. private _attachedMesh;
  65643. private _invertYAxis;
  65644. /** Gets or sets probe position (center of the cube map) */
  65645. position: Vector3;
  65646. /**
  65647. * Creates a new reflection probe
  65648. * @param name defines the name of the probe
  65649. * @param size defines the texture resolution (for each face)
  65650. * @param scene defines the hosting scene
  65651. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65652. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65653. */
  65654. constructor(
  65655. /** defines the name of the probe */
  65656. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65657. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65658. get samples(): number;
  65659. set samples(value: number);
  65660. /** Gets or sets the refresh rate to use (on every frame by default) */
  65661. get refreshRate(): number;
  65662. set refreshRate(value: number);
  65663. /**
  65664. * Gets the hosting scene
  65665. * @returns a Scene
  65666. */
  65667. getScene(): Scene;
  65668. /** Gets the internal CubeTexture used to render to */
  65669. get cubeTexture(): RenderTargetTexture;
  65670. /** Gets the list of meshes to render */
  65671. get renderList(): Nullable<AbstractMesh[]>;
  65672. /**
  65673. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65674. * @param mesh defines the mesh to attach to
  65675. */
  65676. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65677. /**
  65678. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65679. * @param renderingGroupId The rendering group id corresponding to its index
  65680. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65681. */
  65682. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65683. /**
  65684. * Clean all associated resources
  65685. */
  65686. dispose(): void;
  65687. /**
  65688. * Converts the reflection probe information to a readable string for debug purpose.
  65689. * @param fullDetails Supports for multiple levels of logging within scene loading
  65690. * @returns the human readable reflection probe info
  65691. */
  65692. toString(fullDetails?: boolean): string;
  65693. /**
  65694. * Get the class name of the relfection probe.
  65695. * @returns "ReflectionProbe"
  65696. */
  65697. getClassName(): string;
  65698. /**
  65699. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65700. * @returns The JSON representation of the texture
  65701. */
  65702. serialize(): any;
  65703. /**
  65704. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65705. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65706. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65707. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65708. * @returns The parsed reflection probe if successful
  65709. */
  65710. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65711. }
  65712. }
  65713. declare module BABYLON {
  65714. /** @hidden */
  65715. export var _BabylonLoaderRegistered: boolean;
  65716. /**
  65717. * Helps setting up some configuration for the babylon file loader.
  65718. */
  65719. export class BabylonFileLoaderConfiguration {
  65720. /**
  65721. * The loader does not allow injecting custom physix engine into the plugins.
  65722. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65723. * So you could set this variable to your engine import to make it work.
  65724. */
  65725. static LoaderInjectedPhysicsEngine: any;
  65726. }
  65727. }
  65728. declare module BABYLON {
  65729. /**
  65730. * A material to use for fast depth-only rendering.
  65731. */
  65732. export class OcclusionMaterial extends ShaderMaterial {
  65733. constructor(name: string, scene: Scene);
  65734. }
  65735. }
  65736. declare module BABYLON {
  65737. /**
  65738. * The Physically based simple base material of BJS.
  65739. *
  65740. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65741. * It is used as the base class for both the specGloss and metalRough conventions.
  65742. */
  65743. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65744. /**
  65745. * Number of Simultaneous lights allowed on the material.
  65746. */
  65747. maxSimultaneousLights: number;
  65748. /**
  65749. * If sets to true, disables all the lights affecting the material.
  65750. */
  65751. disableLighting: boolean;
  65752. /**
  65753. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65754. */
  65755. environmentTexture: BaseTexture;
  65756. /**
  65757. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65758. */
  65759. invertNormalMapX: boolean;
  65760. /**
  65761. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65762. */
  65763. invertNormalMapY: boolean;
  65764. /**
  65765. * Normal map used in the model.
  65766. */
  65767. normalTexture: BaseTexture;
  65768. /**
  65769. * Emissivie color used to self-illuminate the model.
  65770. */
  65771. emissiveColor: Color3;
  65772. /**
  65773. * Emissivie texture used to self-illuminate the model.
  65774. */
  65775. emissiveTexture: BaseTexture;
  65776. /**
  65777. * Occlusion Channel Strenght.
  65778. */
  65779. occlusionStrength: number;
  65780. /**
  65781. * Occlusion Texture of the material (adding extra occlusion effects).
  65782. */
  65783. occlusionTexture: BaseTexture;
  65784. /**
  65785. * Defines the alpha limits in alpha test mode.
  65786. */
  65787. alphaCutOff: number;
  65788. /**
  65789. * Gets the current double sided mode.
  65790. */
  65791. get doubleSided(): boolean;
  65792. /**
  65793. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65794. */
  65795. set doubleSided(value: boolean);
  65796. /**
  65797. * Stores the pre-calculated light information of a mesh in a texture.
  65798. */
  65799. lightmapTexture: BaseTexture;
  65800. /**
  65801. * If true, the light map contains occlusion information instead of lighting info.
  65802. */
  65803. useLightmapAsShadowmap: boolean;
  65804. /**
  65805. * Instantiates a new PBRMaterial instance.
  65806. *
  65807. * @param name The material name
  65808. * @param scene The scene the material will be use in.
  65809. */
  65810. constructor(name: string, scene: Scene);
  65811. getClassName(): string;
  65812. }
  65813. }
  65814. declare module BABYLON {
  65815. /**
  65816. * The PBR material of BJS following the metal roughness convention.
  65817. *
  65818. * This fits to the PBR convention in the GLTF definition:
  65819. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65820. */
  65821. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65822. /**
  65823. * The base color has two different interpretations depending on the value of metalness.
  65824. * When the material is a metal, the base color is the specific measured reflectance value
  65825. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65826. * of the material.
  65827. */
  65828. baseColor: Color3;
  65829. /**
  65830. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65831. * well as opacity information in the alpha channel.
  65832. */
  65833. baseTexture: BaseTexture;
  65834. /**
  65835. * Specifies the metallic scalar value of the material.
  65836. * Can also be used to scale the metalness values of the metallic texture.
  65837. */
  65838. metallic: number;
  65839. /**
  65840. * Specifies the roughness scalar value of the material.
  65841. * Can also be used to scale the roughness values of the metallic texture.
  65842. */
  65843. roughness: number;
  65844. /**
  65845. * Texture containing both the metallic value in the B channel and the
  65846. * roughness value in the G channel to keep better precision.
  65847. */
  65848. metallicRoughnessTexture: BaseTexture;
  65849. /**
  65850. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65851. *
  65852. * @param name The material name
  65853. * @param scene The scene the material will be use in.
  65854. */
  65855. constructor(name: string, scene: Scene);
  65856. /**
  65857. * Return the currrent class name of the material.
  65858. */
  65859. getClassName(): string;
  65860. /**
  65861. * Makes a duplicate of the current material.
  65862. * @param name - name to use for the new material.
  65863. */
  65864. clone(name: string): PBRMetallicRoughnessMaterial;
  65865. /**
  65866. * Serialize the material to a parsable JSON object.
  65867. */
  65868. serialize(): any;
  65869. /**
  65870. * Parses a JSON object correponding to the serialize function.
  65871. */
  65872. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65873. }
  65874. }
  65875. declare module BABYLON {
  65876. /**
  65877. * The PBR material of BJS following the specular glossiness convention.
  65878. *
  65879. * This fits to the PBR convention in the GLTF definition:
  65880. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65881. */
  65882. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65883. /**
  65884. * Specifies the diffuse color of the material.
  65885. */
  65886. diffuseColor: Color3;
  65887. /**
  65888. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65889. * channel.
  65890. */
  65891. diffuseTexture: BaseTexture;
  65892. /**
  65893. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65894. */
  65895. specularColor: Color3;
  65896. /**
  65897. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65898. */
  65899. glossiness: number;
  65900. /**
  65901. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65902. */
  65903. specularGlossinessTexture: BaseTexture;
  65904. /**
  65905. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  65906. */
  65907. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  65908. /**
  65909. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65910. *
  65911. * @param name The material name
  65912. * @param scene The scene the material will be use in.
  65913. */
  65914. constructor(name: string, scene: Scene);
  65915. /**
  65916. * Return the currrent class name of the material.
  65917. */
  65918. getClassName(): string;
  65919. /**
  65920. * Makes a duplicate of the current material.
  65921. * @param name - name to use for the new material.
  65922. */
  65923. clone(name: string): PBRSpecularGlossinessMaterial;
  65924. /**
  65925. * Serialize the material to a parsable JSON object.
  65926. */
  65927. serialize(): any;
  65928. /**
  65929. * Parses a JSON object correponding to the serialize function.
  65930. */
  65931. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65932. }
  65933. }
  65934. declare module BABYLON {
  65935. /**
  65936. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65937. * It can help converting any input color in a desired output one. This can then be used to create effects
  65938. * from sepia, black and white to sixties or futuristic rendering...
  65939. *
  65940. * The only supported format is currently 3dl.
  65941. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65942. */
  65943. export class ColorGradingTexture extends BaseTexture {
  65944. /**
  65945. * The texture URL.
  65946. */
  65947. url: string;
  65948. /**
  65949. * Empty line regex stored for GC.
  65950. */
  65951. private static _noneEmptyLineRegex;
  65952. private _textureMatrix;
  65953. private _onLoad;
  65954. /**
  65955. * Instantiates a ColorGradingTexture from the following parameters.
  65956. *
  65957. * @param url The location of the color gradind data (currently only supporting 3dl)
  65958. * @param sceneOrEngine The scene or engine the texture will be used in
  65959. * @param onLoad defines a callback triggered when the texture has been loaded
  65960. */
  65961. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65962. /**
  65963. * Fires the onload event from the constructor if requested.
  65964. */
  65965. private _triggerOnLoad;
  65966. /**
  65967. * Returns the texture matrix used in most of the material.
  65968. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65969. */
  65970. getTextureMatrix(): Matrix;
  65971. /**
  65972. * Occurs when the file being loaded is a .3dl LUT file.
  65973. */
  65974. private load3dlTexture;
  65975. /**
  65976. * Starts the loading process of the texture.
  65977. */
  65978. private loadTexture;
  65979. /**
  65980. * Clones the color gradind texture.
  65981. */
  65982. clone(): ColorGradingTexture;
  65983. /**
  65984. * Called during delayed load for textures.
  65985. */
  65986. delayLoad(): void;
  65987. /**
  65988. * Parses a color grading texture serialized by Babylon.
  65989. * @param parsedTexture The texture information being parsedTexture
  65990. * @param scene The scene to load the texture in
  65991. * @param rootUrl The root url of the data assets to load
  65992. * @return A color gradind texture
  65993. */
  65994. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65995. /**
  65996. * Serializes the LUT texture to json format.
  65997. */
  65998. serialize(): any;
  65999. }
  66000. }
  66001. declare module BABYLON {
  66002. /**
  66003. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66004. */
  66005. export class EquiRectangularCubeTexture extends BaseTexture {
  66006. /** The six faces of the cube. */
  66007. private static _FacesMapping;
  66008. private _noMipmap;
  66009. private _onLoad;
  66010. private _onError;
  66011. /** The size of the cubemap. */
  66012. private _size;
  66013. /** The buffer of the image. */
  66014. private _buffer;
  66015. /** The width of the input image. */
  66016. private _width;
  66017. /** The height of the input image. */
  66018. private _height;
  66019. /** The URL to the image. */
  66020. url: string;
  66021. /**
  66022. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66023. * @param url The location of the image
  66024. * @param scene The scene the texture will be used in
  66025. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66026. * @param noMipmap Forces to not generate the mipmap if true
  66027. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66028. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66029. * @param onLoad — defines a callback called when texture is loaded
  66030. * @param onError — defines a callback called if there is an error
  66031. */
  66032. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66033. /**
  66034. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66035. */
  66036. private loadImage;
  66037. /**
  66038. * Convert the image buffer into a cubemap and create a CubeTexture.
  66039. */
  66040. private loadTexture;
  66041. /**
  66042. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66043. * @param buffer The ArrayBuffer that should be converted.
  66044. * @returns The buffer as Float32Array.
  66045. */
  66046. private getFloat32ArrayFromArrayBuffer;
  66047. /**
  66048. * Get the current class name of the texture useful for serialization or dynamic coding.
  66049. * @returns "EquiRectangularCubeTexture"
  66050. */
  66051. getClassName(): string;
  66052. /**
  66053. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66054. * @returns A clone of the current EquiRectangularCubeTexture.
  66055. */
  66056. clone(): EquiRectangularCubeTexture;
  66057. }
  66058. }
  66059. declare module BABYLON {
  66060. /**
  66061. * Defines the options related to the creation of an HtmlElementTexture
  66062. */
  66063. export interface IHtmlElementTextureOptions {
  66064. /**
  66065. * Defines wether mip maps should be created or not.
  66066. */
  66067. generateMipMaps?: boolean;
  66068. /**
  66069. * Defines the sampling mode of the texture.
  66070. */
  66071. samplingMode?: number;
  66072. /**
  66073. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66074. */
  66075. engine: Nullable<ThinEngine>;
  66076. /**
  66077. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66078. */
  66079. scene: Nullable<Scene>;
  66080. }
  66081. /**
  66082. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66083. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66084. * is automatically managed.
  66085. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66086. * in your application.
  66087. *
  66088. * As the update is not automatic, you need to call them manually.
  66089. */
  66090. export class HtmlElementTexture extends BaseTexture {
  66091. /**
  66092. * The texture URL.
  66093. */
  66094. element: HTMLVideoElement | HTMLCanvasElement;
  66095. private static readonly DefaultOptions;
  66096. private _textureMatrix;
  66097. private _isVideo;
  66098. private _generateMipMaps;
  66099. private _samplingMode;
  66100. /**
  66101. * Instantiates a HtmlElementTexture from the following parameters.
  66102. *
  66103. * @param name Defines the name of the texture
  66104. * @param element Defines the video or canvas the texture is filled with
  66105. * @param options Defines the other none mandatory texture creation options
  66106. */
  66107. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66108. private _createInternalTexture;
  66109. /**
  66110. * Returns the texture matrix used in most of the material.
  66111. */
  66112. getTextureMatrix(): Matrix;
  66113. /**
  66114. * Updates the content of the texture.
  66115. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66116. */
  66117. update(invertY?: Nullable<boolean>): void;
  66118. }
  66119. }
  66120. declare module BABYLON {
  66121. /**
  66122. * Based on jsTGALoader - Javascript loader for TGA file
  66123. * By Vincent Thibault
  66124. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66125. */
  66126. export class TGATools {
  66127. private static _TYPE_INDEXED;
  66128. private static _TYPE_RGB;
  66129. private static _TYPE_GREY;
  66130. private static _TYPE_RLE_INDEXED;
  66131. private static _TYPE_RLE_RGB;
  66132. private static _TYPE_RLE_GREY;
  66133. private static _ORIGIN_MASK;
  66134. private static _ORIGIN_SHIFT;
  66135. private static _ORIGIN_BL;
  66136. private static _ORIGIN_BR;
  66137. private static _ORIGIN_UL;
  66138. private static _ORIGIN_UR;
  66139. /**
  66140. * Gets the header of a TGA file
  66141. * @param data defines the TGA data
  66142. * @returns the header
  66143. */
  66144. static GetTGAHeader(data: Uint8Array): any;
  66145. /**
  66146. * Uploads TGA content to a Babylon Texture
  66147. * @hidden
  66148. */
  66149. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66150. /** @hidden */
  66151. 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;
  66152. /** @hidden */
  66153. 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;
  66154. /** @hidden */
  66155. 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;
  66156. /** @hidden */
  66157. 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;
  66158. /** @hidden */
  66159. 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;
  66160. /** @hidden */
  66161. 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;
  66162. }
  66163. }
  66164. declare module BABYLON {
  66165. /**
  66166. * Implementation of the TGA Texture Loader.
  66167. * @hidden
  66168. */
  66169. export class _TGATextureLoader implements IInternalTextureLoader {
  66170. /**
  66171. * Defines wether the loader supports cascade loading the different faces.
  66172. */
  66173. readonly supportCascades: boolean;
  66174. /**
  66175. * This returns if the loader support the current file information.
  66176. * @param extension defines the file extension of the file being loaded
  66177. * @returns true if the loader can load the specified file
  66178. */
  66179. canLoad(extension: string): boolean;
  66180. /**
  66181. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66182. * @param data contains the texture data
  66183. * @param texture defines the BabylonJS internal texture
  66184. * @param createPolynomials will be true if polynomials have been requested
  66185. * @param onLoad defines the callback to trigger once the texture is ready
  66186. * @param onError defines the callback to trigger in case of error
  66187. */
  66188. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66189. /**
  66190. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66191. * @param data contains the texture data
  66192. * @param texture defines the BabylonJS internal texture
  66193. * @param callback defines the method to call once ready to upload
  66194. */
  66195. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66196. }
  66197. }
  66198. declare module BABYLON {
  66199. /**
  66200. * Implementation of the HDR Texture Loader.
  66201. * @hidden
  66202. */
  66203. export class _HDRTextureLoader implements IInternalTextureLoader {
  66204. /**
  66205. * Defines wether the loader supports cascade loading the different faces.
  66206. */
  66207. readonly supportCascades: boolean;
  66208. /**
  66209. * This returns if the loader support the current file information.
  66210. * @param extension defines the file extension of the file being loaded
  66211. * @returns true if the loader can load the specified file
  66212. */
  66213. canLoad(extension: string): boolean;
  66214. /**
  66215. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66216. * @param data contains the texture data
  66217. * @param texture defines the BabylonJS internal texture
  66218. * @param createPolynomials will be true if polynomials have been requested
  66219. * @param onLoad defines the callback to trigger once the texture is ready
  66220. * @param onError defines the callback to trigger in case of error
  66221. */
  66222. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66223. /**
  66224. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66225. * @param data contains the texture data
  66226. * @param texture defines the BabylonJS internal texture
  66227. * @param callback defines the method to call once ready to upload
  66228. */
  66229. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66230. }
  66231. }
  66232. declare module BABYLON {
  66233. /**
  66234. * Info about the .basis files
  66235. */
  66236. class BasisFileInfo {
  66237. /**
  66238. * If the file has alpha
  66239. */
  66240. hasAlpha: boolean;
  66241. /**
  66242. * Info about each image of the basis file
  66243. */
  66244. images: Array<{
  66245. levels: Array<{
  66246. width: number;
  66247. height: number;
  66248. transcodedPixels: ArrayBufferView;
  66249. }>;
  66250. }>;
  66251. }
  66252. /**
  66253. * Result of transcoding a basis file
  66254. */
  66255. class TranscodeResult {
  66256. /**
  66257. * Info about the .basis file
  66258. */
  66259. fileInfo: BasisFileInfo;
  66260. /**
  66261. * Format to use when loading the file
  66262. */
  66263. format: number;
  66264. }
  66265. /**
  66266. * Configuration options for the Basis transcoder
  66267. */
  66268. export class BasisTranscodeConfiguration {
  66269. /**
  66270. * Supported compression formats used to determine the supported output format of the transcoder
  66271. */
  66272. supportedCompressionFormats?: {
  66273. /**
  66274. * etc1 compression format
  66275. */
  66276. etc1?: boolean;
  66277. /**
  66278. * s3tc compression format
  66279. */
  66280. s3tc?: boolean;
  66281. /**
  66282. * pvrtc compression format
  66283. */
  66284. pvrtc?: boolean;
  66285. /**
  66286. * etc2 compression format
  66287. */
  66288. etc2?: boolean;
  66289. };
  66290. /**
  66291. * If mipmap levels should be loaded for transcoded images (Default: true)
  66292. */
  66293. loadMipmapLevels?: boolean;
  66294. /**
  66295. * Index of a single image to load (Default: all images)
  66296. */
  66297. loadSingleImage?: number;
  66298. }
  66299. /**
  66300. * Used to load .Basis files
  66301. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66302. */
  66303. export class BasisTools {
  66304. private static _IgnoreSupportedFormats;
  66305. /**
  66306. * URL to use when loading the basis transcoder
  66307. */
  66308. static JSModuleURL: string;
  66309. /**
  66310. * URL to use when loading the wasm module for the transcoder
  66311. */
  66312. static WasmModuleURL: string;
  66313. /**
  66314. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66315. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66316. * @returns internal format corresponding to the Basis format
  66317. */
  66318. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66319. private static _WorkerPromise;
  66320. private static _Worker;
  66321. private static _actionId;
  66322. private static _CreateWorkerAsync;
  66323. /**
  66324. * Transcodes a loaded image file to compressed pixel data
  66325. * @param data image data to transcode
  66326. * @param config configuration options for the transcoding
  66327. * @returns a promise resulting in the transcoded image
  66328. */
  66329. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66330. /**
  66331. * Loads a texture from the transcode result
  66332. * @param texture texture load to
  66333. * @param transcodeResult the result of transcoding the basis file to load from
  66334. */
  66335. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66336. }
  66337. }
  66338. declare module BABYLON {
  66339. /**
  66340. * Loader for .basis file format
  66341. */
  66342. export class _BasisTextureLoader implements IInternalTextureLoader {
  66343. /**
  66344. * Defines whether the loader supports cascade loading the different faces.
  66345. */
  66346. readonly supportCascades: boolean;
  66347. /**
  66348. * This returns if the loader support the current file information.
  66349. * @param extension defines the file extension of the file being loaded
  66350. * @returns true if the loader can load the specified file
  66351. */
  66352. canLoad(extension: string): boolean;
  66353. /**
  66354. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66355. * @param data contains the texture data
  66356. * @param texture defines the BabylonJS internal texture
  66357. * @param createPolynomials will be true if polynomials have been requested
  66358. * @param onLoad defines the callback to trigger once the texture is ready
  66359. * @param onError defines the callback to trigger in case of error
  66360. */
  66361. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66362. /**
  66363. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66364. * @param data contains the texture data
  66365. * @param texture defines the BabylonJS internal texture
  66366. * @param callback defines the method to call once ready to upload
  66367. */
  66368. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66369. }
  66370. }
  66371. declare module BABYLON {
  66372. /**
  66373. * Defines the basic options interface of a TexturePacker Frame
  66374. */
  66375. export interface ITexturePackerFrame {
  66376. /**
  66377. * The frame ID
  66378. */
  66379. id: number;
  66380. /**
  66381. * The frames Scale
  66382. */
  66383. scale: Vector2;
  66384. /**
  66385. * The Frames offset
  66386. */
  66387. offset: Vector2;
  66388. }
  66389. /**
  66390. * This is a support class for frame Data on texture packer sets.
  66391. */
  66392. export class TexturePackerFrame implements ITexturePackerFrame {
  66393. /**
  66394. * The frame ID
  66395. */
  66396. id: number;
  66397. /**
  66398. * The frames Scale
  66399. */
  66400. scale: Vector2;
  66401. /**
  66402. * The Frames offset
  66403. */
  66404. offset: Vector2;
  66405. /**
  66406. * Initializes a texture package frame.
  66407. * @param id The numerical frame identifier
  66408. * @param scale Scalar Vector2 for UV frame
  66409. * @param offset Vector2 for the frame position in UV units.
  66410. * @returns TexturePackerFrame
  66411. */
  66412. constructor(id: number, scale: Vector2, offset: Vector2);
  66413. }
  66414. }
  66415. declare module BABYLON {
  66416. /**
  66417. * Defines the basic options interface of a TexturePacker
  66418. */
  66419. export interface ITexturePackerOptions {
  66420. /**
  66421. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66422. */
  66423. map?: string[];
  66424. /**
  66425. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66426. */
  66427. uvsIn?: string;
  66428. /**
  66429. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66430. */
  66431. uvsOut?: string;
  66432. /**
  66433. * number representing the layout style. Defaults to LAYOUT_STRIP
  66434. */
  66435. layout?: number;
  66436. /**
  66437. * number of columns if using custom column count layout(2). This defaults to 4.
  66438. */
  66439. colnum?: number;
  66440. /**
  66441. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66442. */
  66443. updateInputMeshes?: boolean;
  66444. /**
  66445. * boolean flag to dispose all the source textures. Defaults to true.
  66446. */
  66447. disposeSources?: boolean;
  66448. /**
  66449. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66450. */
  66451. fillBlanks?: boolean;
  66452. /**
  66453. * string value representing the context fill style color. Defaults to 'black'.
  66454. */
  66455. customFillColor?: string;
  66456. /**
  66457. * Width and Height Value of each Frame in the TexturePacker Sets
  66458. */
  66459. frameSize?: number;
  66460. /**
  66461. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66462. */
  66463. paddingRatio?: number;
  66464. /**
  66465. * Number that declares the fill method for the padding gutter.
  66466. */
  66467. paddingMode?: number;
  66468. /**
  66469. * If in SUBUV_COLOR padding mode what color to use.
  66470. */
  66471. paddingColor?: Color3 | Color4;
  66472. }
  66473. /**
  66474. * Defines the basic interface of a TexturePacker JSON File
  66475. */
  66476. export interface ITexturePackerJSON {
  66477. /**
  66478. * The frame ID
  66479. */
  66480. name: string;
  66481. /**
  66482. * The base64 channel data
  66483. */
  66484. sets: any;
  66485. /**
  66486. * The options of the Packer
  66487. */
  66488. options: ITexturePackerOptions;
  66489. /**
  66490. * The frame data of the Packer
  66491. */
  66492. frames: Array<number>;
  66493. }
  66494. /**
  66495. * This is a support class that generates a series of packed texture sets.
  66496. * @see https://doc.babylonjs.com/babylon101/materials
  66497. */
  66498. export class TexturePacker {
  66499. /** Packer Layout Constant 0 */
  66500. static readonly LAYOUT_STRIP: number;
  66501. /** Packer Layout Constant 1 */
  66502. static readonly LAYOUT_POWER2: number;
  66503. /** Packer Layout Constant 2 */
  66504. static readonly LAYOUT_COLNUM: number;
  66505. /** Packer Layout Constant 0 */
  66506. static readonly SUBUV_WRAP: number;
  66507. /** Packer Layout Constant 1 */
  66508. static readonly SUBUV_EXTEND: number;
  66509. /** Packer Layout Constant 2 */
  66510. static readonly SUBUV_COLOR: number;
  66511. /** The Name of the Texture Package */
  66512. name: string;
  66513. /** The scene scope of the TexturePacker */
  66514. scene: Scene;
  66515. /** The Meshes to target */
  66516. meshes: AbstractMesh[];
  66517. /** Arguments passed with the Constructor */
  66518. options: ITexturePackerOptions;
  66519. /** The promise that is started upon initialization */
  66520. promise: Nullable<Promise<TexturePacker | string>>;
  66521. /** The Container object for the channel sets that are generated */
  66522. sets: object;
  66523. /** The Container array for the frames that are generated */
  66524. frames: TexturePackerFrame[];
  66525. /** The expected number of textures the system is parsing. */
  66526. private _expecting;
  66527. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66528. private _paddingValue;
  66529. /**
  66530. * Initializes a texture package series from an array of meshes or a single mesh.
  66531. * @param name The name of the package
  66532. * @param meshes The target meshes to compose the package from
  66533. * @param options The arguments that texture packer should follow while building.
  66534. * @param scene The scene which the textures are scoped to.
  66535. * @returns TexturePacker
  66536. */
  66537. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66538. /**
  66539. * Starts the package process
  66540. * @param resolve The promises resolution function
  66541. * @returns TexturePacker
  66542. */
  66543. private _createFrames;
  66544. /**
  66545. * Calculates the Size of the Channel Sets
  66546. * @returns Vector2
  66547. */
  66548. private _calculateSize;
  66549. /**
  66550. * Calculates the UV data for the frames.
  66551. * @param baseSize the base frameSize
  66552. * @param padding the base frame padding
  66553. * @param dtSize size of the Dynamic Texture for that channel
  66554. * @param dtUnits is 1/dtSize
  66555. * @param update flag to update the input meshes
  66556. */
  66557. private _calculateMeshUVFrames;
  66558. /**
  66559. * Calculates the frames Offset.
  66560. * @param index of the frame
  66561. * @returns Vector2
  66562. */
  66563. private _getFrameOffset;
  66564. /**
  66565. * Updates a Mesh to the frame data
  66566. * @param mesh that is the target
  66567. * @param frameID or the frame index
  66568. */
  66569. private _updateMeshUV;
  66570. /**
  66571. * Updates a Meshes materials to use the texture packer channels
  66572. * @param m is the mesh to target
  66573. * @param force all channels on the packer to be set.
  66574. */
  66575. private _updateTextureReferences;
  66576. /**
  66577. * Public method to set a Mesh to a frame
  66578. * @param m that is the target
  66579. * @param frameID or the frame index
  66580. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66581. */
  66582. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66583. /**
  66584. * Starts the async promise to compile the texture packer.
  66585. * @returns Promise<void>
  66586. */
  66587. processAsync(): Promise<void>;
  66588. /**
  66589. * Disposes all textures associated with this packer
  66590. */
  66591. dispose(): void;
  66592. /**
  66593. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66594. * @param imageType is the image type to use.
  66595. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66596. */
  66597. download(imageType?: string, quality?: number): void;
  66598. /**
  66599. * Public method to load a texturePacker JSON file.
  66600. * @param data of the JSON file in string format.
  66601. */
  66602. updateFromJSON(data: string): void;
  66603. }
  66604. }
  66605. declare module BABYLON {
  66606. /**
  66607. * 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.
  66608. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66609. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66610. */
  66611. export class CustomProceduralTexture extends ProceduralTexture {
  66612. private _animate;
  66613. private _time;
  66614. private _config;
  66615. private _texturePath;
  66616. /**
  66617. * Instantiates a new Custom Procedural Texture.
  66618. * 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.
  66619. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66620. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66621. * @param name Define the name of the texture
  66622. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66623. * @param size Define the size of the texture to create
  66624. * @param scene Define the scene the texture belongs to
  66625. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66626. * @param generateMipMaps Define if the texture should creates mip maps or not
  66627. */
  66628. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66629. private _loadJson;
  66630. /**
  66631. * Is the texture ready to be used ? (rendered at least once)
  66632. * @returns true if ready, otherwise, false.
  66633. */
  66634. isReady(): boolean;
  66635. /**
  66636. * Render the texture to its associated render target.
  66637. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66638. */
  66639. render(useCameraPostProcess?: boolean): void;
  66640. /**
  66641. * Update the list of dependant textures samplers in the shader.
  66642. */
  66643. updateTextures(): void;
  66644. /**
  66645. * Update the uniform values of the procedural texture in the shader.
  66646. */
  66647. updateShaderUniforms(): void;
  66648. /**
  66649. * Define if the texture animates or not.
  66650. */
  66651. get animate(): boolean;
  66652. set animate(value: boolean);
  66653. }
  66654. }
  66655. declare module BABYLON {
  66656. /** @hidden */
  66657. export var noisePixelShader: {
  66658. name: string;
  66659. shader: string;
  66660. };
  66661. }
  66662. declare module BABYLON {
  66663. /**
  66664. * Class used to generate noise procedural textures
  66665. */
  66666. export class NoiseProceduralTexture extends ProceduralTexture {
  66667. /** Gets or sets the start time (default is 0) */
  66668. time: number;
  66669. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66670. brightness: number;
  66671. /** Defines the number of octaves to process */
  66672. octaves: number;
  66673. /** Defines the level of persistence (0.8 by default) */
  66674. persistence: number;
  66675. /** Gets or sets animation speed factor (default is 1) */
  66676. animationSpeedFactor: number;
  66677. /**
  66678. * Creates a new NoiseProceduralTexture
  66679. * @param name defines the name fo the texture
  66680. * @param size defines the size of the texture (default is 256)
  66681. * @param scene defines the hosting scene
  66682. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66683. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66684. */
  66685. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66686. private _updateShaderUniforms;
  66687. protected _getDefines(): string;
  66688. /** Generate the current state of the procedural texture */
  66689. render(useCameraPostProcess?: boolean): void;
  66690. /**
  66691. * Serializes this noise procedural texture
  66692. * @returns a serialized noise procedural texture object
  66693. */
  66694. serialize(): any;
  66695. /**
  66696. * Clone the texture.
  66697. * @returns the cloned texture
  66698. */
  66699. clone(): NoiseProceduralTexture;
  66700. /**
  66701. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66702. * @param parsedTexture defines parsed texture data
  66703. * @param scene defines the current scene
  66704. * @param rootUrl defines the root URL containing noise procedural texture information
  66705. * @returns a parsed NoiseProceduralTexture
  66706. */
  66707. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66708. }
  66709. }
  66710. declare module BABYLON {
  66711. /**
  66712. * Raw cube texture where the raw buffers are passed in
  66713. */
  66714. export class RawCubeTexture extends CubeTexture {
  66715. /**
  66716. * Creates a cube texture where the raw buffers are passed in.
  66717. * @param scene defines the scene the texture is attached to
  66718. * @param data defines the array of data to use to create each face
  66719. * @param size defines the size of the textures
  66720. * @param format defines the format of the data
  66721. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66722. * @param generateMipMaps defines if the engine should generate the mip levels
  66723. * @param invertY defines if data must be stored with Y axis inverted
  66724. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66725. * @param compression defines the compression used (null by default)
  66726. */
  66727. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66728. /**
  66729. * Updates the raw cube texture.
  66730. * @param data defines the data to store
  66731. * @param format defines the data format
  66732. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66733. * @param invertY defines if data must be stored with Y axis inverted
  66734. * @param compression defines the compression used (null by default)
  66735. * @param level defines which level of the texture to update
  66736. */
  66737. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66738. /**
  66739. * Updates a raw cube texture with RGBD encoded data.
  66740. * @param data defines the array of data [mipmap][face] to use to create each face
  66741. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66742. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66743. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66744. * @returns a promsie that resolves when the operation is complete
  66745. */
  66746. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66747. /**
  66748. * Clones the raw cube texture.
  66749. * @return a new cube texture
  66750. */
  66751. clone(): CubeTexture;
  66752. /** @hidden */
  66753. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66754. }
  66755. }
  66756. declare module BABYLON {
  66757. /**
  66758. * Class used to store 2D array textures containing user data
  66759. */
  66760. export class RawTexture2DArray extends Texture {
  66761. /** Gets or sets the texture format to use */
  66762. format: number;
  66763. /**
  66764. * Create a new RawTexture2DArray
  66765. * @param data defines the data of the texture
  66766. * @param width defines the width of the texture
  66767. * @param height defines the height of the texture
  66768. * @param depth defines the number of layers of the texture
  66769. * @param format defines the texture format to use
  66770. * @param scene defines the hosting scene
  66771. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66772. * @param invertY defines if texture must be stored with Y axis inverted
  66773. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66774. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66775. */
  66776. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66777. /** Gets or sets the texture format to use */
  66778. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66779. /**
  66780. * Update the texture with new data
  66781. * @param data defines the data to store in the texture
  66782. */
  66783. update(data: ArrayBufferView): void;
  66784. }
  66785. }
  66786. declare module BABYLON {
  66787. /**
  66788. * Class used to store 3D textures containing user data
  66789. */
  66790. export class RawTexture3D extends Texture {
  66791. /** Gets or sets the texture format to use */
  66792. format: number;
  66793. /**
  66794. * Create a new RawTexture3D
  66795. * @param data defines the data of the texture
  66796. * @param width defines the width of the texture
  66797. * @param height defines the height of the texture
  66798. * @param depth defines the depth of the texture
  66799. * @param format defines the texture format to use
  66800. * @param scene defines the hosting scene
  66801. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66802. * @param invertY defines if texture must be stored with Y axis inverted
  66803. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66804. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66805. */
  66806. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66807. /** Gets or sets the texture format to use */
  66808. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66809. /**
  66810. * Update the texture with new data
  66811. * @param data defines the data to store in the texture
  66812. */
  66813. update(data: ArrayBufferView): void;
  66814. }
  66815. }
  66816. declare module BABYLON {
  66817. /**
  66818. * Creates a refraction texture used by refraction channel of the standard material.
  66819. * It is like a mirror but to see through a material.
  66820. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66821. */
  66822. export class RefractionTexture extends RenderTargetTexture {
  66823. /**
  66824. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66825. * 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.
  66826. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66827. */
  66828. refractionPlane: Plane;
  66829. /**
  66830. * Define how deep under the surface we should see.
  66831. */
  66832. depth: number;
  66833. /**
  66834. * Creates a refraction texture used by refraction channel of the standard material.
  66835. * It is like a mirror but to see through a material.
  66836. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66837. * @param name Define the texture name
  66838. * @param size Define the size of the underlying texture
  66839. * @param scene Define the scene the refraction belongs to
  66840. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66841. */
  66842. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66843. /**
  66844. * Clone the refraction texture.
  66845. * @returns the cloned texture
  66846. */
  66847. clone(): RefractionTexture;
  66848. /**
  66849. * Serialize the texture to a JSON representation you could use in Parse later on
  66850. * @returns the serialized JSON representation
  66851. */
  66852. serialize(): any;
  66853. }
  66854. }
  66855. declare module BABYLON {
  66856. /**
  66857. * Block used to add support for vertex skinning (bones)
  66858. */
  66859. export class BonesBlock extends NodeMaterialBlock {
  66860. /**
  66861. * Creates a new BonesBlock
  66862. * @param name defines the block name
  66863. */
  66864. constructor(name: string);
  66865. /**
  66866. * Initialize the block and prepare the context for build
  66867. * @param state defines the state that will be used for the build
  66868. */
  66869. initialize(state: NodeMaterialBuildState): void;
  66870. /**
  66871. * Gets the current class name
  66872. * @returns the class name
  66873. */
  66874. getClassName(): string;
  66875. /**
  66876. * Gets the matrix indices input component
  66877. */
  66878. get matricesIndices(): NodeMaterialConnectionPoint;
  66879. /**
  66880. * Gets the matrix weights input component
  66881. */
  66882. get matricesWeights(): NodeMaterialConnectionPoint;
  66883. /**
  66884. * Gets the extra matrix indices input component
  66885. */
  66886. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66887. /**
  66888. * Gets the extra matrix weights input component
  66889. */
  66890. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66891. /**
  66892. * Gets the world input component
  66893. */
  66894. get world(): NodeMaterialConnectionPoint;
  66895. /**
  66896. * Gets the output component
  66897. */
  66898. get output(): NodeMaterialConnectionPoint;
  66899. autoConfigure(material: NodeMaterial): void;
  66900. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66901. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66902. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66903. protected _buildBlock(state: NodeMaterialBuildState): this;
  66904. }
  66905. }
  66906. declare module BABYLON {
  66907. /**
  66908. * Block used to add support for instances
  66909. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66910. */
  66911. export class InstancesBlock extends NodeMaterialBlock {
  66912. /**
  66913. * Creates a new InstancesBlock
  66914. * @param name defines the block name
  66915. */
  66916. constructor(name: string);
  66917. /**
  66918. * Gets the current class name
  66919. * @returns the class name
  66920. */
  66921. getClassName(): string;
  66922. /**
  66923. * Gets the first world row input component
  66924. */
  66925. get world0(): NodeMaterialConnectionPoint;
  66926. /**
  66927. * Gets the second world row input component
  66928. */
  66929. get world1(): NodeMaterialConnectionPoint;
  66930. /**
  66931. * Gets the third world row input component
  66932. */
  66933. get world2(): NodeMaterialConnectionPoint;
  66934. /**
  66935. * Gets the forth world row input component
  66936. */
  66937. get world3(): NodeMaterialConnectionPoint;
  66938. /**
  66939. * Gets the world input component
  66940. */
  66941. get world(): NodeMaterialConnectionPoint;
  66942. /**
  66943. * Gets the output component
  66944. */
  66945. get output(): NodeMaterialConnectionPoint;
  66946. /**
  66947. * Gets the isntanceID component
  66948. */
  66949. get instanceID(): NodeMaterialConnectionPoint;
  66950. autoConfigure(material: NodeMaterial): void;
  66951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66952. protected _buildBlock(state: NodeMaterialBuildState): this;
  66953. }
  66954. }
  66955. declare module BABYLON {
  66956. /**
  66957. * Block used to add morph targets support to vertex shader
  66958. */
  66959. export class MorphTargetsBlock extends NodeMaterialBlock {
  66960. private _repeatableContentAnchor;
  66961. /**
  66962. * Create a new MorphTargetsBlock
  66963. * @param name defines the block name
  66964. */
  66965. constructor(name: string);
  66966. /**
  66967. * Gets the current class name
  66968. * @returns the class name
  66969. */
  66970. getClassName(): string;
  66971. /**
  66972. * Gets the position input component
  66973. */
  66974. get position(): NodeMaterialConnectionPoint;
  66975. /**
  66976. * Gets the normal input component
  66977. */
  66978. get normal(): NodeMaterialConnectionPoint;
  66979. /**
  66980. * Gets the tangent input component
  66981. */
  66982. get tangent(): NodeMaterialConnectionPoint;
  66983. /**
  66984. * Gets the tangent input component
  66985. */
  66986. get uv(): NodeMaterialConnectionPoint;
  66987. /**
  66988. * Gets the position output component
  66989. */
  66990. get positionOutput(): NodeMaterialConnectionPoint;
  66991. /**
  66992. * Gets the normal output component
  66993. */
  66994. get normalOutput(): NodeMaterialConnectionPoint;
  66995. /**
  66996. * Gets the tangent output component
  66997. */
  66998. get tangentOutput(): NodeMaterialConnectionPoint;
  66999. /**
  67000. * Gets the tangent output component
  67001. */
  67002. get uvOutput(): NodeMaterialConnectionPoint;
  67003. initialize(state: NodeMaterialBuildState): void;
  67004. autoConfigure(material: NodeMaterial): void;
  67005. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67006. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67007. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67008. protected _buildBlock(state: NodeMaterialBuildState): this;
  67009. }
  67010. }
  67011. declare module BABYLON {
  67012. /**
  67013. * Block used to get data information from a light
  67014. */
  67015. export class LightInformationBlock extends NodeMaterialBlock {
  67016. private _lightDataUniformName;
  67017. private _lightColorUniformName;
  67018. private _lightTypeDefineName;
  67019. /**
  67020. * Gets or sets the light associated with this block
  67021. */
  67022. light: Nullable<Light>;
  67023. /**
  67024. * Creates a new LightInformationBlock
  67025. * @param name defines the block name
  67026. */
  67027. constructor(name: string);
  67028. /**
  67029. * Gets the current class name
  67030. * @returns the class name
  67031. */
  67032. getClassName(): string;
  67033. /**
  67034. * Gets the world position input component
  67035. */
  67036. get worldPosition(): NodeMaterialConnectionPoint;
  67037. /**
  67038. * Gets the direction output component
  67039. */
  67040. get direction(): NodeMaterialConnectionPoint;
  67041. /**
  67042. * Gets the direction output component
  67043. */
  67044. get color(): NodeMaterialConnectionPoint;
  67045. /**
  67046. * Gets the direction output component
  67047. */
  67048. get intensity(): NodeMaterialConnectionPoint;
  67049. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67050. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67051. protected _buildBlock(state: NodeMaterialBuildState): this;
  67052. serialize(): any;
  67053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67054. }
  67055. }
  67056. declare module BABYLON {
  67057. /**
  67058. * Block used to add image processing support to fragment shader
  67059. */
  67060. export class ImageProcessingBlock extends NodeMaterialBlock {
  67061. /**
  67062. * Create a new ImageProcessingBlock
  67063. * @param name defines the block name
  67064. */
  67065. constructor(name: string);
  67066. /**
  67067. * Gets the current class name
  67068. * @returns the class name
  67069. */
  67070. getClassName(): string;
  67071. /**
  67072. * Gets the color input component
  67073. */
  67074. get color(): NodeMaterialConnectionPoint;
  67075. /**
  67076. * Gets the output component
  67077. */
  67078. get output(): NodeMaterialConnectionPoint;
  67079. /**
  67080. * Initialize the block and prepare the context for build
  67081. * @param state defines the state that will be used for the build
  67082. */
  67083. initialize(state: NodeMaterialBuildState): void;
  67084. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67086. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67087. protected _buildBlock(state: NodeMaterialBuildState): this;
  67088. }
  67089. }
  67090. declare module BABYLON {
  67091. /**
  67092. * Block used to pertub normals based on a normal map
  67093. */
  67094. export class PerturbNormalBlock extends NodeMaterialBlock {
  67095. private _tangentSpaceParameterName;
  67096. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67097. invertX: boolean;
  67098. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67099. invertY: boolean;
  67100. /**
  67101. * Create a new PerturbNormalBlock
  67102. * @param name defines the block name
  67103. */
  67104. constructor(name: string);
  67105. /**
  67106. * Gets the current class name
  67107. * @returns the class name
  67108. */
  67109. getClassName(): string;
  67110. /**
  67111. * Gets the world position input component
  67112. */
  67113. get worldPosition(): NodeMaterialConnectionPoint;
  67114. /**
  67115. * Gets the world normal input component
  67116. */
  67117. get worldNormal(): NodeMaterialConnectionPoint;
  67118. /**
  67119. * Gets the world tangent input component
  67120. */
  67121. get worldTangent(): NodeMaterialConnectionPoint;
  67122. /**
  67123. * Gets the uv input component
  67124. */
  67125. get uv(): NodeMaterialConnectionPoint;
  67126. /**
  67127. * Gets the normal map color input component
  67128. */
  67129. get normalMapColor(): NodeMaterialConnectionPoint;
  67130. /**
  67131. * Gets the strength input component
  67132. */
  67133. get strength(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the output component
  67136. */
  67137. get output(): NodeMaterialConnectionPoint;
  67138. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67139. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67140. autoConfigure(material: NodeMaterial): void;
  67141. protected _buildBlock(state: NodeMaterialBuildState): this;
  67142. protected _dumpPropertiesCode(): string;
  67143. serialize(): any;
  67144. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67145. }
  67146. }
  67147. declare module BABYLON {
  67148. /**
  67149. * Block used to discard a pixel if a value is smaller than a cutoff
  67150. */
  67151. export class DiscardBlock extends NodeMaterialBlock {
  67152. /**
  67153. * Create a new DiscardBlock
  67154. * @param name defines the block name
  67155. */
  67156. constructor(name: string);
  67157. /**
  67158. * Gets the current class name
  67159. * @returns the class name
  67160. */
  67161. getClassName(): string;
  67162. /**
  67163. * Gets the color input component
  67164. */
  67165. get value(): NodeMaterialConnectionPoint;
  67166. /**
  67167. * Gets the cutoff input component
  67168. */
  67169. get cutoff(): NodeMaterialConnectionPoint;
  67170. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67171. }
  67172. }
  67173. declare module BABYLON {
  67174. /**
  67175. * Block used to test if the fragment shader is front facing
  67176. */
  67177. export class FrontFacingBlock extends NodeMaterialBlock {
  67178. /**
  67179. * Creates a new FrontFacingBlock
  67180. * @param name defines the block name
  67181. */
  67182. constructor(name: string);
  67183. /**
  67184. * Gets the current class name
  67185. * @returns the class name
  67186. */
  67187. getClassName(): string;
  67188. /**
  67189. * Gets the output component
  67190. */
  67191. get output(): NodeMaterialConnectionPoint;
  67192. protected _buildBlock(state: NodeMaterialBuildState): this;
  67193. }
  67194. }
  67195. declare module BABYLON {
  67196. /**
  67197. * Block used to get the derivative value on x and y of a given input
  67198. */
  67199. export class DerivativeBlock extends NodeMaterialBlock {
  67200. /**
  67201. * Create a new DerivativeBlock
  67202. * @param name defines the block name
  67203. */
  67204. constructor(name: string);
  67205. /**
  67206. * Gets the current class name
  67207. * @returns the class name
  67208. */
  67209. getClassName(): string;
  67210. /**
  67211. * Gets the input component
  67212. */
  67213. get input(): NodeMaterialConnectionPoint;
  67214. /**
  67215. * Gets the derivative output on x
  67216. */
  67217. get dx(): NodeMaterialConnectionPoint;
  67218. /**
  67219. * Gets the derivative output on y
  67220. */
  67221. get dy(): NodeMaterialConnectionPoint;
  67222. protected _buildBlock(state: NodeMaterialBuildState): this;
  67223. }
  67224. }
  67225. declare module BABYLON {
  67226. /**
  67227. * Block used to make gl_FragCoord available
  67228. */
  67229. export class FragCoordBlock extends NodeMaterialBlock {
  67230. /**
  67231. * Creates a new FragCoordBlock
  67232. * @param name defines the block name
  67233. */
  67234. constructor(name: string);
  67235. /**
  67236. * Gets the current class name
  67237. * @returns the class name
  67238. */
  67239. getClassName(): string;
  67240. /**
  67241. * Gets the xy component
  67242. */
  67243. get xy(): NodeMaterialConnectionPoint;
  67244. /**
  67245. * Gets the xyz component
  67246. */
  67247. get xyz(): NodeMaterialConnectionPoint;
  67248. /**
  67249. * Gets the xyzw component
  67250. */
  67251. get xyzw(): NodeMaterialConnectionPoint;
  67252. /**
  67253. * Gets the x component
  67254. */
  67255. get x(): NodeMaterialConnectionPoint;
  67256. /**
  67257. * Gets the y component
  67258. */
  67259. get y(): NodeMaterialConnectionPoint;
  67260. /**
  67261. * Gets the z component
  67262. */
  67263. get z(): NodeMaterialConnectionPoint;
  67264. /**
  67265. * Gets the w component
  67266. */
  67267. get output(): NodeMaterialConnectionPoint;
  67268. protected writeOutputs(state: NodeMaterialBuildState): string;
  67269. protected _buildBlock(state: NodeMaterialBuildState): this;
  67270. }
  67271. }
  67272. declare module BABYLON {
  67273. /**
  67274. * Block used to get the screen sizes
  67275. */
  67276. export class ScreenSizeBlock extends NodeMaterialBlock {
  67277. private _varName;
  67278. private _scene;
  67279. /**
  67280. * Creates a new ScreenSizeBlock
  67281. * @param name defines the block name
  67282. */
  67283. constructor(name: string);
  67284. /**
  67285. * Gets the current class name
  67286. * @returns the class name
  67287. */
  67288. getClassName(): string;
  67289. /**
  67290. * Gets the xy component
  67291. */
  67292. get xy(): NodeMaterialConnectionPoint;
  67293. /**
  67294. * Gets the x component
  67295. */
  67296. get x(): NodeMaterialConnectionPoint;
  67297. /**
  67298. * Gets the y component
  67299. */
  67300. get y(): NodeMaterialConnectionPoint;
  67301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67302. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67303. protected _buildBlock(state: NodeMaterialBuildState): this;
  67304. }
  67305. }
  67306. declare module BABYLON {
  67307. /**
  67308. * Block used to add support for scene fog
  67309. */
  67310. export class FogBlock extends NodeMaterialBlock {
  67311. private _fogDistanceName;
  67312. private _fogParameters;
  67313. /**
  67314. * Create a new FogBlock
  67315. * @param name defines the block name
  67316. */
  67317. constructor(name: string);
  67318. /**
  67319. * Gets the current class name
  67320. * @returns the class name
  67321. */
  67322. getClassName(): string;
  67323. /**
  67324. * Gets the world position input component
  67325. */
  67326. get worldPosition(): NodeMaterialConnectionPoint;
  67327. /**
  67328. * Gets the view input component
  67329. */
  67330. get view(): NodeMaterialConnectionPoint;
  67331. /**
  67332. * Gets the color input component
  67333. */
  67334. get input(): NodeMaterialConnectionPoint;
  67335. /**
  67336. * Gets the fog color input component
  67337. */
  67338. get fogColor(): NodeMaterialConnectionPoint;
  67339. /**
  67340. * Gets the output component
  67341. */
  67342. get output(): NodeMaterialConnectionPoint;
  67343. autoConfigure(material: NodeMaterial): void;
  67344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67346. protected _buildBlock(state: NodeMaterialBuildState): this;
  67347. }
  67348. }
  67349. declare module BABYLON {
  67350. /**
  67351. * Block used to add light in the fragment shader
  67352. */
  67353. export class LightBlock extends NodeMaterialBlock {
  67354. private _lightId;
  67355. /**
  67356. * Gets or sets the light associated with this block
  67357. */
  67358. light: Nullable<Light>;
  67359. /**
  67360. * Create a new LightBlock
  67361. * @param name defines the block name
  67362. */
  67363. constructor(name: string);
  67364. /**
  67365. * Gets the current class name
  67366. * @returns the class name
  67367. */
  67368. getClassName(): string;
  67369. /**
  67370. * Gets the world position input component
  67371. */
  67372. get worldPosition(): NodeMaterialConnectionPoint;
  67373. /**
  67374. * Gets the world normal input component
  67375. */
  67376. get worldNormal(): NodeMaterialConnectionPoint;
  67377. /**
  67378. * Gets the camera (or eye) position component
  67379. */
  67380. get cameraPosition(): NodeMaterialConnectionPoint;
  67381. /**
  67382. * Gets the glossiness component
  67383. */
  67384. get glossiness(): NodeMaterialConnectionPoint;
  67385. /**
  67386. * Gets the glossinness power component
  67387. */
  67388. get glossPower(): NodeMaterialConnectionPoint;
  67389. /**
  67390. * Gets the diffuse color component
  67391. */
  67392. get diffuseColor(): NodeMaterialConnectionPoint;
  67393. /**
  67394. * Gets the specular color component
  67395. */
  67396. get specularColor(): NodeMaterialConnectionPoint;
  67397. /**
  67398. * Gets the view matrix component
  67399. */
  67400. get view(): NodeMaterialConnectionPoint;
  67401. /**
  67402. * Gets the diffuse output component
  67403. */
  67404. get diffuseOutput(): NodeMaterialConnectionPoint;
  67405. /**
  67406. * Gets the specular output component
  67407. */
  67408. get specularOutput(): NodeMaterialConnectionPoint;
  67409. /**
  67410. * Gets the shadow output component
  67411. */
  67412. get shadow(): NodeMaterialConnectionPoint;
  67413. autoConfigure(material: NodeMaterial): void;
  67414. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67415. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67416. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67417. private _injectVertexCode;
  67418. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67419. serialize(): any;
  67420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67421. }
  67422. }
  67423. declare module BABYLON {
  67424. /**
  67425. * Block used to read a reflection texture from a sampler
  67426. */
  67427. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67428. /**
  67429. * Create a new ReflectionTextureBlock
  67430. * @param name defines the block name
  67431. */
  67432. constructor(name: string);
  67433. /**
  67434. * Gets the current class name
  67435. * @returns the class name
  67436. */
  67437. getClassName(): string;
  67438. /**
  67439. * Gets the world position input component
  67440. */
  67441. get position(): NodeMaterialConnectionPoint;
  67442. /**
  67443. * Gets the world position input component
  67444. */
  67445. get worldPosition(): NodeMaterialConnectionPoint;
  67446. /**
  67447. * Gets the world normal input component
  67448. */
  67449. get worldNormal(): NodeMaterialConnectionPoint;
  67450. /**
  67451. * Gets the world input component
  67452. */
  67453. get world(): NodeMaterialConnectionPoint;
  67454. /**
  67455. * Gets the camera (or eye) position component
  67456. */
  67457. get cameraPosition(): NodeMaterialConnectionPoint;
  67458. /**
  67459. * Gets the view input component
  67460. */
  67461. get view(): NodeMaterialConnectionPoint;
  67462. /**
  67463. * Gets the rgb output component
  67464. */
  67465. get rgb(): NodeMaterialConnectionPoint;
  67466. /**
  67467. * Gets the rgba output component
  67468. */
  67469. get rgba(): NodeMaterialConnectionPoint;
  67470. /**
  67471. * Gets the r output component
  67472. */
  67473. get r(): NodeMaterialConnectionPoint;
  67474. /**
  67475. * Gets the g output component
  67476. */
  67477. get g(): NodeMaterialConnectionPoint;
  67478. /**
  67479. * Gets the b output component
  67480. */
  67481. get b(): NodeMaterialConnectionPoint;
  67482. /**
  67483. * Gets the a output component
  67484. */
  67485. get a(): NodeMaterialConnectionPoint;
  67486. autoConfigure(material: NodeMaterial): void;
  67487. protected _buildBlock(state: NodeMaterialBuildState): this;
  67488. }
  67489. }
  67490. declare module BABYLON {
  67491. /**
  67492. * Block used to add 2 vectors
  67493. */
  67494. export class AddBlock extends NodeMaterialBlock {
  67495. /**
  67496. * Creates a new AddBlock
  67497. * @param name defines the block name
  67498. */
  67499. constructor(name: string);
  67500. /**
  67501. * Gets the current class name
  67502. * @returns the class name
  67503. */
  67504. getClassName(): string;
  67505. /**
  67506. * Gets the left operand input component
  67507. */
  67508. get left(): NodeMaterialConnectionPoint;
  67509. /**
  67510. * Gets the right operand input component
  67511. */
  67512. get right(): NodeMaterialConnectionPoint;
  67513. /**
  67514. * Gets the output component
  67515. */
  67516. get output(): NodeMaterialConnectionPoint;
  67517. protected _buildBlock(state: NodeMaterialBuildState): this;
  67518. }
  67519. }
  67520. declare module BABYLON {
  67521. /**
  67522. * Block used to scale a vector by a float
  67523. */
  67524. export class ScaleBlock extends NodeMaterialBlock {
  67525. /**
  67526. * Creates a new ScaleBlock
  67527. * @param name defines the block name
  67528. */
  67529. constructor(name: string);
  67530. /**
  67531. * Gets the current class name
  67532. * @returns the class name
  67533. */
  67534. getClassName(): string;
  67535. /**
  67536. * Gets the input component
  67537. */
  67538. get input(): NodeMaterialConnectionPoint;
  67539. /**
  67540. * Gets the factor input component
  67541. */
  67542. get factor(): NodeMaterialConnectionPoint;
  67543. /**
  67544. * Gets the output component
  67545. */
  67546. get output(): NodeMaterialConnectionPoint;
  67547. protected _buildBlock(state: NodeMaterialBuildState): this;
  67548. }
  67549. }
  67550. declare module BABYLON {
  67551. /**
  67552. * Block used to clamp a float
  67553. */
  67554. export class ClampBlock extends NodeMaterialBlock {
  67555. /** Gets or sets the minimum range */
  67556. minimum: number;
  67557. /** Gets or sets the maximum range */
  67558. maximum: number;
  67559. /**
  67560. * Creates a new ClampBlock
  67561. * @param name defines the block name
  67562. */
  67563. constructor(name: string);
  67564. /**
  67565. * Gets the current class name
  67566. * @returns the class name
  67567. */
  67568. getClassName(): string;
  67569. /**
  67570. * Gets the value input component
  67571. */
  67572. get value(): NodeMaterialConnectionPoint;
  67573. /**
  67574. * Gets the output component
  67575. */
  67576. get output(): NodeMaterialConnectionPoint;
  67577. protected _buildBlock(state: NodeMaterialBuildState): this;
  67578. protected _dumpPropertiesCode(): string;
  67579. serialize(): any;
  67580. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67581. }
  67582. }
  67583. declare module BABYLON {
  67584. /**
  67585. * Block used to apply a cross product between 2 vectors
  67586. */
  67587. export class CrossBlock extends NodeMaterialBlock {
  67588. /**
  67589. * Creates a new CrossBlock
  67590. * @param name defines the block name
  67591. */
  67592. constructor(name: string);
  67593. /**
  67594. * Gets the current class name
  67595. * @returns the class name
  67596. */
  67597. getClassName(): string;
  67598. /**
  67599. * Gets the left operand input component
  67600. */
  67601. get left(): NodeMaterialConnectionPoint;
  67602. /**
  67603. * Gets the right operand input component
  67604. */
  67605. get right(): NodeMaterialConnectionPoint;
  67606. /**
  67607. * Gets the output component
  67608. */
  67609. get output(): NodeMaterialConnectionPoint;
  67610. protected _buildBlock(state: NodeMaterialBuildState): this;
  67611. }
  67612. }
  67613. declare module BABYLON {
  67614. /**
  67615. * Block used to apply a dot product between 2 vectors
  67616. */
  67617. export class DotBlock extends NodeMaterialBlock {
  67618. /**
  67619. * Creates a new DotBlock
  67620. * @param name defines the block name
  67621. */
  67622. constructor(name: string);
  67623. /**
  67624. * Gets the current class name
  67625. * @returns the class name
  67626. */
  67627. getClassName(): string;
  67628. /**
  67629. * Gets the left operand input component
  67630. */
  67631. get left(): NodeMaterialConnectionPoint;
  67632. /**
  67633. * Gets the right operand input component
  67634. */
  67635. get right(): NodeMaterialConnectionPoint;
  67636. /**
  67637. * Gets the output component
  67638. */
  67639. get output(): NodeMaterialConnectionPoint;
  67640. protected _buildBlock(state: NodeMaterialBuildState): this;
  67641. }
  67642. }
  67643. declare module BABYLON {
  67644. /**
  67645. * Block used to normalize a vector
  67646. */
  67647. export class NormalizeBlock extends NodeMaterialBlock {
  67648. /**
  67649. * Creates a new NormalizeBlock
  67650. * @param name defines the block name
  67651. */
  67652. constructor(name: string);
  67653. /**
  67654. * Gets the current class name
  67655. * @returns the class name
  67656. */
  67657. getClassName(): string;
  67658. /**
  67659. * Gets the input component
  67660. */
  67661. get input(): NodeMaterialConnectionPoint;
  67662. /**
  67663. * Gets the output component
  67664. */
  67665. get output(): NodeMaterialConnectionPoint;
  67666. protected _buildBlock(state: NodeMaterialBuildState): this;
  67667. }
  67668. }
  67669. declare module BABYLON {
  67670. /**
  67671. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67672. */
  67673. export class ColorMergerBlock extends NodeMaterialBlock {
  67674. /**
  67675. * Create a new ColorMergerBlock
  67676. * @param name defines the block name
  67677. */
  67678. constructor(name: string);
  67679. /**
  67680. * Gets the current class name
  67681. * @returns the class name
  67682. */
  67683. getClassName(): string;
  67684. /**
  67685. * Gets the rgb component (input)
  67686. */
  67687. get rgbIn(): NodeMaterialConnectionPoint;
  67688. /**
  67689. * Gets the r component (input)
  67690. */
  67691. get r(): NodeMaterialConnectionPoint;
  67692. /**
  67693. * Gets the g component (input)
  67694. */
  67695. get g(): NodeMaterialConnectionPoint;
  67696. /**
  67697. * Gets the b component (input)
  67698. */
  67699. get b(): NodeMaterialConnectionPoint;
  67700. /**
  67701. * Gets the a component (input)
  67702. */
  67703. get a(): NodeMaterialConnectionPoint;
  67704. /**
  67705. * Gets the rgba component (output)
  67706. */
  67707. get rgba(): NodeMaterialConnectionPoint;
  67708. /**
  67709. * Gets the rgb component (output)
  67710. */
  67711. get rgbOut(): NodeMaterialConnectionPoint;
  67712. /**
  67713. * Gets the rgb component (output)
  67714. * @deprecated Please use rgbOut instead.
  67715. */
  67716. get rgb(): NodeMaterialConnectionPoint;
  67717. protected _buildBlock(state: NodeMaterialBuildState): this;
  67718. }
  67719. }
  67720. declare module BABYLON {
  67721. /**
  67722. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67723. */
  67724. export class VectorSplitterBlock extends NodeMaterialBlock {
  67725. /**
  67726. * Create a new VectorSplitterBlock
  67727. * @param name defines the block name
  67728. */
  67729. constructor(name: string);
  67730. /**
  67731. * Gets the current class name
  67732. * @returns the class name
  67733. */
  67734. getClassName(): string;
  67735. /**
  67736. * Gets the xyzw component (input)
  67737. */
  67738. get xyzw(): NodeMaterialConnectionPoint;
  67739. /**
  67740. * Gets the xyz component (input)
  67741. */
  67742. get xyzIn(): NodeMaterialConnectionPoint;
  67743. /**
  67744. * Gets the xy component (input)
  67745. */
  67746. get xyIn(): NodeMaterialConnectionPoint;
  67747. /**
  67748. * Gets the xyz component (output)
  67749. */
  67750. get xyzOut(): NodeMaterialConnectionPoint;
  67751. /**
  67752. * Gets the xy component (output)
  67753. */
  67754. get xyOut(): NodeMaterialConnectionPoint;
  67755. /**
  67756. * Gets the x component (output)
  67757. */
  67758. get x(): NodeMaterialConnectionPoint;
  67759. /**
  67760. * Gets the y component (output)
  67761. */
  67762. get y(): NodeMaterialConnectionPoint;
  67763. /**
  67764. * Gets the z component (output)
  67765. */
  67766. get z(): NodeMaterialConnectionPoint;
  67767. /**
  67768. * Gets the w component (output)
  67769. */
  67770. get w(): NodeMaterialConnectionPoint;
  67771. protected _inputRename(name: string): string;
  67772. protected _outputRename(name: string): string;
  67773. protected _buildBlock(state: NodeMaterialBuildState): this;
  67774. }
  67775. }
  67776. declare module BABYLON {
  67777. /**
  67778. * Block used to lerp between 2 values
  67779. */
  67780. export class LerpBlock extends NodeMaterialBlock {
  67781. /**
  67782. * Creates a new LerpBlock
  67783. * @param name defines the block name
  67784. */
  67785. constructor(name: string);
  67786. /**
  67787. * Gets the current class name
  67788. * @returns the class name
  67789. */
  67790. getClassName(): string;
  67791. /**
  67792. * Gets the left operand input component
  67793. */
  67794. get left(): NodeMaterialConnectionPoint;
  67795. /**
  67796. * Gets the right operand input component
  67797. */
  67798. get right(): NodeMaterialConnectionPoint;
  67799. /**
  67800. * Gets the gradient operand input component
  67801. */
  67802. get gradient(): NodeMaterialConnectionPoint;
  67803. /**
  67804. * Gets the output component
  67805. */
  67806. get output(): NodeMaterialConnectionPoint;
  67807. protected _buildBlock(state: NodeMaterialBuildState): this;
  67808. }
  67809. }
  67810. declare module BABYLON {
  67811. /**
  67812. * Block used to divide 2 vectors
  67813. */
  67814. export class DivideBlock extends NodeMaterialBlock {
  67815. /**
  67816. * Creates a new DivideBlock
  67817. * @param name defines the block name
  67818. */
  67819. constructor(name: string);
  67820. /**
  67821. * Gets the current class name
  67822. * @returns the class name
  67823. */
  67824. getClassName(): string;
  67825. /**
  67826. * Gets the left operand input component
  67827. */
  67828. get left(): NodeMaterialConnectionPoint;
  67829. /**
  67830. * Gets the right operand input component
  67831. */
  67832. get right(): NodeMaterialConnectionPoint;
  67833. /**
  67834. * Gets the output component
  67835. */
  67836. get output(): NodeMaterialConnectionPoint;
  67837. protected _buildBlock(state: NodeMaterialBuildState): this;
  67838. }
  67839. }
  67840. declare module BABYLON {
  67841. /**
  67842. * Block used to subtract 2 vectors
  67843. */
  67844. export class SubtractBlock extends NodeMaterialBlock {
  67845. /**
  67846. * Creates a new SubtractBlock
  67847. * @param name defines the block name
  67848. */
  67849. constructor(name: string);
  67850. /**
  67851. * Gets the current class name
  67852. * @returns the class name
  67853. */
  67854. getClassName(): string;
  67855. /**
  67856. * Gets the left operand input component
  67857. */
  67858. get left(): NodeMaterialConnectionPoint;
  67859. /**
  67860. * Gets the right operand input component
  67861. */
  67862. get right(): NodeMaterialConnectionPoint;
  67863. /**
  67864. * Gets the output component
  67865. */
  67866. get output(): NodeMaterialConnectionPoint;
  67867. protected _buildBlock(state: NodeMaterialBuildState): this;
  67868. }
  67869. }
  67870. declare module BABYLON {
  67871. /**
  67872. * Block used to step a value
  67873. */
  67874. export class StepBlock extends NodeMaterialBlock {
  67875. /**
  67876. * Creates a new StepBlock
  67877. * @param name defines the block name
  67878. */
  67879. constructor(name: string);
  67880. /**
  67881. * Gets the current class name
  67882. * @returns the class name
  67883. */
  67884. getClassName(): string;
  67885. /**
  67886. * Gets the value operand input component
  67887. */
  67888. get value(): NodeMaterialConnectionPoint;
  67889. /**
  67890. * Gets the edge operand input component
  67891. */
  67892. get edge(): NodeMaterialConnectionPoint;
  67893. /**
  67894. * Gets the output component
  67895. */
  67896. get output(): NodeMaterialConnectionPoint;
  67897. protected _buildBlock(state: NodeMaterialBuildState): this;
  67898. }
  67899. }
  67900. declare module BABYLON {
  67901. /**
  67902. * Block used to get the opposite (1 - x) of a value
  67903. */
  67904. export class OneMinusBlock extends NodeMaterialBlock {
  67905. /**
  67906. * Creates a new OneMinusBlock
  67907. * @param name defines the block name
  67908. */
  67909. constructor(name: string);
  67910. /**
  67911. * Gets the current class name
  67912. * @returns the class name
  67913. */
  67914. getClassName(): string;
  67915. /**
  67916. * Gets the input component
  67917. */
  67918. get input(): NodeMaterialConnectionPoint;
  67919. /**
  67920. * Gets the output component
  67921. */
  67922. get output(): NodeMaterialConnectionPoint;
  67923. protected _buildBlock(state: NodeMaterialBuildState): this;
  67924. }
  67925. }
  67926. declare module BABYLON {
  67927. /**
  67928. * Block used to get the view direction
  67929. */
  67930. export class ViewDirectionBlock extends NodeMaterialBlock {
  67931. /**
  67932. * Creates a new ViewDirectionBlock
  67933. * @param name defines the block name
  67934. */
  67935. constructor(name: string);
  67936. /**
  67937. * Gets the current class name
  67938. * @returns the class name
  67939. */
  67940. getClassName(): string;
  67941. /**
  67942. * Gets the world position component
  67943. */
  67944. get worldPosition(): NodeMaterialConnectionPoint;
  67945. /**
  67946. * Gets the camera position component
  67947. */
  67948. get cameraPosition(): NodeMaterialConnectionPoint;
  67949. /**
  67950. * Gets the output component
  67951. */
  67952. get output(): NodeMaterialConnectionPoint;
  67953. autoConfigure(material: NodeMaterial): void;
  67954. protected _buildBlock(state: NodeMaterialBuildState): this;
  67955. }
  67956. }
  67957. declare module BABYLON {
  67958. /**
  67959. * Block used to compute fresnel value
  67960. */
  67961. export class FresnelBlock extends NodeMaterialBlock {
  67962. /**
  67963. * Create a new FresnelBlock
  67964. * @param name defines the block name
  67965. */
  67966. constructor(name: string);
  67967. /**
  67968. * Gets the current class name
  67969. * @returns the class name
  67970. */
  67971. getClassName(): string;
  67972. /**
  67973. * Gets the world normal input component
  67974. */
  67975. get worldNormal(): NodeMaterialConnectionPoint;
  67976. /**
  67977. * Gets the view direction input component
  67978. */
  67979. get viewDirection(): NodeMaterialConnectionPoint;
  67980. /**
  67981. * Gets the bias input component
  67982. */
  67983. get bias(): NodeMaterialConnectionPoint;
  67984. /**
  67985. * Gets the camera (or eye) position component
  67986. */
  67987. get power(): NodeMaterialConnectionPoint;
  67988. /**
  67989. * Gets the fresnel output component
  67990. */
  67991. get fresnel(): NodeMaterialConnectionPoint;
  67992. autoConfigure(material: NodeMaterial): void;
  67993. protected _buildBlock(state: NodeMaterialBuildState): this;
  67994. }
  67995. }
  67996. declare module BABYLON {
  67997. /**
  67998. * Block used to get the max of 2 values
  67999. */
  68000. export class MaxBlock extends NodeMaterialBlock {
  68001. /**
  68002. * Creates a new MaxBlock
  68003. * @param name defines the block name
  68004. */
  68005. constructor(name: string);
  68006. /**
  68007. * Gets the current class name
  68008. * @returns the class name
  68009. */
  68010. getClassName(): string;
  68011. /**
  68012. * Gets the left operand input component
  68013. */
  68014. get left(): NodeMaterialConnectionPoint;
  68015. /**
  68016. * Gets the right operand input component
  68017. */
  68018. get right(): NodeMaterialConnectionPoint;
  68019. /**
  68020. * Gets the output component
  68021. */
  68022. get output(): NodeMaterialConnectionPoint;
  68023. protected _buildBlock(state: NodeMaterialBuildState): this;
  68024. }
  68025. }
  68026. declare module BABYLON {
  68027. /**
  68028. * Block used to get the min of 2 values
  68029. */
  68030. export class MinBlock extends NodeMaterialBlock {
  68031. /**
  68032. * Creates a new MinBlock
  68033. * @param name defines the block name
  68034. */
  68035. constructor(name: string);
  68036. /**
  68037. * Gets the current class name
  68038. * @returns the class name
  68039. */
  68040. getClassName(): string;
  68041. /**
  68042. * Gets the left operand input component
  68043. */
  68044. get left(): NodeMaterialConnectionPoint;
  68045. /**
  68046. * Gets the right operand input component
  68047. */
  68048. get right(): NodeMaterialConnectionPoint;
  68049. /**
  68050. * Gets the output component
  68051. */
  68052. get output(): NodeMaterialConnectionPoint;
  68053. protected _buildBlock(state: NodeMaterialBuildState): this;
  68054. }
  68055. }
  68056. declare module BABYLON {
  68057. /**
  68058. * Block used to get the distance between 2 values
  68059. */
  68060. export class DistanceBlock extends NodeMaterialBlock {
  68061. /**
  68062. * Creates a new DistanceBlock
  68063. * @param name defines the block name
  68064. */
  68065. constructor(name: string);
  68066. /**
  68067. * Gets the current class name
  68068. * @returns the class name
  68069. */
  68070. getClassName(): string;
  68071. /**
  68072. * Gets the left operand input component
  68073. */
  68074. get left(): NodeMaterialConnectionPoint;
  68075. /**
  68076. * Gets the right operand input component
  68077. */
  68078. get right(): NodeMaterialConnectionPoint;
  68079. /**
  68080. * Gets the output component
  68081. */
  68082. get output(): NodeMaterialConnectionPoint;
  68083. protected _buildBlock(state: NodeMaterialBuildState): this;
  68084. }
  68085. }
  68086. declare module BABYLON {
  68087. /**
  68088. * Block used to get the length of a vector
  68089. */
  68090. export class LengthBlock extends NodeMaterialBlock {
  68091. /**
  68092. * Creates a new LengthBlock
  68093. * @param name defines the block name
  68094. */
  68095. constructor(name: string);
  68096. /**
  68097. * Gets the current class name
  68098. * @returns the class name
  68099. */
  68100. getClassName(): string;
  68101. /**
  68102. * Gets the value input component
  68103. */
  68104. get value(): NodeMaterialConnectionPoint;
  68105. /**
  68106. * Gets the output component
  68107. */
  68108. get output(): NodeMaterialConnectionPoint;
  68109. protected _buildBlock(state: NodeMaterialBuildState): this;
  68110. }
  68111. }
  68112. declare module BABYLON {
  68113. /**
  68114. * Block used to get negative version of a value (i.e. x * -1)
  68115. */
  68116. export class NegateBlock extends NodeMaterialBlock {
  68117. /**
  68118. * Creates a new NegateBlock
  68119. * @param name defines the block name
  68120. */
  68121. constructor(name: string);
  68122. /**
  68123. * Gets the current class name
  68124. * @returns the class name
  68125. */
  68126. getClassName(): string;
  68127. /**
  68128. * Gets the value input component
  68129. */
  68130. get value(): NodeMaterialConnectionPoint;
  68131. /**
  68132. * Gets the output component
  68133. */
  68134. get output(): NodeMaterialConnectionPoint;
  68135. protected _buildBlock(state: NodeMaterialBuildState): this;
  68136. }
  68137. }
  68138. declare module BABYLON {
  68139. /**
  68140. * Block used to get the value of the first parameter raised to the power of the second
  68141. */
  68142. export class PowBlock extends NodeMaterialBlock {
  68143. /**
  68144. * Creates a new PowBlock
  68145. * @param name defines the block name
  68146. */
  68147. constructor(name: string);
  68148. /**
  68149. * Gets the current class name
  68150. * @returns the class name
  68151. */
  68152. getClassName(): string;
  68153. /**
  68154. * Gets the value operand input component
  68155. */
  68156. get value(): NodeMaterialConnectionPoint;
  68157. /**
  68158. * Gets the power operand input component
  68159. */
  68160. get power(): NodeMaterialConnectionPoint;
  68161. /**
  68162. * Gets the output component
  68163. */
  68164. get output(): NodeMaterialConnectionPoint;
  68165. protected _buildBlock(state: NodeMaterialBuildState): this;
  68166. }
  68167. }
  68168. declare module BABYLON {
  68169. /**
  68170. * Block used to get a random number
  68171. */
  68172. export class RandomNumberBlock extends NodeMaterialBlock {
  68173. /**
  68174. * Creates a new RandomNumberBlock
  68175. * @param name defines the block name
  68176. */
  68177. constructor(name: string);
  68178. /**
  68179. * Gets the current class name
  68180. * @returns the class name
  68181. */
  68182. getClassName(): string;
  68183. /**
  68184. * Gets the seed input component
  68185. */
  68186. get seed(): NodeMaterialConnectionPoint;
  68187. /**
  68188. * Gets the output component
  68189. */
  68190. get output(): NodeMaterialConnectionPoint;
  68191. protected _buildBlock(state: NodeMaterialBuildState): this;
  68192. }
  68193. }
  68194. declare module BABYLON {
  68195. /**
  68196. * Block used to compute arc tangent of 2 values
  68197. */
  68198. export class ArcTan2Block extends NodeMaterialBlock {
  68199. /**
  68200. * Creates a new ArcTan2Block
  68201. * @param name defines the block name
  68202. */
  68203. constructor(name: string);
  68204. /**
  68205. * Gets the current class name
  68206. * @returns the class name
  68207. */
  68208. getClassName(): string;
  68209. /**
  68210. * Gets the x operand input component
  68211. */
  68212. get x(): NodeMaterialConnectionPoint;
  68213. /**
  68214. * Gets the y operand input component
  68215. */
  68216. get y(): NodeMaterialConnectionPoint;
  68217. /**
  68218. * Gets the output component
  68219. */
  68220. get output(): NodeMaterialConnectionPoint;
  68221. protected _buildBlock(state: NodeMaterialBuildState): this;
  68222. }
  68223. }
  68224. declare module BABYLON {
  68225. /**
  68226. * Block used to smooth step a value
  68227. */
  68228. export class SmoothStepBlock extends NodeMaterialBlock {
  68229. /**
  68230. * Creates a new SmoothStepBlock
  68231. * @param name defines the block name
  68232. */
  68233. constructor(name: string);
  68234. /**
  68235. * Gets the current class name
  68236. * @returns the class name
  68237. */
  68238. getClassName(): string;
  68239. /**
  68240. * Gets the value operand input component
  68241. */
  68242. get value(): NodeMaterialConnectionPoint;
  68243. /**
  68244. * Gets the first edge operand input component
  68245. */
  68246. get edge0(): NodeMaterialConnectionPoint;
  68247. /**
  68248. * Gets the second edge operand input component
  68249. */
  68250. get edge1(): NodeMaterialConnectionPoint;
  68251. /**
  68252. * Gets the output component
  68253. */
  68254. get output(): NodeMaterialConnectionPoint;
  68255. protected _buildBlock(state: NodeMaterialBuildState): this;
  68256. }
  68257. }
  68258. declare module BABYLON {
  68259. /**
  68260. * Block used to get the reciprocal (1 / x) of a value
  68261. */
  68262. export class ReciprocalBlock extends NodeMaterialBlock {
  68263. /**
  68264. * Creates a new ReciprocalBlock
  68265. * @param name defines the block name
  68266. */
  68267. constructor(name: string);
  68268. /**
  68269. * Gets the current class name
  68270. * @returns the class name
  68271. */
  68272. getClassName(): string;
  68273. /**
  68274. * Gets the input component
  68275. */
  68276. get input(): NodeMaterialConnectionPoint;
  68277. /**
  68278. * Gets the output component
  68279. */
  68280. get output(): NodeMaterialConnectionPoint;
  68281. protected _buildBlock(state: NodeMaterialBuildState): this;
  68282. }
  68283. }
  68284. declare module BABYLON {
  68285. /**
  68286. * Block used to replace a color by another one
  68287. */
  68288. export class ReplaceColorBlock extends NodeMaterialBlock {
  68289. /**
  68290. * Creates a new ReplaceColorBlock
  68291. * @param name defines the block name
  68292. */
  68293. constructor(name: string);
  68294. /**
  68295. * Gets the current class name
  68296. * @returns the class name
  68297. */
  68298. getClassName(): string;
  68299. /**
  68300. * Gets the value input component
  68301. */
  68302. get value(): NodeMaterialConnectionPoint;
  68303. /**
  68304. * Gets the reference input component
  68305. */
  68306. get reference(): NodeMaterialConnectionPoint;
  68307. /**
  68308. * Gets the distance input component
  68309. */
  68310. get distance(): NodeMaterialConnectionPoint;
  68311. /**
  68312. * Gets the replacement input component
  68313. */
  68314. get replacement(): NodeMaterialConnectionPoint;
  68315. /**
  68316. * Gets the output component
  68317. */
  68318. get output(): NodeMaterialConnectionPoint;
  68319. protected _buildBlock(state: NodeMaterialBuildState): this;
  68320. }
  68321. }
  68322. declare module BABYLON {
  68323. /**
  68324. * Block used to posterize a value
  68325. * @see https://en.wikipedia.org/wiki/Posterization
  68326. */
  68327. export class PosterizeBlock extends NodeMaterialBlock {
  68328. /**
  68329. * Creates a new PosterizeBlock
  68330. * @param name defines the block name
  68331. */
  68332. constructor(name: string);
  68333. /**
  68334. * Gets the current class name
  68335. * @returns the class name
  68336. */
  68337. getClassName(): string;
  68338. /**
  68339. * Gets the value input component
  68340. */
  68341. get value(): NodeMaterialConnectionPoint;
  68342. /**
  68343. * Gets the steps input component
  68344. */
  68345. get steps(): NodeMaterialConnectionPoint;
  68346. /**
  68347. * Gets the output component
  68348. */
  68349. get output(): NodeMaterialConnectionPoint;
  68350. protected _buildBlock(state: NodeMaterialBuildState): this;
  68351. }
  68352. }
  68353. declare module BABYLON {
  68354. /**
  68355. * Operations supported by the Wave block
  68356. */
  68357. export enum WaveBlockKind {
  68358. /** SawTooth */
  68359. SawTooth = 0,
  68360. /** Square */
  68361. Square = 1,
  68362. /** Triangle */
  68363. Triangle = 2
  68364. }
  68365. /**
  68366. * Block used to apply wave operation to floats
  68367. */
  68368. export class WaveBlock extends NodeMaterialBlock {
  68369. /**
  68370. * Gets or sets the kibnd of wave to be applied by the block
  68371. */
  68372. kind: WaveBlockKind;
  68373. /**
  68374. * Creates a new WaveBlock
  68375. * @param name defines the block name
  68376. */
  68377. constructor(name: string);
  68378. /**
  68379. * Gets the current class name
  68380. * @returns the class name
  68381. */
  68382. getClassName(): string;
  68383. /**
  68384. * Gets the input component
  68385. */
  68386. get input(): NodeMaterialConnectionPoint;
  68387. /**
  68388. * Gets the output component
  68389. */
  68390. get output(): NodeMaterialConnectionPoint;
  68391. protected _buildBlock(state: NodeMaterialBuildState): this;
  68392. serialize(): any;
  68393. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68394. }
  68395. }
  68396. declare module BABYLON {
  68397. /**
  68398. * Class used to store a color step for the GradientBlock
  68399. */
  68400. export class GradientBlockColorStep {
  68401. private _step;
  68402. /**
  68403. * Gets value indicating which step this color is associated with (between 0 and 1)
  68404. */
  68405. get step(): number;
  68406. /**
  68407. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68408. */
  68409. set step(val: number);
  68410. private _color;
  68411. /**
  68412. * Gets the color associated with this step
  68413. */
  68414. get color(): Color3;
  68415. /**
  68416. * Sets the color associated with this step
  68417. */
  68418. set color(val: Color3);
  68419. /**
  68420. * Creates a new GradientBlockColorStep
  68421. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68422. * @param color defines the color associated with this step
  68423. */
  68424. constructor(step: number, color: Color3);
  68425. }
  68426. /**
  68427. * Block used to return a color from a gradient based on an input value between 0 and 1
  68428. */
  68429. export class GradientBlock extends NodeMaterialBlock {
  68430. /**
  68431. * Gets or sets the list of color steps
  68432. */
  68433. colorSteps: GradientBlockColorStep[];
  68434. /** Gets an observable raised when the value is changed */
  68435. onValueChangedObservable: Observable<GradientBlock>;
  68436. /** calls observable when the value is changed*/
  68437. colorStepsUpdated(): void;
  68438. /**
  68439. * Creates a new GradientBlock
  68440. * @param name defines the block name
  68441. */
  68442. constructor(name: string);
  68443. /**
  68444. * Gets the current class name
  68445. * @returns the class name
  68446. */
  68447. getClassName(): string;
  68448. /**
  68449. * Gets the gradient input component
  68450. */
  68451. get gradient(): NodeMaterialConnectionPoint;
  68452. /**
  68453. * Gets the output component
  68454. */
  68455. get output(): NodeMaterialConnectionPoint;
  68456. private _writeColorConstant;
  68457. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68458. serialize(): any;
  68459. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68460. protected _dumpPropertiesCode(): string;
  68461. }
  68462. }
  68463. declare module BABYLON {
  68464. /**
  68465. * Block used to normalize lerp between 2 values
  68466. */
  68467. export class NLerpBlock extends NodeMaterialBlock {
  68468. /**
  68469. * Creates a new NLerpBlock
  68470. * @param name defines the block name
  68471. */
  68472. constructor(name: string);
  68473. /**
  68474. * Gets the current class name
  68475. * @returns the class name
  68476. */
  68477. getClassName(): string;
  68478. /**
  68479. * Gets the left operand input component
  68480. */
  68481. get left(): NodeMaterialConnectionPoint;
  68482. /**
  68483. * Gets the right operand input component
  68484. */
  68485. get right(): NodeMaterialConnectionPoint;
  68486. /**
  68487. * Gets the gradient operand input component
  68488. */
  68489. get gradient(): NodeMaterialConnectionPoint;
  68490. /**
  68491. * Gets the output component
  68492. */
  68493. get output(): NodeMaterialConnectionPoint;
  68494. protected _buildBlock(state: NodeMaterialBuildState): this;
  68495. }
  68496. }
  68497. declare module BABYLON {
  68498. /**
  68499. * block used to Generate a Worley Noise 3D Noise Pattern
  68500. */
  68501. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68502. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68503. manhattanDistance: boolean;
  68504. /**
  68505. * Creates a new WorleyNoise3DBlock
  68506. * @param name defines the block name
  68507. */
  68508. constructor(name: string);
  68509. /**
  68510. * Gets the current class name
  68511. * @returns the class name
  68512. */
  68513. getClassName(): string;
  68514. /**
  68515. * Gets the seed input component
  68516. */
  68517. get seed(): NodeMaterialConnectionPoint;
  68518. /**
  68519. * Gets the jitter input component
  68520. */
  68521. get jitter(): NodeMaterialConnectionPoint;
  68522. /**
  68523. * Gets the output component
  68524. */
  68525. get output(): NodeMaterialConnectionPoint;
  68526. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68527. /**
  68528. * Exposes the properties to the UI?
  68529. */
  68530. protected _dumpPropertiesCode(): string;
  68531. /**
  68532. * Exposes the properties to the Seralize?
  68533. */
  68534. serialize(): any;
  68535. /**
  68536. * Exposes the properties to the deseralize?
  68537. */
  68538. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68539. }
  68540. }
  68541. declare module BABYLON {
  68542. /**
  68543. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68544. */
  68545. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68546. /**
  68547. * Creates a new SimplexPerlin3DBlock
  68548. * @param name defines the block name
  68549. */
  68550. constructor(name: string);
  68551. /**
  68552. * Gets the current class name
  68553. * @returns the class name
  68554. */
  68555. getClassName(): string;
  68556. /**
  68557. * Gets the seed operand input component
  68558. */
  68559. get seed(): NodeMaterialConnectionPoint;
  68560. /**
  68561. * Gets the output component
  68562. */
  68563. get output(): NodeMaterialConnectionPoint;
  68564. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68565. }
  68566. }
  68567. declare module BABYLON {
  68568. /**
  68569. * Block used to blend normals
  68570. */
  68571. export class NormalBlendBlock extends NodeMaterialBlock {
  68572. /**
  68573. * Creates a new NormalBlendBlock
  68574. * @param name defines the block name
  68575. */
  68576. constructor(name: string);
  68577. /**
  68578. * Gets the current class name
  68579. * @returns the class name
  68580. */
  68581. getClassName(): string;
  68582. /**
  68583. * Gets the first input component
  68584. */
  68585. get normalMap0(): NodeMaterialConnectionPoint;
  68586. /**
  68587. * Gets the second input component
  68588. */
  68589. get normalMap1(): NodeMaterialConnectionPoint;
  68590. /**
  68591. * Gets the output component
  68592. */
  68593. get output(): NodeMaterialConnectionPoint;
  68594. protected _buildBlock(state: NodeMaterialBuildState): this;
  68595. }
  68596. }
  68597. declare module BABYLON {
  68598. /**
  68599. * Block used to rotate a 2d vector by a given angle
  68600. */
  68601. export class Rotate2dBlock extends NodeMaterialBlock {
  68602. /**
  68603. * Creates a new Rotate2dBlock
  68604. * @param name defines the block name
  68605. */
  68606. constructor(name: string);
  68607. /**
  68608. * Gets the current class name
  68609. * @returns the class name
  68610. */
  68611. getClassName(): string;
  68612. /**
  68613. * Gets the input vector
  68614. */
  68615. get input(): NodeMaterialConnectionPoint;
  68616. /**
  68617. * Gets the input angle
  68618. */
  68619. get angle(): NodeMaterialConnectionPoint;
  68620. /**
  68621. * Gets the output component
  68622. */
  68623. get output(): NodeMaterialConnectionPoint;
  68624. autoConfigure(material: NodeMaterial): void;
  68625. protected _buildBlock(state: NodeMaterialBuildState): this;
  68626. }
  68627. }
  68628. declare module BABYLON {
  68629. /**
  68630. * Block used to get the reflected vector from a direction and a normal
  68631. */
  68632. export class ReflectBlock extends NodeMaterialBlock {
  68633. /**
  68634. * Creates a new ReflectBlock
  68635. * @param name defines the block name
  68636. */
  68637. constructor(name: string);
  68638. /**
  68639. * Gets the current class name
  68640. * @returns the class name
  68641. */
  68642. getClassName(): string;
  68643. /**
  68644. * Gets the incident component
  68645. */
  68646. get incident(): NodeMaterialConnectionPoint;
  68647. /**
  68648. * Gets the normal component
  68649. */
  68650. get normal(): NodeMaterialConnectionPoint;
  68651. /**
  68652. * Gets the output component
  68653. */
  68654. get output(): NodeMaterialConnectionPoint;
  68655. protected _buildBlock(state: NodeMaterialBuildState): this;
  68656. }
  68657. }
  68658. declare module BABYLON {
  68659. /**
  68660. * Block used to get the refracted vector from a direction and a normal
  68661. */
  68662. export class RefractBlock extends NodeMaterialBlock {
  68663. /**
  68664. * Creates a new RefractBlock
  68665. * @param name defines the block name
  68666. */
  68667. constructor(name: string);
  68668. /**
  68669. * Gets the current class name
  68670. * @returns the class name
  68671. */
  68672. getClassName(): string;
  68673. /**
  68674. * Gets the incident component
  68675. */
  68676. get incident(): NodeMaterialConnectionPoint;
  68677. /**
  68678. * Gets the normal component
  68679. */
  68680. get normal(): NodeMaterialConnectionPoint;
  68681. /**
  68682. * Gets the index of refraction component
  68683. */
  68684. get ior(): NodeMaterialConnectionPoint;
  68685. /**
  68686. * Gets the output component
  68687. */
  68688. get output(): NodeMaterialConnectionPoint;
  68689. protected _buildBlock(state: NodeMaterialBuildState): this;
  68690. }
  68691. }
  68692. declare module BABYLON {
  68693. /**
  68694. * Block used to desaturate a color
  68695. */
  68696. export class DesaturateBlock extends NodeMaterialBlock {
  68697. /**
  68698. * Creates a new DesaturateBlock
  68699. * @param name defines the block name
  68700. */
  68701. constructor(name: string);
  68702. /**
  68703. * Gets the current class name
  68704. * @returns the class name
  68705. */
  68706. getClassName(): string;
  68707. /**
  68708. * Gets the color operand input component
  68709. */
  68710. get color(): NodeMaterialConnectionPoint;
  68711. /**
  68712. * Gets the level operand input component
  68713. */
  68714. get level(): NodeMaterialConnectionPoint;
  68715. /**
  68716. * Gets the output component
  68717. */
  68718. get output(): NodeMaterialConnectionPoint;
  68719. protected _buildBlock(state: NodeMaterialBuildState): this;
  68720. }
  68721. }
  68722. declare module BABYLON {
  68723. /**
  68724. * Block used to implement the reflection module of the PBR material
  68725. */
  68726. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68727. /** @hidden */
  68728. _defineLODReflectionAlpha: string;
  68729. /** @hidden */
  68730. _defineLinearSpecularReflection: string;
  68731. private _vEnvironmentIrradianceName;
  68732. /** @hidden */
  68733. _vReflectionMicrosurfaceInfosName: string;
  68734. /** @hidden */
  68735. _vReflectionInfosName: string;
  68736. /** @hidden */
  68737. _vReflectionFilteringInfoName: string;
  68738. private _scene;
  68739. /**
  68740. * The properties below are set by the main PBR block prior to calling methods of this class.
  68741. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68742. * It's less burden on the user side in the editor part.
  68743. */
  68744. /** @hidden */
  68745. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68746. /** @hidden */
  68747. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68748. /** @hidden */
  68749. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68750. /** @hidden */
  68751. viewConnectionPoint: NodeMaterialConnectionPoint;
  68752. /**
  68753. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68754. * diffuse part of the IBL.
  68755. */
  68756. useSphericalHarmonics: boolean;
  68757. /**
  68758. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68759. */
  68760. forceIrradianceInFragment: boolean;
  68761. /**
  68762. * Create a new ReflectionBlock
  68763. * @param name defines the block name
  68764. */
  68765. constructor(name: string);
  68766. /**
  68767. * Gets the current class name
  68768. * @returns the class name
  68769. */
  68770. getClassName(): string;
  68771. /**
  68772. * Gets the position input component
  68773. */
  68774. get position(): NodeMaterialConnectionPoint;
  68775. /**
  68776. * Gets the world position input component
  68777. */
  68778. get worldPosition(): NodeMaterialConnectionPoint;
  68779. /**
  68780. * Gets the world normal input component
  68781. */
  68782. get worldNormal(): NodeMaterialConnectionPoint;
  68783. /**
  68784. * Gets the world input component
  68785. */
  68786. get world(): NodeMaterialConnectionPoint;
  68787. /**
  68788. * Gets the camera (or eye) position component
  68789. */
  68790. get cameraPosition(): NodeMaterialConnectionPoint;
  68791. /**
  68792. * Gets the view input component
  68793. */
  68794. get view(): NodeMaterialConnectionPoint;
  68795. /**
  68796. * Gets the color input component
  68797. */
  68798. get color(): NodeMaterialConnectionPoint;
  68799. /**
  68800. * Gets the reflection object output component
  68801. */
  68802. get reflection(): NodeMaterialConnectionPoint;
  68803. /**
  68804. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68805. */
  68806. get hasTexture(): boolean;
  68807. /**
  68808. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68809. */
  68810. get reflectionColor(): string;
  68811. protected _getTexture(): Nullable<BaseTexture>;
  68812. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68813. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68814. /**
  68815. * Gets the code to inject in the vertex shader
  68816. * @param state current state of the node material building
  68817. * @returns the shader code
  68818. */
  68819. handleVertexSide(state: NodeMaterialBuildState): string;
  68820. /**
  68821. * Gets the main code of the block (fragment side)
  68822. * @param state current state of the node material building
  68823. * @param normalVarName name of the existing variable corresponding to the normal
  68824. * @returns the shader code
  68825. */
  68826. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68827. protected _buildBlock(state: NodeMaterialBuildState): this;
  68828. protected _dumpPropertiesCode(): string;
  68829. serialize(): any;
  68830. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68831. }
  68832. }
  68833. declare module BABYLON {
  68834. /**
  68835. * Block used to implement the sheen module of the PBR material
  68836. */
  68837. export class SheenBlock extends NodeMaterialBlock {
  68838. /**
  68839. * Create a new SheenBlock
  68840. * @param name defines the block name
  68841. */
  68842. constructor(name: string);
  68843. /**
  68844. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68845. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68846. * making it easier to setup and tweak the effect
  68847. */
  68848. albedoScaling: boolean;
  68849. /**
  68850. * Defines if the sheen is linked to the sheen color.
  68851. */
  68852. linkSheenWithAlbedo: boolean;
  68853. /**
  68854. * Initialize the block and prepare the context for build
  68855. * @param state defines the state that will be used for the build
  68856. */
  68857. initialize(state: NodeMaterialBuildState): void;
  68858. /**
  68859. * Gets the current class name
  68860. * @returns the class name
  68861. */
  68862. getClassName(): string;
  68863. /**
  68864. * Gets the intensity input component
  68865. */
  68866. get intensity(): NodeMaterialConnectionPoint;
  68867. /**
  68868. * Gets the color input component
  68869. */
  68870. get color(): NodeMaterialConnectionPoint;
  68871. /**
  68872. * Gets the roughness input component
  68873. */
  68874. get roughness(): NodeMaterialConnectionPoint;
  68875. /**
  68876. * Gets the sheen object output component
  68877. */
  68878. get sheen(): NodeMaterialConnectionPoint;
  68879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68880. /**
  68881. * Gets the main code of the block (fragment side)
  68882. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68883. * @returns the shader code
  68884. */
  68885. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68886. protected _buildBlock(state: NodeMaterialBuildState): this;
  68887. protected _dumpPropertiesCode(): string;
  68888. serialize(): any;
  68889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68890. }
  68891. }
  68892. declare module BABYLON {
  68893. /**
  68894. * Block used to implement the anisotropy module of the PBR material
  68895. */
  68896. export class AnisotropyBlock extends NodeMaterialBlock {
  68897. /**
  68898. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68899. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68900. * It's less burden on the user side in the editor part.
  68901. */
  68902. /** @hidden */
  68903. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68904. /** @hidden */
  68905. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68906. /**
  68907. * Create a new AnisotropyBlock
  68908. * @param name defines the block name
  68909. */
  68910. constructor(name: string);
  68911. /**
  68912. * Initialize the block and prepare the context for build
  68913. * @param state defines the state that will be used for the build
  68914. */
  68915. initialize(state: NodeMaterialBuildState): void;
  68916. /**
  68917. * Gets the current class name
  68918. * @returns the class name
  68919. */
  68920. getClassName(): string;
  68921. /**
  68922. * Gets the intensity input component
  68923. */
  68924. get intensity(): NodeMaterialConnectionPoint;
  68925. /**
  68926. * Gets the direction input component
  68927. */
  68928. get direction(): NodeMaterialConnectionPoint;
  68929. /**
  68930. * Gets the uv input component
  68931. */
  68932. get uv(): NodeMaterialConnectionPoint;
  68933. /**
  68934. * Gets the worldTangent input component
  68935. */
  68936. get worldTangent(): NodeMaterialConnectionPoint;
  68937. /**
  68938. * Gets the anisotropy object output component
  68939. */
  68940. get anisotropy(): NodeMaterialConnectionPoint;
  68941. private _generateTBNSpace;
  68942. /**
  68943. * Gets the main code of the block (fragment side)
  68944. * @param state current state of the node material building
  68945. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68946. * @returns the shader code
  68947. */
  68948. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68949. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68950. protected _buildBlock(state: NodeMaterialBuildState): this;
  68951. }
  68952. }
  68953. declare module BABYLON {
  68954. /**
  68955. * Block used to implement the clear coat module of the PBR material
  68956. */
  68957. export class ClearCoatBlock extends NodeMaterialBlock {
  68958. private _scene;
  68959. /**
  68960. * Create a new ClearCoatBlock
  68961. * @param name defines the block name
  68962. */
  68963. constructor(name: string);
  68964. /**
  68965. * Defines if the F0 value should be remapped to account for the interface change in the material.
  68966. */
  68967. remapF0OnInterfaceChange: boolean;
  68968. /**
  68969. * Initialize the block and prepare the context for build
  68970. * @param state defines the state that will be used for the build
  68971. */
  68972. initialize(state: NodeMaterialBuildState): void;
  68973. /**
  68974. * Gets the current class name
  68975. * @returns the class name
  68976. */
  68977. getClassName(): string;
  68978. /**
  68979. * Gets the intensity input component
  68980. */
  68981. get intensity(): NodeMaterialConnectionPoint;
  68982. /**
  68983. * Gets the roughness input component
  68984. */
  68985. get roughness(): NodeMaterialConnectionPoint;
  68986. /**
  68987. * Gets the ior input component
  68988. */
  68989. get indexOfRefraction(): NodeMaterialConnectionPoint;
  68990. /**
  68991. * Gets the bump texture input component
  68992. */
  68993. get normalMapColor(): NodeMaterialConnectionPoint;
  68994. /**
  68995. * Gets the uv input component
  68996. */
  68997. get uv(): NodeMaterialConnectionPoint;
  68998. /**
  68999. * Gets the tint color input component
  69000. */
  69001. get tintColor(): NodeMaterialConnectionPoint;
  69002. /**
  69003. * Gets the tint "at distance" input component
  69004. */
  69005. get tintAtDistance(): NodeMaterialConnectionPoint;
  69006. /**
  69007. * Gets the tint thickness input component
  69008. */
  69009. get tintThickness(): NodeMaterialConnectionPoint;
  69010. /**
  69011. * Gets the world tangent input component
  69012. */
  69013. get worldTangent(): NodeMaterialConnectionPoint;
  69014. /**
  69015. * Gets the clear coat object output component
  69016. */
  69017. get clearcoat(): NodeMaterialConnectionPoint;
  69018. autoConfigure(material: NodeMaterial): void;
  69019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69020. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69021. private _generateTBNSpace;
  69022. /**
  69023. * Gets the main code of the block (fragment side)
  69024. * @param state current state of the node material building
  69025. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69026. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69027. * @param worldPosVarName name of the variable holding the world position
  69028. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69029. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69030. * @param worldNormalVarName name of the variable holding the world normal
  69031. * @returns the shader code
  69032. */
  69033. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69034. protected _buildBlock(state: NodeMaterialBuildState): this;
  69035. protected _dumpPropertiesCode(): string;
  69036. serialize(): any;
  69037. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69038. }
  69039. }
  69040. declare module BABYLON {
  69041. /**
  69042. * Block used to implement the sub surface module of the PBR material
  69043. */
  69044. export class SubSurfaceBlock extends NodeMaterialBlock {
  69045. /**
  69046. * Create a new SubSurfaceBlock
  69047. * @param name defines the block name
  69048. */
  69049. constructor(name: string);
  69050. /**
  69051. * Initialize the block and prepare the context for build
  69052. * @param state defines the state that will be used for the build
  69053. */
  69054. initialize(state: NodeMaterialBuildState): void;
  69055. /**
  69056. * Gets the current class name
  69057. * @returns the class name
  69058. */
  69059. getClassName(): string;
  69060. /**
  69061. * Gets the thickness component
  69062. */
  69063. get thickness(): NodeMaterialConnectionPoint;
  69064. /**
  69065. * Gets the tint color input component
  69066. */
  69067. get tintColor(): NodeMaterialConnectionPoint;
  69068. /**
  69069. * Gets the translucency intensity input component
  69070. */
  69071. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69072. /**
  69073. * Gets the translucency diffusion distance input component
  69074. */
  69075. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69076. /**
  69077. * Gets the refraction object parameters
  69078. */
  69079. get refraction(): NodeMaterialConnectionPoint;
  69080. /**
  69081. * Gets the sub surface object output component
  69082. */
  69083. get subsurface(): NodeMaterialConnectionPoint;
  69084. autoConfigure(material: NodeMaterial): void;
  69085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69086. /**
  69087. * Gets the main code of the block (fragment side)
  69088. * @param state current state of the node material building
  69089. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69090. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69091. * @param worldPosVarName name of the variable holding the world position
  69092. * @returns the shader code
  69093. */
  69094. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69095. protected _buildBlock(state: NodeMaterialBuildState): this;
  69096. }
  69097. }
  69098. declare module BABYLON {
  69099. /**
  69100. * Block used to implement the PBR metallic/roughness model
  69101. */
  69102. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69103. /**
  69104. * Gets or sets the light associated with this block
  69105. */
  69106. light: Nullable<Light>;
  69107. private _lightId;
  69108. private _scene;
  69109. private _environmentBRDFTexture;
  69110. private _environmentBrdfSamplerName;
  69111. private _vNormalWName;
  69112. private _invertNormalName;
  69113. private _metallicReflectanceColor;
  69114. private _metallicF0Factor;
  69115. private _vMetallicReflectanceFactorsName;
  69116. /**
  69117. * Create a new ReflectionBlock
  69118. * @param name defines the block name
  69119. */
  69120. constructor(name: string);
  69121. /**
  69122. * Intensity of the direct lights e.g. the four lights available in your scene.
  69123. * This impacts both the direct diffuse and specular highlights.
  69124. */
  69125. directIntensity: number;
  69126. /**
  69127. * Intensity of the environment e.g. how much the environment will light the object
  69128. * either through harmonics for rough material or through the refelction for shiny ones.
  69129. */
  69130. environmentIntensity: number;
  69131. /**
  69132. * This is a special control allowing the reduction of the specular highlights coming from the
  69133. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69134. */
  69135. specularIntensity: number;
  69136. /**
  69137. * Defines the falloff type used in this material.
  69138. * It by default is Physical.
  69139. */
  69140. lightFalloff: number;
  69141. /**
  69142. * Specifies that alpha test should be used
  69143. */
  69144. useAlphaTest: boolean;
  69145. /**
  69146. * Defines the alpha limits in alpha test mode.
  69147. */
  69148. alphaTestCutoff: number;
  69149. /**
  69150. * Specifies that alpha blending should be used
  69151. */
  69152. useAlphaBlending: boolean;
  69153. /**
  69154. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69155. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69156. */
  69157. useRadianceOverAlpha: boolean;
  69158. /**
  69159. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69160. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69161. */
  69162. useSpecularOverAlpha: boolean;
  69163. /**
  69164. * Enables specular anti aliasing in the PBR shader.
  69165. * It will both interacts on the Geometry for analytical and IBL lighting.
  69166. * It also prefilter the roughness map based on the bump values.
  69167. */
  69168. enableSpecularAntiAliasing: boolean;
  69169. /**
  69170. * Enables realtime filtering on the texture.
  69171. */
  69172. realTimeFiltering: boolean;
  69173. /**
  69174. * Quality switch for realtime filtering
  69175. */
  69176. realTimeFilteringQuality: number;
  69177. /**
  69178. * Defines if the material uses energy conservation.
  69179. */
  69180. useEnergyConservation: boolean;
  69181. /**
  69182. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69183. * too much the area relying on ambient texture to define their ambient occlusion.
  69184. */
  69185. useRadianceOcclusion: boolean;
  69186. /**
  69187. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69188. * makes the reflect vector face the model (under horizon).
  69189. */
  69190. useHorizonOcclusion: boolean;
  69191. /**
  69192. * If set to true, no lighting calculations will be applied.
  69193. */
  69194. unlit: boolean;
  69195. /**
  69196. * Force normal to face away from face.
  69197. */
  69198. forceNormalForward: boolean;
  69199. /**
  69200. * Defines the material debug mode.
  69201. * It helps seeing only some components of the material while troubleshooting.
  69202. */
  69203. debugMode: number;
  69204. /**
  69205. * Specify from where on screen the debug mode should start.
  69206. * The value goes from -1 (full screen) to 1 (not visible)
  69207. * It helps with side by side comparison against the final render
  69208. * This defaults to 0
  69209. */
  69210. debugLimit: number;
  69211. /**
  69212. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69213. * You can use the factor to better multiply the final value.
  69214. */
  69215. debugFactor: number;
  69216. /**
  69217. * Initialize the block and prepare the context for build
  69218. * @param state defines the state that will be used for the build
  69219. */
  69220. initialize(state: NodeMaterialBuildState): void;
  69221. /**
  69222. * Gets the current class name
  69223. * @returns the class name
  69224. */
  69225. getClassName(): string;
  69226. /**
  69227. * Gets the world position input component
  69228. */
  69229. get worldPosition(): NodeMaterialConnectionPoint;
  69230. /**
  69231. * Gets the world normal input component
  69232. */
  69233. get worldNormal(): NodeMaterialConnectionPoint;
  69234. /**
  69235. * Gets the view matrix parameter
  69236. */
  69237. get view(): NodeMaterialConnectionPoint;
  69238. /**
  69239. * Gets the camera position input component
  69240. */
  69241. get cameraPosition(): NodeMaterialConnectionPoint;
  69242. /**
  69243. * Gets the perturbed normal input component
  69244. */
  69245. get perturbedNormal(): NodeMaterialConnectionPoint;
  69246. /**
  69247. * Gets the base color input component
  69248. */
  69249. get baseColor(): NodeMaterialConnectionPoint;
  69250. /**
  69251. * Gets the metallic input component
  69252. */
  69253. get metallic(): NodeMaterialConnectionPoint;
  69254. /**
  69255. * Gets the roughness input component
  69256. */
  69257. get roughness(): NodeMaterialConnectionPoint;
  69258. /**
  69259. * Gets the ambient occlusion input component
  69260. */
  69261. get ambientOcc(): NodeMaterialConnectionPoint;
  69262. /**
  69263. * Gets the opacity input component
  69264. */
  69265. get opacity(): NodeMaterialConnectionPoint;
  69266. /**
  69267. * Gets the index of refraction input component
  69268. */
  69269. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69270. /**
  69271. * Gets the ambient color input component
  69272. */
  69273. get ambientColor(): NodeMaterialConnectionPoint;
  69274. /**
  69275. * Gets the reflection object parameters
  69276. */
  69277. get reflection(): NodeMaterialConnectionPoint;
  69278. /**
  69279. * Gets the clear coat object parameters
  69280. */
  69281. get clearcoat(): NodeMaterialConnectionPoint;
  69282. /**
  69283. * Gets the sheen object parameters
  69284. */
  69285. get sheen(): NodeMaterialConnectionPoint;
  69286. /**
  69287. * Gets the sub surface object parameters
  69288. */
  69289. get subsurface(): NodeMaterialConnectionPoint;
  69290. /**
  69291. * Gets the anisotropy object parameters
  69292. */
  69293. get anisotropy(): NodeMaterialConnectionPoint;
  69294. /**
  69295. * Gets the ambient output component
  69296. */
  69297. get ambientClr(): NodeMaterialConnectionPoint;
  69298. /**
  69299. * Gets the diffuse output component
  69300. */
  69301. get diffuseDir(): NodeMaterialConnectionPoint;
  69302. /**
  69303. * Gets the specular output component
  69304. */
  69305. get specularDir(): NodeMaterialConnectionPoint;
  69306. /**
  69307. * Gets the clear coat output component
  69308. */
  69309. get clearcoatDir(): NodeMaterialConnectionPoint;
  69310. /**
  69311. * Gets the sheen output component
  69312. */
  69313. get sheenDir(): NodeMaterialConnectionPoint;
  69314. /**
  69315. * Gets the indirect diffuse output component
  69316. */
  69317. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69318. /**
  69319. * Gets the indirect specular output component
  69320. */
  69321. get specularIndirect(): NodeMaterialConnectionPoint;
  69322. /**
  69323. * Gets the indirect clear coat output component
  69324. */
  69325. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69326. /**
  69327. * Gets the indirect sheen output component
  69328. */
  69329. get sheenIndirect(): NodeMaterialConnectionPoint;
  69330. /**
  69331. * Gets the refraction output component
  69332. */
  69333. get refraction(): NodeMaterialConnectionPoint;
  69334. /**
  69335. * Gets the global lighting output component
  69336. */
  69337. get lighting(): NodeMaterialConnectionPoint;
  69338. /**
  69339. * Gets the shadow output component
  69340. */
  69341. get shadow(): NodeMaterialConnectionPoint;
  69342. /**
  69343. * Gets the alpha output component
  69344. */
  69345. get alpha(): NodeMaterialConnectionPoint;
  69346. autoConfigure(material: NodeMaterial): void;
  69347. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69348. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69349. isReady(): boolean;
  69350. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69351. private _injectVertexCode;
  69352. private _getAlbedoOpacityCode;
  69353. private _getAmbientOcclusionCode;
  69354. private _getReflectivityCode;
  69355. protected _buildBlock(state: NodeMaterialBuildState): this;
  69356. protected _dumpPropertiesCode(): string;
  69357. serialize(): any;
  69358. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69359. }
  69360. }
  69361. declare module BABYLON {
  69362. /**
  69363. * Block used to compute value of one parameter modulo another
  69364. */
  69365. export class ModBlock extends NodeMaterialBlock {
  69366. /**
  69367. * Creates a new ModBlock
  69368. * @param name defines the block name
  69369. */
  69370. constructor(name: string);
  69371. /**
  69372. * Gets the current class name
  69373. * @returns the class name
  69374. */
  69375. getClassName(): string;
  69376. /**
  69377. * Gets the left operand input component
  69378. */
  69379. get left(): NodeMaterialConnectionPoint;
  69380. /**
  69381. * Gets the right operand input component
  69382. */
  69383. get right(): NodeMaterialConnectionPoint;
  69384. /**
  69385. * Gets the output component
  69386. */
  69387. get output(): NodeMaterialConnectionPoint;
  69388. protected _buildBlock(state: NodeMaterialBuildState): this;
  69389. }
  69390. }
  69391. declare module BABYLON {
  69392. /**
  69393. * Configuration for Draco compression
  69394. */
  69395. export interface IDracoCompressionConfiguration {
  69396. /**
  69397. * Configuration for the decoder.
  69398. */
  69399. decoder: {
  69400. /**
  69401. * The url to the WebAssembly module.
  69402. */
  69403. wasmUrl?: string;
  69404. /**
  69405. * The url to the WebAssembly binary.
  69406. */
  69407. wasmBinaryUrl?: string;
  69408. /**
  69409. * The url to the fallback JavaScript module.
  69410. */
  69411. fallbackUrl?: string;
  69412. };
  69413. }
  69414. /**
  69415. * Draco compression (https://google.github.io/draco/)
  69416. *
  69417. * This class wraps the Draco module.
  69418. *
  69419. * **Encoder**
  69420. *
  69421. * The encoder is not currently implemented.
  69422. *
  69423. * **Decoder**
  69424. *
  69425. * 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.
  69426. *
  69427. * To update the configuration, use the following code:
  69428. * ```javascript
  69429. * DracoCompression.Configuration = {
  69430. * decoder: {
  69431. * wasmUrl: "<url to the WebAssembly library>",
  69432. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69433. * fallbackUrl: "<url to the fallback JavaScript library>",
  69434. * }
  69435. * };
  69436. * ```
  69437. *
  69438. * 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.
  69439. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69440. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69441. *
  69442. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69443. * ```javascript
  69444. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69445. * ```
  69446. *
  69447. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69448. */
  69449. export class DracoCompression implements IDisposable {
  69450. private _workerPoolPromise?;
  69451. private _decoderModulePromise?;
  69452. /**
  69453. * The configuration. Defaults to the following urls:
  69454. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69455. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69456. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69457. */
  69458. static Configuration: IDracoCompressionConfiguration;
  69459. /**
  69460. * Returns true if the decoder configuration is available.
  69461. */
  69462. static get DecoderAvailable(): boolean;
  69463. /**
  69464. * Default number of workers to create when creating the draco compression object.
  69465. */
  69466. static DefaultNumWorkers: number;
  69467. private static GetDefaultNumWorkers;
  69468. private static _Default;
  69469. /**
  69470. * Default instance for the draco compression object.
  69471. */
  69472. static get Default(): DracoCompression;
  69473. /**
  69474. * Constructor
  69475. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69476. */
  69477. constructor(numWorkers?: number);
  69478. /**
  69479. * Stop all async operations and release resources.
  69480. */
  69481. dispose(): void;
  69482. /**
  69483. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69484. * @returns a promise that resolves when ready
  69485. */
  69486. whenReadyAsync(): Promise<void>;
  69487. /**
  69488. * Decode Draco compressed mesh data to vertex data.
  69489. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69490. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69491. * @returns A promise that resolves with the decoded vertex data
  69492. */
  69493. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69494. [kind: string]: number;
  69495. }): Promise<VertexData>;
  69496. }
  69497. }
  69498. declare module BABYLON {
  69499. /**
  69500. * Class for building Constructive Solid Geometry
  69501. */
  69502. export class CSG {
  69503. private polygons;
  69504. /**
  69505. * The world matrix
  69506. */
  69507. matrix: Matrix;
  69508. /**
  69509. * Stores the position
  69510. */
  69511. position: Vector3;
  69512. /**
  69513. * Stores the rotation
  69514. */
  69515. rotation: Vector3;
  69516. /**
  69517. * Stores the rotation quaternion
  69518. */
  69519. rotationQuaternion: Nullable<Quaternion>;
  69520. /**
  69521. * Stores the scaling vector
  69522. */
  69523. scaling: Vector3;
  69524. /**
  69525. * Convert the Mesh to CSG
  69526. * @param mesh The Mesh to convert to CSG
  69527. * @returns A new CSG from the Mesh
  69528. */
  69529. static FromMesh(mesh: Mesh): CSG;
  69530. /**
  69531. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69532. * @param polygons Polygons used to construct a CSG solid
  69533. */
  69534. private static FromPolygons;
  69535. /**
  69536. * Clones, or makes a deep copy, of the CSG
  69537. * @returns A new CSG
  69538. */
  69539. clone(): CSG;
  69540. /**
  69541. * Unions this CSG with another CSG
  69542. * @param csg The CSG to union against this CSG
  69543. * @returns The unioned CSG
  69544. */
  69545. union(csg: CSG): CSG;
  69546. /**
  69547. * Unions this CSG with another CSG in place
  69548. * @param csg The CSG to union against this CSG
  69549. */
  69550. unionInPlace(csg: CSG): void;
  69551. /**
  69552. * Subtracts this CSG with another CSG
  69553. * @param csg The CSG to subtract against this CSG
  69554. * @returns A new CSG
  69555. */
  69556. subtract(csg: CSG): CSG;
  69557. /**
  69558. * Subtracts this CSG with another CSG in place
  69559. * @param csg The CSG to subtact against this CSG
  69560. */
  69561. subtractInPlace(csg: CSG): void;
  69562. /**
  69563. * Intersect this CSG with another CSG
  69564. * @param csg The CSG to intersect against this CSG
  69565. * @returns A new CSG
  69566. */
  69567. intersect(csg: CSG): CSG;
  69568. /**
  69569. * Intersects this CSG with another CSG in place
  69570. * @param csg The CSG to intersect against this CSG
  69571. */
  69572. intersectInPlace(csg: CSG): void;
  69573. /**
  69574. * Return a new CSG solid with solid and empty space switched. This solid is
  69575. * not modified.
  69576. * @returns A new CSG solid with solid and empty space switched
  69577. */
  69578. inverse(): CSG;
  69579. /**
  69580. * Inverses the CSG in place
  69581. */
  69582. inverseInPlace(): void;
  69583. /**
  69584. * This is used to keep meshes transformations so they can be restored
  69585. * when we build back a Babylon Mesh
  69586. * NB : All CSG operations are performed in world coordinates
  69587. * @param csg The CSG to copy the transform attributes from
  69588. * @returns This CSG
  69589. */
  69590. copyTransformAttributes(csg: CSG): CSG;
  69591. /**
  69592. * Build Raw mesh from CSG
  69593. * Coordinates here are in world space
  69594. * @param name The name of the mesh geometry
  69595. * @param scene The Scene
  69596. * @param keepSubMeshes Specifies if the submeshes should be kept
  69597. * @returns A new Mesh
  69598. */
  69599. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69600. /**
  69601. * Build Mesh from CSG taking material and transforms into account
  69602. * @param name The name of the Mesh
  69603. * @param material The material of the Mesh
  69604. * @param scene The Scene
  69605. * @param keepSubMeshes Specifies if submeshes should be kept
  69606. * @returns The new Mesh
  69607. */
  69608. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69609. }
  69610. }
  69611. declare module BABYLON {
  69612. /**
  69613. * Class used to create a trail following a mesh
  69614. */
  69615. export class TrailMesh extends Mesh {
  69616. private _generator;
  69617. private _autoStart;
  69618. private _running;
  69619. private _diameter;
  69620. private _length;
  69621. private _sectionPolygonPointsCount;
  69622. private _sectionVectors;
  69623. private _sectionNormalVectors;
  69624. private _beforeRenderObserver;
  69625. /**
  69626. * @constructor
  69627. * @param name The value used by scene.getMeshByName() to do a lookup.
  69628. * @param generator The mesh or transform node to generate a trail.
  69629. * @param scene The scene to add this mesh to.
  69630. * @param diameter Diameter of trailing mesh. Default is 1.
  69631. * @param length Length of trailing mesh. Default is 60.
  69632. * @param autoStart Automatically start trailing mesh. Default true.
  69633. */
  69634. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69635. /**
  69636. * "TrailMesh"
  69637. * @returns "TrailMesh"
  69638. */
  69639. getClassName(): string;
  69640. private _createMesh;
  69641. /**
  69642. * Start trailing mesh.
  69643. */
  69644. start(): void;
  69645. /**
  69646. * Stop trailing mesh.
  69647. */
  69648. stop(): void;
  69649. /**
  69650. * Update trailing mesh geometry.
  69651. */
  69652. update(): void;
  69653. /**
  69654. * Returns a new TrailMesh object.
  69655. * @param name is a string, the name given to the new mesh
  69656. * @param newGenerator use new generator object for cloned trail mesh
  69657. * @returns a new mesh
  69658. */
  69659. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69660. /**
  69661. * Serializes this trail mesh
  69662. * @param serializationObject object to write serialization to
  69663. */
  69664. serialize(serializationObject: any): void;
  69665. /**
  69666. * Parses a serialized trail mesh
  69667. * @param parsedMesh the serialized mesh
  69668. * @param scene the scene to create the trail mesh in
  69669. * @returns the created trail mesh
  69670. */
  69671. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69672. }
  69673. }
  69674. declare module BABYLON {
  69675. /**
  69676. * Class containing static functions to help procedurally build meshes
  69677. */
  69678. export class TiledBoxBuilder {
  69679. /**
  69680. * Creates a box mesh
  69681. * 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)
  69682. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69684. * * 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
  69685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69686. * @param name defines the name of the mesh
  69687. * @param options defines the options used to create the mesh
  69688. * @param scene defines the hosting scene
  69689. * @returns the box mesh
  69690. */
  69691. static CreateTiledBox(name: string, options: {
  69692. pattern?: number;
  69693. width?: number;
  69694. height?: number;
  69695. depth?: number;
  69696. tileSize?: number;
  69697. tileWidth?: number;
  69698. tileHeight?: number;
  69699. alignHorizontal?: number;
  69700. alignVertical?: number;
  69701. faceUV?: Vector4[];
  69702. faceColors?: Color4[];
  69703. sideOrientation?: number;
  69704. updatable?: boolean;
  69705. }, scene?: Nullable<Scene>): Mesh;
  69706. }
  69707. }
  69708. declare module BABYLON {
  69709. /**
  69710. * Class containing static functions to help procedurally build meshes
  69711. */
  69712. export class TorusKnotBuilder {
  69713. /**
  69714. * Creates a torus knot mesh
  69715. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69716. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69717. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69718. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69720. * * 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
  69721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69722. * @param name defines the name of the mesh
  69723. * @param options defines the options used to create the mesh
  69724. * @param scene defines the hosting scene
  69725. * @returns the torus knot mesh
  69726. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69727. */
  69728. static CreateTorusKnot(name: string, options: {
  69729. radius?: number;
  69730. tube?: number;
  69731. radialSegments?: number;
  69732. tubularSegments?: number;
  69733. p?: number;
  69734. q?: number;
  69735. updatable?: boolean;
  69736. sideOrientation?: number;
  69737. frontUVs?: Vector4;
  69738. backUVs?: Vector4;
  69739. }, scene: any): Mesh;
  69740. }
  69741. }
  69742. declare module BABYLON {
  69743. /**
  69744. * Polygon
  69745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69746. */
  69747. export class Polygon {
  69748. /**
  69749. * Creates a rectangle
  69750. * @param xmin bottom X coord
  69751. * @param ymin bottom Y coord
  69752. * @param xmax top X coord
  69753. * @param ymax top Y coord
  69754. * @returns points that make the resulting rectation
  69755. */
  69756. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69757. /**
  69758. * Creates a circle
  69759. * @param radius radius of circle
  69760. * @param cx scale in x
  69761. * @param cy scale in y
  69762. * @param numberOfSides number of sides that make up the circle
  69763. * @returns points that make the resulting circle
  69764. */
  69765. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69766. /**
  69767. * Creates a polygon from input string
  69768. * @param input Input polygon data
  69769. * @returns the parsed points
  69770. */
  69771. static Parse(input: string): Vector2[];
  69772. /**
  69773. * Starts building a polygon from x and y coordinates
  69774. * @param x x coordinate
  69775. * @param y y coordinate
  69776. * @returns the started path2
  69777. */
  69778. static StartingAt(x: number, y: number): Path2;
  69779. }
  69780. /**
  69781. * Builds a polygon
  69782. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69783. */
  69784. export class PolygonMeshBuilder {
  69785. private _points;
  69786. private _outlinepoints;
  69787. private _holes;
  69788. private _name;
  69789. private _scene;
  69790. private _epoints;
  69791. private _eholes;
  69792. private _addToepoint;
  69793. /**
  69794. * Babylon reference to the earcut plugin.
  69795. */
  69796. bjsEarcut: any;
  69797. /**
  69798. * Creates a PolygonMeshBuilder
  69799. * @param name name of the builder
  69800. * @param contours Path of the polygon
  69801. * @param scene scene to add to when creating the mesh
  69802. * @param earcutInjection can be used to inject your own earcut reference
  69803. */
  69804. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69805. /**
  69806. * Adds a hole within the polygon
  69807. * @param hole Array of points defining the hole
  69808. * @returns this
  69809. */
  69810. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69811. /**
  69812. * Creates the polygon
  69813. * @param updatable If the mesh should be updatable
  69814. * @param depth The depth of the mesh created
  69815. * @param smoothingThreshold Dot product threshold for smoothed normals
  69816. * @returns the created mesh
  69817. */
  69818. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  69819. /**
  69820. * Creates the polygon
  69821. * @param depth The depth of the mesh created
  69822. * @param smoothingThreshold Dot product threshold for smoothed normals
  69823. * @returns the created VertexData
  69824. */
  69825. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  69826. /**
  69827. * Adds a side to the polygon
  69828. * @param positions points that make the polygon
  69829. * @param normals normals of the polygon
  69830. * @param uvs uvs of the polygon
  69831. * @param indices indices of the polygon
  69832. * @param bounds bounds of the polygon
  69833. * @param points points of the polygon
  69834. * @param depth depth of the polygon
  69835. * @param flip flip of the polygon
  69836. */
  69837. private addSide;
  69838. }
  69839. }
  69840. declare module BABYLON {
  69841. /**
  69842. * Class containing static functions to help procedurally build meshes
  69843. */
  69844. export class PolygonBuilder {
  69845. /**
  69846. * Creates a polygon mesh
  69847. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69848. * * 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
  69849. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69851. * * 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)
  69852. * * Remember you can only change the shape positions, not their number when updating a polygon
  69853. * @param name defines the name of the mesh
  69854. * @param options defines the options used to create the mesh
  69855. * @param scene defines the hosting scene
  69856. * @param earcutInjection can be used to inject your own earcut reference
  69857. * @returns the polygon mesh
  69858. */
  69859. static CreatePolygon(name: string, options: {
  69860. shape: Vector3[];
  69861. holes?: Vector3[][];
  69862. depth?: number;
  69863. smoothingThreshold?: number;
  69864. faceUV?: Vector4[];
  69865. faceColors?: Color4[];
  69866. updatable?: boolean;
  69867. sideOrientation?: number;
  69868. frontUVs?: Vector4;
  69869. backUVs?: Vector4;
  69870. wrap?: boolean;
  69871. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69872. /**
  69873. * Creates an extruded polygon mesh, with depth in the Y direction.
  69874. * * 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)
  69875. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69876. * @param name defines the name of the mesh
  69877. * @param options defines the options used to create the mesh
  69878. * @param scene defines the hosting scene
  69879. * @param earcutInjection can be used to inject your own earcut reference
  69880. * @returns the polygon mesh
  69881. */
  69882. static ExtrudePolygon(name: string, options: {
  69883. shape: Vector3[];
  69884. holes?: Vector3[][];
  69885. depth?: number;
  69886. faceUV?: Vector4[];
  69887. faceColors?: Color4[];
  69888. updatable?: boolean;
  69889. sideOrientation?: number;
  69890. frontUVs?: Vector4;
  69891. backUVs?: Vector4;
  69892. wrap?: boolean;
  69893. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69894. }
  69895. }
  69896. declare module BABYLON {
  69897. /**
  69898. * Class containing static functions to help procedurally build meshes
  69899. */
  69900. export class LatheBuilder {
  69901. /**
  69902. * Creates lathe mesh.
  69903. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69904. * * 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
  69905. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69906. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69907. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69908. * * 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
  69909. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69910. * * 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
  69911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69912. * * 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
  69913. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69915. * @param name defines the name of the mesh
  69916. * @param options defines the options used to create the mesh
  69917. * @param scene defines the hosting scene
  69918. * @returns the lathe mesh
  69919. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69920. */
  69921. static CreateLathe(name: string, options: {
  69922. shape: Vector3[];
  69923. radius?: number;
  69924. tessellation?: number;
  69925. clip?: number;
  69926. arc?: number;
  69927. closed?: boolean;
  69928. updatable?: boolean;
  69929. sideOrientation?: number;
  69930. frontUVs?: Vector4;
  69931. backUVs?: Vector4;
  69932. cap?: number;
  69933. invertUV?: boolean;
  69934. }, scene?: Nullable<Scene>): Mesh;
  69935. }
  69936. }
  69937. declare module BABYLON {
  69938. /**
  69939. * Class containing static functions to help procedurally build meshes
  69940. */
  69941. export class TiledPlaneBuilder {
  69942. /**
  69943. * Creates a tiled plane mesh
  69944. * * The parameter `pattern` will, depending on value, do nothing or
  69945. * * * flip (reflect about central vertical) alternate tiles across and up
  69946. * * * flip every tile on alternate rows
  69947. * * * rotate (180 degs) alternate tiles across and up
  69948. * * * rotate every tile on alternate rows
  69949. * * * flip and rotate alternate tiles across and up
  69950. * * * flip and rotate every tile on alternate rows
  69951. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69952. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69953. * * 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
  69954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69955. * * 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)
  69956. * * 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)
  69957. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69958. * @param name defines the name of the mesh
  69959. * @param options defines the options used to create the mesh
  69960. * @param scene defines the hosting scene
  69961. * @returns the box mesh
  69962. */
  69963. static CreateTiledPlane(name: string, options: {
  69964. pattern?: number;
  69965. tileSize?: number;
  69966. tileWidth?: number;
  69967. tileHeight?: number;
  69968. size?: number;
  69969. width?: number;
  69970. height?: number;
  69971. alignHorizontal?: number;
  69972. alignVertical?: number;
  69973. sideOrientation?: number;
  69974. frontUVs?: Vector4;
  69975. backUVs?: Vector4;
  69976. updatable?: boolean;
  69977. }, scene?: Nullable<Scene>): Mesh;
  69978. }
  69979. }
  69980. declare module BABYLON {
  69981. /**
  69982. * Class containing static functions to help procedurally build meshes
  69983. */
  69984. export class TubeBuilder {
  69985. /**
  69986. * Creates a tube mesh.
  69987. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69988. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69989. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69990. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69991. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69992. * * 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)
  69993. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69994. * * 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
  69995. * * 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
  69996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69997. * * 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
  69998. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70000. * @param name defines the name of the mesh
  70001. * @param options defines the options used to create the mesh
  70002. * @param scene defines the hosting scene
  70003. * @returns the tube mesh
  70004. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70005. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70006. */
  70007. static CreateTube(name: string, options: {
  70008. path: Vector3[];
  70009. radius?: number;
  70010. tessellation?: number;
  70011. radiusFunction?: {
  70012. (i: number, distance: number): number;
  70013. };
  70014. cap?: number;
  70015. arc?: number;
  70016. updatable?: boolean;
  70017. sideOrientation?: number;
  70018. frontUVs?: Vector4;
  70019. backUVs?: Vector4;
  70020. instance?: Mesh;
  70021. invertUV?: boolean;
  70022. }, scene?: Nullable<Scene>): Mesh;
  70023. }
  70024. }
  70025. declare module BABYLON {
  70026. /**
  70027. * Class containing static functions to help procedurally build meshes
  70028. */
  70029. export class IcoSphereBuilder {
  70030. /**
  70031. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70032. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70033. * * 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`)
  70034. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70035. * * 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
  70036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70037. * * 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
  70038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70039. * @param name defines the name of the mesh
  70040. * @param options defines the options used to create the mesh
  70041. * @param scene defines the hosting scene
  70042. * @returns the icosahedron mesh
  70043. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70044. */
  70045. static CreateIcoSphere(name: string, options: {
  70046. radius?: number;
  70047. radiusX?: number;
  70048. radiusY?: number;
  70049. radiusZ?: number;
  70050. flat?: boolean;
  70051. subdivisions?: number;
  70052. sideOrientation?: number;
  70053. frontUVs?: Vector4;
  70054. backUVs?: Vector4;
  70055. updatable?: boolean;
  70056. }, scene?: Nullable<Scene>): Mesh;
  70057. }
  70058. }
  70059. declare module BABYLON {
  70060. /**
  70061. * Class containing static functions to help procedurally build meshes
  70062. */
  70063. export class DecalBuilder {
  70064. /**
  70065. * Creates a decal mesh.
  70066. * 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
  70067. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70068. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70069. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70070. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70071. * @param name defines the name of the mesh
  70072. * @param sourceMesh defines the mesh where the decal must be applied
  70073. * @param options defines the options used to create the mesh
  70074. * @param scene defines the hosting scene
  70075. * @returns the decal mesh
  70076. * @see https://doc.babylonjs.com/how_to/decals
  70077. */
  70078. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70079. position?: Vector3;
  70080. normal?: Vector3;
  70081. size?: Vector3;
  70082. angle?: number;
  70083. }): Mesh;
  70084. }
  70085. }
  70086. declare module BABYLON {
  70087. /**
  70088. * Class containing static functions to help procedurally build meshes
  70089. */
  70090. export class MeshBuilder {
  70091. /**
  70092. * Creates a box mesh
  70093. * * The parameter `size` sets the size (float) of each box side (default 1)
  70094. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70095. * * 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)
  70096. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70098. * * 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
  70099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70100. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70101. * @param name defines the name of the mesh
  70102. * @param options defines the options used to create the mesh
  70103. * @param scene defines the hosting scene
  70104. * @returns the box mesh
  70105. */
  70106. static CreateBox(name: string, options: {
  70107. size?: number;
  70108. width?: number;
  70109. height?: number;
  70110. depth?: number;
  70111. faceUV?: Vector4[];
  70112. faceColors?: Color4[];
  70113. sideOrientation?: number;
  70114. frontUVs?: Vector4;
  70115. backUVs?: Vector4;
  70116. wrap?: boolean;
  70117. topBaseAt?: number;
  70118. bottomBaseAt?: number;
  70119. updatable?: boolean;
  70120. }, scene?: Nullable<Scene>): Mesh;
  70121. /**
  70122. * Creates a tiled box mesh
  70123. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70125. * @param name defines the name of the mesh
  70126. * @param options defines the options used to create the mesh
  70127. * @param scene defines the hosting scene
  70128. * @returns the tiled box mesh
  70129. */
  70130. static CreateTiledBox(name: string, options: {
  70131. pattern?: number;
  70132. size?: number;
  70133. width?: number;
  70134. height?: number;
  70135. depth: number;
  70136. tileSize?: number;
  70137. tileWidth?: number;
  70138. tileHeight?: number;
  70139. faceUV?: Vector4[];
  70140. faceColors?: Color4[];
  70141. alignHorizontal?: number;
  70142. alignVertical?: number;
  70143. sideOrientation?: number;
  70144. updatable?: boolean;
  70145. }, scene?: Nullable<Scene>): Mesh;
  70146. /**
  70147. * Creates a sphere mesh
  70148. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70149. * * 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`)
  70150. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70151. * * 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
  70152. * * 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)
  70153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70154. * * 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
  70155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70156. * @param name defines the name of the mesh
  70157. * @param options defines the options used to create the mesh
  70158. * @param scene defines the hosting scene
  70159. * @returns the sphere mesh
  70160. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70161. */
  70162. static CreateSphere(name: string, options: {
  70163. segments?: number;
  70164. diameter?: number;
  70165. diameterX?: number;
  70166. diameterY?: number;
  70167. diameterZ?: number;
  70168. arc?: number;
  70169. slice?: number;
  70170. sideOrientation?: number;
  70171. frontUVs?: Vector4;
  70172. backUVs?: Vector4;
  70173. updatable?: boolean;
  70174. }, scene?: Nullable<Scene>): Mesh;
  70175. /**
  70176. * Creates a plane polygonal mesh. By default, this is a disc
  70177. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70178. * * 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
  70179. * * 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
  70180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70181. * * 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
  70182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70183. * @param name defines the name of the mesh
  70184. * @param options defines the options used to create the mesh
  70185. * @param scene defines the hosting scene
  70186. * @returns the plane polygonal mesh
  70187. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70188. */
  70189. static CreateDisc(name: string, options: {
  70190. radius?: number;
  70191. tessellation?: number;
  70192. arc?: number;
  70193. updatable?: boolean;
  70194. sideOrientation?: number;
  70195. frontUVs?: Vector4;
  70196. backUVs?: Vector4;
  70197. }, scene?: Nullable<Scene>): Mesh;
  70198. /**
  70199. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70200. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70201. * * 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`)
  70202. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70203. * * 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
  70204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70207. * @param name defines the name of the mesh
  70208. * @param options defines the options used to create the mesh
  70209. * @param scene defines the hosting scene
  70210. * @returns the icosahedron mesh
  70211. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70212. */
  70213. static CreateIcoSphere(name: string, options: {
  70214. radius?: number;
  70215. radiusX?: number;
  70216. radiusY?: number;
  70217. radiusZ?: number;
  70218. flat?: boolean;
  70219. subdivisions?: number;
  70220. sideOrientation?: number;
  70221. frontUVs?: Vector4;
  70222. backUVs?: Vector4;
  70223. updatable?: boolean;
  70224. }, scene?: Nullable<Scene>): Mesh;
  70225. /**
  70226. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70227. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70228. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70229. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70230. * * 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
  70231. * * 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
  70232. * * 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
  70233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70234. * * 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
  70235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70236. * * 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
  70237. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70238. * * 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
  70239. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70241. * @param name defines the name of the mesh
  70242. * @param options defines the options used to create the mesh
  70243. * @param scene defines the hosting scene
  70244. * @returns the ribbon mesh
  70245. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70246. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70247. */
  70248. static CreateRibbon(name: string, options: {
  70249. pathArray: Vector3[][];
  70250. closeArray?: boolean;
  70251. closePath?: boolean;
  70252. offset?: number;
  70253. updatable?: boolean;
  70254. sideOrientation?: number;
  70255. frontUVs?: Vector4;
  70256. backUVs?: Vector4;
  70257. instance?: Mesh;
  70258. invertUV?: boolean;
  70259. uvs?: Vector2[];
  70260. colors?: Color4[];
  70261. }, scene?: Nullable<Scene>): Mesh;
  70262. /**
  70263. * Creates a cylinder or a cone mesh
  70264. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70265. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70266. * * 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.
  70267. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70268. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70269. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70270. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70271. * * 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).
  70272. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70273. * * 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).
  70274. * * 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
  70275. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70276. * * 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
  70277. * * 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.
  70278. * * If `enclose` is false, a ring surface is one element.
  70279. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70280. * * 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
  70281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70282. * * 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
  70283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70284. * @param name defines the name of the mesh
  70285. * @param options defines the options used to create the mesh
  70286. * @param scene defines the hosting scene
  70287. * @returns the cylinder mesh
  70288. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70289. */
  70290. static CreateCylinder(name: string, options: {
  70291. height?: number;
  70292. diameterTop?: number;
  70293. diameterBottom?: number;
  70294. diameter?: number;
  70295. tessellation?: number;
  70296. subdivisions?: number;
  70297. arc?: number;
  70298. faceColors?: Color4[];
  70299. faceUV?: Vector4[];
  70300. updatable?: boolean;
  70301. hasRings?: boolean;
  70302. enclose?: boolean;
  70303. cap?: number;
  70304. sideOrientation?: number;
  70305. frontUVs?: Vector4;
  70306. backUVs?: Vector4;
  70307. }, scene?: Nullable<Scene>): Mesh;
  70308. /**
  70309. * Creates a torus mesh
  70310. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70311. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70312. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70314. * * 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
  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. * @param name defines the name of the mesh
  70317. * @param options defines the options used to create the mesh
  70318. * @param scene defines the hosting scene
  70319. * @returns the torus mesh
  70320. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70321. */
  70322. static CreateTorus(name: string, options: {
  70323. diameter?: number;
  70324. thickness?: number;
  70325. tessellation?: number;
  70326. updatable?: boolean;
  70327. sideOrientation?: number;
  70328. frontUVs?: Vector4;
  70329. backUVs?: Vector4;
  70330. }, scene?: Nullable<Scene>): Mesh;
  70331. /**
  70332. * Creates a torus knot mesh
  70333. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70334. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70335. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70336. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70340. * @param name defines the name of the mesh
  70341. * @param options defines the options used to create the mesh
  70342. * @param scene defines the hosting scene
  70343. * @returns the torus knot mesh
  70344. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70345. */
  70346. static CreateTorusKnot(name: string, options: {
  70347. radius?: number;
  70348. tube?: number;
  70349. radialSegments?: number;
  70350. tubularSegments?: number;
  70351. p?: number;
  70352. q?: number;
  70353. updatable?: boolean;
  70354. sideOrientation?: number;
  70355. frontUVs?: Vector4;
  70356. backUVs?: Vector4;
  70357. }, scene?: Nullable<Scene>): Mesh;
  70358. /**
  70359. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70360. * * 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
  70361. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70362. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70363. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70364. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70365. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70366. * * 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
  70367. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70370. * @param name defines the name of the new line system
  70371. * @param options defines the options used to create the line system
  70372. * @param scene defines the hosting scene
  70373. * @returns a new line system mesh
  70374. */
  70375. static CreateLineSystem(name: string, options: {
  70376. lines: Vector3[][];
  70377. updatable?: boolean;
  70378. instance?: Nullable<LinesMesh>;
  70379. colors?: Nullable<Color4[][]>;
  70380. useVertexAlpha?: boolean;
  70381. }, scene: Nullable<Scene>): LinesMesh;
  70382. /**
  70383. * Creates a line mesh
  70384. * 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
  70385. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70386. * * The parameter `points` is an array successive Vector3
  70387. * * 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
  70388. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70389. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70390. * * When updating an instance, remember that only point positions can change, not the number of points
  70391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70393. * @param name defines the name of the new line system
  70394. * @param options defines the options used to create the line system
  70395. * @param scene defines the hosting scene
  70396. * @returns a new line mesh
  70397. */
  70398. static CreateLines(name: string, options: {
  70399. points: Vector3[];
  70400. updatable?: boolean;
  70401. instance?: Nullable<LinesMesh>;
  70402. colors?: Color4[];
  70403. useVertexAlpha?: boolean;
  70404. }, scene?: Nullable<Scene>): LinesMesh;
  70405. /**
  70406. * Creates a dashed line mesh
  70407. * * 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
  70408. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70409. * * The parameter `points` is an array successive Vector3
  70410. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70411. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70412. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70413. * * 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
  70414. * * When updating an instance, remember that only point positions can change, not the number of points
  70415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70416. * @param name defines the name of the mesh
  70417. * @param options defines the options used to create the mesh
  70418. * @param scene defines the hosting scene
  70419. * @returns the dashed line mesh
  70420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70421. */
  70422. static CreateDashedLines(name: string, options: {
  70423. points: Vector3[];
  70424. dashSize?: number;
  70425. gapSize?: number;
  70426. dashNb?: number;
  70427. updatable?: boolean;
  70428. instance?: LinesMesh;
  70429. }, scene?: Nullable<Scene>): LinesMesh;
  70430. /**
  70431. * 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.
  70432. * * 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.
  70433. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70434. * * 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.
  70435. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70436. * * 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
  70437. * * 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
  70438. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70440. * * 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
  70441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70443. * @param name defines the name of the mesh
  70444. * @param options defines the options used to create the mesh
  70445. * @param scene defines the hosting scene
  70446. * @returns the extruded shape mesh
  70447. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70448. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70449. */
  70450. static ExtrudeShape(name: string, options: {
  70451. shape: Vector3[];
  70452. path: Vector3[];
  70453. scale?: number;
  70454. rotation?: number;
  70455. cap?: number;
  70456. updatable?: boolean;
  70457. sideOrientation?: number;
  70458. frontUVs?: Vector4;
  70459. backUVs?: Vector4;
  70460. instance?: Mesh;
  70461. invertUV?: boolean;
  70462. }, scene?: Nullable<Scene>): Mesh;
  70463. /**
  70464. * Creates an custom extruded shape mesh.
  70465. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70466. * * 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.
  70467. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70468. * * 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
  70469. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70470. * * 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
  70471. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70472. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70473. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70474. * * 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
  70475. * * 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
  70476. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70478. * * 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
  70479. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70481. * @param name defines the name of the mesh
  70482. * @param options defines the options used to create the mesh
  70483. * @param scene defines the hosting scene
  70484. * @returns the custom extruded shape mesh
  70485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70486. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70488. */
  70489. static ExtrudeShapeCustom(name: string, options: {
  70490. shape: Vector3[];
  70491. path: Vector3[];
  70492. scaleFunction?: any;
  70493. rotationFunction?: any;
  70494. ribbonCloseArray?: boolean;
  70495. ribbonClosePath?: boolean;
  70496. cap?: number;
  70497. updatable?: boolean;
  70498. sideOrientation?: number;
  70499. frontUVs?: Vector4;
  70500. backUVs?: Vector4;
  70501. instance?: Mesh;
  70502. invertUV?: boolean;
  70503. }, scene?: Nullable<Scene>): Mesh;
  70504. /**
  70505. * Creates lathe mesh.
  70506. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70507. * * 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
  70508. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70509. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70510. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70511. * * 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
  70512. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70513. * * 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
  70514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70515. * * 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
  70516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 lathe mesh
  70522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70523. */
  70524. static CreateLathe(name: string, options: {
  70525. shape: Vector3[];
  70526. radius?: number;
  70527. tessellation?: number;
  70528. clip?: number;
  70529. arc?: number;
  70530. closed?: boolean;
  70531. updatable?: boolean;
  70532. sideOrientation?: number;
  70533. frontUVs?: Vector4;
  70534. backUVs?: Vector4;
  70535. cap?: number;
  70536. invertUV?: boolean;
  70537. }, scene?: Nullable<Scene>): Mesh;
  70538. /**
  70539. * Creates a tiled plane mesh
  70540. * * You can set a limited pattern arrangement with the tiles
  70541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70542. * * 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
  70543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70544. * @param name defines the name of the mesh
  70545. * @param options defines the options used to create the mesh
  70546. * @param scene defines the hosting scene
  70547. * @returns the plane mesh
  70548. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70549. */
  70550. static CreateTiledPlane(name: string, options: {
  70551. pattern?: number;
  70552. tileSize?: number;
  70553. tileWidth?: number;
  70554. tileHeight?: number;
  70555. size?: number;
  70556. width?: number;
  70557. height?: number;
  70558. alignHorizontal?: number;
  70559. alignVertical?: number;
  70560. sideOrientation?: number;
  70561. frontUVs?: Vector4;
  70562. backUVs?: Vector4;
  70563. updatable?: boolean;
  70564. }, scene?: Nullable<Scene>): Mesh;
  70565. /**
  70566. * Creates a plane mesh
  70567. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70568. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70569. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70571. * * 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
  70572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70573. * @param name defines the name of the mesh
  70574. * @param options defines the options used to create the mesh
  70575. * @param scene defines the hosting scene
  70576. * @returns the plane mesh
  70577. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70578. */
  70579. static CreatePlane(name: string, options: {
  70580. size?: number;
  70581. width?: number;
  70582. height?: number;
  70583. sideOrientation?: number;
  70584. frontUVs?: Vector4;
  70585. backUVs?: Vector4;
  70586. updatable?: boolean;
  70587. sourcePlane?: Plane;
  70588. }, scene?: Nullable<Scene>): Mesh;
  70589. /**
  70590. * Creates a ground mesh
  70591. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70592. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70594. * @param name defines the name of the mesh
  70595. * @param options defines the options used to create the mesh
  70596. * @param scene defines the hosting scene
  70597. * @returns the ground mesh
  70598. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70599. */
  70600. static CreateGround(name: string, options: {
  70601. width?: number;
  70602. height?: number;
  70603. subdivisions?: number;
  70604. subdivisionsX?: number;
  70605. subdivisionsY?: number;
  70606. updatable?: boolean;
  70607. }, scene?: Nullable<Scene>): Mesh;
  70608. /**
  70609. * Creates a tiled ground mesh
  70610. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70611. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70612. * * 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
  70613. * * 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
  70614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70615. * @param name defines the name of the mesh
  70616. * @param options defines the options used to create the mesh
  70617. * @param scene defines the hosting scene
  70618. * @returns the tiled ground mesh
  70619. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70620. */
  70621. static CreateTiledGround(name: string, options: {
  70622. xmin: number;
  70623. zmin: number;
  70624. xmax: number;
  70625. zmax: number;
  70626. subdivisions?: {
  70627. w: number;
  70628. h: number;
  70629. };
  70630. precision?: {
  70631. w: number;
  70632. h: number;
  70633. };
  70634. updatable?: boolean;
  70635. }, scene?: Nullable<Scene>): Mesh;
  70636. /**
  70637. * Creates a ground mesh from a height map
  70638. * * The parameter `url` sets the URL of the height map image resource.
  70639. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70640. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70641. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70642. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70643. * * 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.
  70644. * * 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).
  70645. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70647. * @param name defines the name of the mesh
  70648. * @param url defines the url to the height map
  70649. * @param options defines the options used to create the mesh
  70650. * @param scene defines the hosting scene
  70651. * @returns the ground mesh
  70652. * @see https://doc.babylonjs.com/babylon101/height_map
  70653. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70654. */
  70655. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70656. width?: number;
  70657. height?: number;
  70658. subdivisions?: number;
  70659. minHeight?: number;
  70660. maxHeight?: number;
  70661. colorFilter?: Color3;
  70662. alphaFilter?: number;
  70663. updatable?: boolean;
  70664. onReady?: (mesh: GroundMesh) => void;
  70665. }, scene?: Nullable<Scene>): GroundMesh;
  70666. /**
  70667. * Creates a polygon mesh
  70668. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70669. * * 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
  70670. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70672. * * 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)
  70673. * * Remember you can only change the shape positions, not their number when updating a polygon
  70674. * @param name defines the name of the mesh
  70675. * @param options defines the options used to create the mesh
  70676. * @param scene defines the hosting scene
  70677. * @param earcutInjection can be used to inject your own earcut reference
  70678. * @returns the polygon mesh
  70679. */
  70680. static CreatePolygon(name: string, options: {
  70681. shape: Vector3[];
  70682. holes?: Vector3[][];
  70683. depth?: number;
  70684. faceUV?: Vector4[];
  70685. faceColors?: Color4[];
  70686. updatable?: boolean;
  70687. sideOrientation?: number;
  70688. frontUVs?: Vector4;
  70689. backUVs?: Vector4;
  70690. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70691. /**
  70692. * Creates an extruded polygon mesh, with depth in the Y direction.
  70693. * * 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)
  70694. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70695. * @param name defines the name of the mesh
  70696. * @param options defines the options used to create the mesh
  70697. * @param scene defines the hosting scene
  70698. * @param earcutInjection can be used to inject your own earcut reference
  70699. * @returns the polygon mesh
  70700. */
  70701. static ExtrudePolygon(name: string, options: {
  70702. shape: Vector3[];
  70703. holes?: Vector3[][];
  70704. depth?: number;
  70705. faceUV?: Vector4[];
  70706. faceColors?: Color4[];
  70707. updatable?: boolean;
  70708. sideOrientation?: number;
  70709. frontUVs?: Vector4;
  70710. backUVs?: Vector4;
  70711. wrap?: boolean;
  70712. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70713. /**
  70714. * Creates a tube mesh.
  70715. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70716. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70717. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70718. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70719. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70720. * * 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)
  70721. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70722. * * 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
  70723. * * 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
  70724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70725. * * 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
  70726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70728. * @param name defines the name of the mesh
  70729. * @param options defines the options used to create the mesh
  70730. * @param scene defines the hosting scene
  70731. * @returns the tube mesh
  70732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70733. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70734. */
  70735. static CreateTube(name: string, options: {
  70736. path: Vector3[];
  70737. radius?: number;
  70738. tessellation?: number;
  70739. radiusFunction?: {
  70740. (i: number, distance: number): number;
  70741. };
  70742. cap?: number;
  70743. arc?: number;
  70744. updatable?: boolean;
  70745. sideOrientation?: number;
  70746. frontUVs?: Vector4;
  70747. backUVs?: Vector4;
  70748. instance?: Mesh;
  70749. invertUV?: boolean;
  70750. }, scene?: Nullable<Scene>): Mesh;
  70751. /**
  70752. * Creates a polyhedron mesh
  70753. * * 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
  70754. * * The parameter `size` (positive float, default 1) sets the polygon size
  70755. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70756. * * 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`
  70757. * * 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
  70758. * * 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)`)
  70759. * * 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
  70760. * * 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
  70761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70762. * * 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
  70763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70764. * @param name defines the name of the mesh
  70765. * @param options defines the options used to create the mesh
  70766. * @param scene defines the hosting scene
  70767. * @returns the polyhedron mesh
  70768. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70769. */
  70770. static CreatePolyhedron(name: string, options: {
  70771. type?: number;
  70772. size?: number;
  70773. sizeX?: number;
  70774. sizeY?: number;
  70775. sizeZ?: number;
  70776. custom?: any;
  70777. faceUV?: Vector4[];
  70778. faceColors?: Color4[];
  70779. flat?: boolean;
  70780. updatable?: boolean;
  70781. sideOrientation?: number;
  70782. frontUVs?: Vector4;
  70783. backUVs?: Vector4;
  70784. }, scene?: Nullable<Scene>): Mesh;
  70785. /**
  70786. * Creates a decal mesh.
  70787. * 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
  70788. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70789. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70790. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70791. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70792. * @param name defines the name of the mesh
  70793. * @param sourceMesh defines the mesh where the decal must be applied
  70794. * @param options defines the options used to create the mesh
  70795. * @param scene defines the hosting scene
  70796. * @returns the decal mesh
  70797. * @see https://doc.babylonjs.com/how_to/decals
  70798. */
  70799. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70800. position?: Vector3;
  70801. normal?: Vector3;
  70802. size?: Vector3;
  70803. angle?: number;
  70804. }): Mesh;
  70805. /**
  70806. * Creates a Capsule Mesh
  70807. * @param name defines the name of the mesh.
  70808. * @param options the constructors options used to shape the mesh.
  70809. * @param scene defines the scene the mesh is scoped to.
  70810. * @returns the capsule mesh
  70811. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70812. */
  70813. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70814. }
  70815. }
  70816. declare module BABYLON {
  70817. /**
  70818. * A simplifier interface for future simplification implementations
  70819. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70820. */
  70821. export interface ISimplifier {
  70822. /**
  70823. * Simplification of a given mesh according to the given settings.
  70824. * Since this requires computation, it is assumed that the function runs async.
  70825. * @param settings The settings of the simplification, including quality and distance
  70826. * @param successCallback A callback that will be called after the mesh was simplified.
  70827. * @param errorCallback in case of an error, this callback will be called. optional.
  70828. */
  70829. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70830. }
  70831. /**
  70832. * Expected simplification settings.
  70833. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70834. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70835. */
  70836. export interface ISimplificationSettings {
  70837. /**
  70838. * Gets or sets the expected quality
  70839. */
  70840. quality: number;
  70841. /**
  70842. * Gets or sets the distance when this optimized version should be used
  70843. */
  70844. distance: number;
  70845. /**
  70846. * Gets an already optimized mesh
  70847. */
  70848. optimizeMesh?: boolean;
  70849. }
  70850. /**
  70851. * Class used to specify simplification options
  70852. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70853. */
  70854. export class SimplificationSettings implements ISimplificationSettings {
  70855. /** expected quality */
  70856. quality: number;
  70857. /** distance when this optimized version should be used */
  70858. distance: number;
  70859. /** already optimized mesh */
  70860. optimizeMesh?: boolean | undefined;
  70861. /**
  70862. * Creates a SimplificationSettings
  70863. * @param quality expected quality
  70864. * @param distance distance when this optimized version should be used
  70865. * @param optimizeMesh already optimized mesh
  70866. */
  70867. constructor(
  70868. /** expected quality */
  70869. quality: number,
  70870. /** distance when this optimized version should be used */
  70871. distance: number,
  70872. /** already optimized mesh */
  70873. optimizeMesh?: boolean | undefined);
  70874. }
  70875. /**
  70876. * Interface used to define a simplification task
  70877. */
  70878. export interface ISimplificationTask {
  70879. /**
  70880. * Array of settings
  70881. */
  70882. settings: Array<ISimplificationSettings>;
  70883. /**
  70884. * Simplification type
  70885. */
  70886. simplificationType: SimplificationType;
  70887. /**
  70888. * Mesh to simplify
  70889. */
  70890. mesh: Mesh;
  70891. /**
  70892. * Callback called on success
  70893. */
  70894. successCallback?: () => void;
  70895. /**
  70896. * Defines if parallel processing can be used
  70897. */
  70898. parallelProcessing: boolean;
  70899. }
  70900. /**
  70901. * Queue used to order the simplification tasks
  70902. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70903. */
  70904. export class SimplificationQueue {
  70905. private _simplificationArray;
  70906. /**
  70907. * Gets a boolean indicating that the process is still running
  70908. */
  70909. running: boolean;
  70910. /**
  70911. * Creates a new queue
  70912. */
  70913. constructor();
  70914. /**
  70915. * Adds a new simplification task
  70916. * @param task defines a task to add
  70917. */
  70918. addTask(task: ISimplificationTask): void;
  70919. /**
  70920. * Execute next task
  70921. */
  70922. executeNext(): void;
  70923. /**
  70924. * Execute a simplification task
  70925. * @param task defines the task to run
  70926. */
  70927. runSimplification(task: ISimplificationTask): void;
  70928. private getSimplifier;
  70929. }
  70930. /**
  70931. * The implemented types of simplification
  70932. * At the moment only Quadratic Error Decimation is implemented
  70933. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70934. */
  70935. export enum SimplificationType {
  70936. /** Quadratic error decimation */
  70937. QUADRATIC = 0
  70938. }
  70939. /**
  70940. * An implementation of the Quadratic Error simplification algorithm.
  70941. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70942. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70943. * @author RaananW
  70944. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70945. */
  70946. export class QuadraticErrorSimplification implements ISimplifier {
  70947. private _mesh;
  70948. private triangles;
  70949. private vertices;
  70950. private references;
  70951. private _reconstructedMesh;
  70952. /** Gets or sets the number pf sync interations */
  70953. syncIterations: number;
  70954. /** Gets or sets the aggressiveness of the simplifier */
  70955. aggressiveness: number;
  70956. /** Gets or sets the number of allowed iterations for decimation */
  70957. decimationIterations: number;
  70958. /** Gets or sets the espilon to use for bounding box computation */
  70959. boundingBoxEpsilon: number;
  70960. /**
  70961. * Creates a new QuadraticErrorSimplification
  70962. * @param _mesh defines the target mesh
  70963. */
  70964. constructor(_mesh: Mesh);
  70965. /**
  70966. * Simplification of a given mesh according to the given settings.
  70967. * Since this requires computation, it is assumed that the function runs async.
  70968. * @param settings The settings of the simplification, including quality and distance
  70969. * @param successCallback A callback that will be called after the mesh was simplified.
  70970. */
  70971. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70972. private runDecimation;
  70973. private initWithMesh;
  70974. private init;
  70975. private reconstructMesh;
  70976. private initDecimatedMesh;
  70977. private isFlipped;
  70978. private updateTriangles;
  70979. private identifyBorder;
  70980. private updateMesh;
  70981. private vertexError;
  70982. private calculateError;
  70983. }
  70984. }
  70985. declare module BABYLON {
  70986. interface Scene {
  70987. /** @hidden (Backing field) */
  70988. _simplificationQueue: SimplificationQueue;
  70989. /**
  70990. * Gets or sets the simplification queue attached to the scene
  70991. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70992. */
  70993. simplificationQueue: SimplificationQueue;
  70994. }
  70995. interface Mesh {
  70996. /**
  70997. * Simplify the mesh according to the given array of settings.
  70998. * Function will return immediately and will simplify async
  70999. * @param settings a collection of simplification settings
  71000. * @param parallelProcessing should all levels calculate parallel or one after the other
  71001. * @param simplificationType the type of simplification to run
  71002. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71003. * @returns the current mesh
  71004. */
  71005. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71006. }
  71007. /**
  71008. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71009. * created in a scene
  71010. */
  71011. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71012. /**
  71013. * The component name helpfull to identify the component in the list of scene components.
  71014. */
  71015. readonly name: string;
  71016. /**
  71017. * The scene the component belongs to.
  71018. */
  71019. scene: Scene;
  71020. /**
  71021. * Creates a new instance of the component for the given scene
  71022. * @param scene Defines the scene to register the component in
  71023. */
  71024. constructor(scene: Scene);
  71025. /**
  71026. * Registers the component in a given scene
  71027. */
  71028. register(): void;
  71029. /**
  71030. * Rebuilds the elements related to this component in case of
  71031. * context lost for instance.
  71032. */
  71033. rebuild(): void;
  71034. /**
  71035. * Disposes the component and the associated ressources
  71036. */
  71037. dispose(): void;
  71038. private _beforeCameraUpdate;
  71039. }
  71040. }
  71041. declare module BABYLON {
  71042. interface Mesh {
  71043. /**
  71044. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71045. */
  71046. thinInstanceEnablePicking: boolean;
  71047. /**
  71048. * Creates a new thin instance
  71049. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71050. * @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
  71051. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71052. */
  71053. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71054. /**
  71055. * Adds the transformation (matrix) of the current mesh as a thin instance
  71056. * @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
  71057. * @returns the thin instance index number
  71058. */
  71059. thinInstanceAddSelf(refresh: boolean): number;
  71060. /**
  71061. * Registers a custom attribute to be used with thin instances
  71062. * @param kind name of the attribute
  71063. * @param stride size in floats of the attribute
  71064. */
  71065. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71066. /**
  71067. * Sets the matrix of a thin instance
  71068. * @param index index of the thin instance
  71069. * @param matrix matrix to set
  71070. * @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
  71071. */
  71072. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71073. /**
  71074. * Sets the value of a custom attribute for a thin instance
  71075. * @param kind name of the attribute
  71076. * @param index index of the thin instance
  71077. * @param value value to set
  71078. * @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
  71079. */
  71080. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71081. /**
  71082. * 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.
  71083. */
  71084. thinInstanceCount: number;
  71085. /**
  71086. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71087. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71088. * @param buffer buffer to set
  71089. * @param stride size in floats of each value of the buffer
  71090. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71091. */
  71092. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71093. /**
  71094. * Gets the list of world matrices
  71095. * @return an array containing all the world matrices from the thin instances
  71096. */
  71097. thinInstanceGetWorldMatrices(): Matrix[];
  71098. /**
  71099. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71100. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71101. */
  71102. thinInstanceBufferUpdated(kind: string): void;
  71103. /**
  71104. * Applies a partial update to a buffer directly on the GPU
  71105. * 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
  71106. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71107. * @param data the data to set in the GPU buffer
  71108. * @param offset the offset in the GPU buffer where to update the data
  71109. */
  71110. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71111. /**
  71112. * Refreshes the bounding info, taking into account all the thin instances defined
  71113. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71114. */
  71115. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71116. /** @hidden */
  71117. _thinInstanceInitializeUserStorage(): void;
  71118. /** @hidden */
  71119. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71120. /** @hidden */
  71121. _userThinInstanceBuffersStorage: {
  71122. data: {
  71123. [key: string]: Float32Array;
  71124. };
  71125. sizes: {
  71126. [key: string]: number;
  71127. };
  71128. vertexBuffers: {
  71129. [key: string]: Nullable<VertexBuffer>;
  71130. };
  71131. strides: {
  71132. [key: string]: number;
  71133. };
  71134. };
  71135. }
  71136. }
  71137. declare module BABYLON {
  71138. /**
  71139. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71140. */
  71141. export interface INavigationEnginePlugin {
  71142. /**
  71143. * plugin name
  71144. */
  71145. name: string;
  71146. /**
  71147. * Creates a navigation mesh
  71148. * @param meshes array of all the geometry used to compute the navigatio mesh
  71149. * @param parameters bunch of parameters used to filter geometry
  71150. */
  71151. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71152. /**
  71153. * Create a navigation mesh debug mesh
  71154. * @param scene is where the mesh will be added
  71155. * @returns debug display mesh
  71156. */
  71157. createDebugNavMesh(scene: Scene): Mesh;
  71158. /**
  71159. * Get a navigation mesh constrained position, closest to the parameter position
  71160. * @param position world position
  71161. * @returns the closest point to position constrained by the navigation mesh
  71162. */
  71163. getClosestPoint(position: Vector3): Vector3;
  71164. /**
  71165. * Get a navigation mesh constrained position, closest to the parameter position
  71166. * @param position world position
  71167. * @param result output the closest point to position constrained by the navigation mesh
  71168. */
  71169. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71170. /**
  71171. * Get a navigation mesh constrained position, within a particular radius
  71172. * @param position world position
  71173. * @param maxRadius the maximum distance to the constrained world position
  71174. * @returns the closest point to position constrained by the navigation mesh
  71175. */
  71176. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71177. /**
  71178. * Get a navigation mesh constrained position, within a particular radius
  71179. * @param position world position
  71180. * @param maxRadius the maximum distance to the constrained world position
  71181. * @param result output the closest point to position constrained by the navigation mesh
  71182. */
  71183. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71184. /**
  71185. * Compute the final position from a segment made of destination-position
  71186. * @param position world position
  71187. * @param destination world position
  71188. * @returns the resulting point along the navmesh
  71189. */
  71190. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71191. /**
  71192. * Compute the final position from a segment made of destination-position
  71193. * @param position world position
  71194. * @param destination world position
  71195. * @param result output the resulting point along the navmesh
  71196. */
  71197. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71198. /**
  71199. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71200. * @param start world position
  71201. * @param end world position
  71202. * @returns array containing world position composing the path
  71203. */
  71204. computePath(start: Vector3, end: Vector3): Vector3[];
  71205. /**
  71206. * If this plugin is supported
  71207. * @returns true if plugin is supported
  71208. */
  71209. isSupported(): boolean;
  71210. /**
  71211. * Create a new Crowd so you can add agents
  71212. * @param maxAgents the maximum agent count in the crowd
  71213. * @param maxAgentRadius the maximum radius an agent can have
  71214. * @param scene to attach the crowd to
  71215. * @returns the crowd you can add agents to
  71216. */
  71217. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71218. /**
  71219. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71220. * The queries will try to find a solution within those bounds
  71221. * default is (1,1,1)
  71222. * @param extent x,y,z value that define the extent around the queries point of reference
  71223. */
  71224. setDefaultQueryExtent(extent: Vector3): void;
  71225. /**
  71226. * Get the Bounding box extent specified by setDefaultQueryExtent
  71227. * @returns the box extent values
  71228. */
  71229. getDefaultQueryExtent(): Vector3;
  71230. /**
  71231. * build the navmesh from a previously saved state using getNavmeshData
  71232. * @param data the Uint8Array returned by getNavmeshData
  71233. */
  71234. buildFromNavmeshData(data: Uint8Array): void;
  71235. /**
  71236. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71237. * @returns data the Uint8Array that can be saved and reused
  71238. */
  71239. getNavmeshData(): Uint8Array;
  71240. /**
  71241. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71242. * @param result output the box extent values
  71243. */
  71244. getDefaultQueryExtentToRef(result: Vector3): void;
  71245. /**
  71246. * Set the time step of the navigation tick update.
  71247. * Default is 1/60.
  71248. * A value of 0 will disable fixed time update
  71249. * @param newTimeStep the new timestep to apply to this world.
  71250. */
  71251. setTimeStep(newTimeStep: number): void;
  71252. /**
  71253. * Get the time step of the navigation tick update.
  71254. * @returns the current time step
  71255. */
  71256. getTimeStep(): number;
  71257. /**
  71258. * If delta time in navigation tick update is greater than the time step
  71259. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71260. * they will be discarded.
  71261. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71262. * @param newStepCount the maximum number of iterations
  71263. */
  71264. setMaximumSubStepCount(newStepCount: number): void;
  71265. /**
  71266. * Get the maximum number of iterations per navigation tick update
  71267. * @returns the maximum number of iterations
  71268. */
  71269. getMaximumSubStepCount(): number;
  71270. /**
  71271. * Release all resources
  71272. */
  71273. dispose(): void;
  71274. }
  71275. /**
  71276. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71277. */
  71278. export interface ICrowd {
  71279. /**
  71280. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71281. * You can attach anything to that node. The node position is updated in the scene update tick.
  71282. * @param pos world position that will be constrained by the navigation mesh
  71283. * @param parameters agent parameters
  71284. * @param transform hooked to the agent that will be update by the scene
  71285. * @returns agent index
  71286. */
  71287. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71288. /**
  71289. * Returns the agent position in world space
  71290. * @param index agent index returned by addAgent
  71291. * @returns world space position
  71292. */
  71293. getAgentPosition(index: number): Vector3;
  71294. /**
  71295. * Gets the agent position result in world space
  71296. * @param index agent index returned by addAgent
  71297. * @param result output world space position
  71298. */
  71299. getAgentPositionToRef(index: number, result: Vector3): void;
  71300. /**
  71301. * Gets the agent velocity in world space
  71302. * @param index agent index returned by addAgent
  71303. * @returns world space velocity
  71304. */
  71305. getAgentVelocity(index: number): Vector3;
  71306. /**
  71307. * Gets the agent velocity result in world space
  71308. * @param index agent index returned by addAgent
  71309. * @param result output world space velocity
  71310. */
  71311. getAgentVelocityToRef(index: number, result: Vector3): void;
  71312. /**
  71313. * Gets the agent next target point on the path
  71314. * @param index agent index returned by addAgent
  71315. * @returns world space position
  71316. */
  71317. getAgentNextTargetPath(index: number): Vector3;
  71318. /**
  71319. * Gets the agent state
  71320. * @param index agent index returned by addAgent
  71321. * @returns agent state
  71322. */
  71323. getAgentState(index: number): number;
  71324. /**
  71325. * returns true if the agent in over an off mesh link connection
  71326. * @param index agent index returned by addAgent
  71327. * @returns true if over an off mesh link connection
  71328. */
  71329. overOffmeshConnection(index: number): boolean;
  71330. /**
  71331. * Gets the agent next target point on the path
  71332. * @param index agent index returned by addAgent
  71333. * @param result output world space position
  71334. */
  71335. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71336. /**
  71337. * remove a particular agent previously created
  71338. * @param index agent index returned by addAgent
  71339. */
  71340. removeAgent(index: number): void;
  71341. /**
  71342. * get the list of all agents attached to this crowd
  71343. * @returns list of agent indices
  71344. */
  71345. getAgents(): number[];
  71346. /**
  71347. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71348. * @param deltaTime in seconds
  71349. */
  71350. update(deltaTime: number): void;
  71351. /**
  71352. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71353. * @param index agent index returned by addAgent
  71354. * @param destination targeted world position
  71355. */
  71356. agentGoto(index: number, destination: Vector3): void;
  71357. /**
  71358. * Teleport the agent to a new position
  71359. * @param index agent index returned by addAgent
  71360. * @param destination targeted world position
  71361. */
  71362. agentTeleport(index: number, destination: Vector3): void;
  71363. /**
  71364. * Update agent parameters
  71365. * @param index agent index returned by addAgent
  71366. * @param parameters agent parameters
  71367. */
  71368. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71369. /**
  71370. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71371. * The queries will try to find a solution within those bounds
  71372. * default is (1,1,1)
  71373. * @param extent x,y,z value that define the extent around the queries point of reference
  71374. */
  71375. setDefaultQueryExtent(extent: Vector3): void;
  71376. /**
  71377. * Get the Bounding box extent specified by setDefaultQueryExtent
  71378. * @returns the box extent values
  71379. */
  71380. getDefaultQueryExtent(): Vector3;
  71381. /**
  71382. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71383. * @param result output the box extent values
  71384. */
  71385. getDefaultQueryExtentToRef(result: Vector3): void;
  71386. /**
  71387. * Release all resources
  71388. */
  71389. dispose(): void;
  71390. }
  71391. /**
  71392. * Configures an agent
  71393. */
  71394. export interface IAgentParameters {
  71395. /**
  71396. * Agent radius. [Limit: >= 0]
  71397. */
  71398. radius: number;
  71399. /**
  71400. * Agent height. [Limit: > 0]
  71401. */
  71402. height: number;
  71403. /**
  71404. * Maximum allowed acceleration. [Limit: >= 0]
  71405. */
  71406. maxAcceleration: number;
  71407. /**
  71408. * Maximum allowed speed. [Limit: >= 0]
  71409. */
  71410. maxSpeed: number;
  71411. /**
  71412. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71413. */
  71414. collisionQueryRange: number;
  71415. /**
  71416. * The path visibility optimization range. [Limit: > 0]
  71417. */
  71418. pathOptimizationRange: number;
  71419. /**
  71420. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71421. */
  71422. separationWeight: number;
  71423. }
  71424. /**
  71425. * Configures the navigation mesh creation
  71426. */
  71427. export interface INavMeshParameters {
  71428. /**
  71429. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71430. */
  71431. cs: number;
  71432. /**
  71433. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71434. */
  71435. ch: number;
  71436. /**
  71437. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71438. */
  71439. walkableSlopeAngle: number;
  71440. /**
  71441. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71442. * be considered walkable. [Limit: >= 3] [Units: vx]
  71443. */
  71444. walkableHeight: number;
  71445. /**
  71446. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71447. */
  71448. walkableClimb: number;
  71449. /**
  71450. * The distance to erode/shrink the walkable area of the heightfield away from
  71451. * obstructions. [Limit: >=0] [Units: vx]
  71452. */
  71453. walkableRadius: number;
  71454. /**
  71455. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71456. */
  71457. maxEdgeLen: number;
  71458. /**
  71459. * The maximum distance a simplfied contour's border edges should deviate
  71460. * the original raw contour. [Limit: >=0] [Units: vx]
  71461. */
  71462. maxSimplificationError: number;
  71463. /**
  71464. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71465. */
  71466. minRegionArea: number;
  71467. /**
  71468. * Any regions with a span count smaller than this value will, if possible,
  71469. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71470. */
  71471. mergeRegionArea: number;
  71472. /**
  71473. * The maximum number of vertices allowed for polygons generated during the
  71474. * contour to polygon conversion process. [Limit: >= 3]
  71475. */
  71476. maxVertsPerPoly: number;
  71477. /**
  71478. * Sets the sampling distance to use when generating the detail mesh.
  71479. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71480. */
  71481. detailSampleDist: number;
  71482. /**
  71483. * The maximum distance the detail mesh surface should deviate from heightfield
  71484. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71485. */
  71486. detailSampleMaxError: number;
  71487. }
  71488. }
  71489. declare module BABYLON {
  71490. /**
  71491. * RecastJS navigation plugin
  71492. */
  71493. export class RecastJSPlugin implements INavigationEnginePlugin {
  71494. /**
  71495. * Reference to the Recast library
  71496. */
  71497. bjsRECAST: any;
  71498. /**
  71499. * plugin name
  71500. */
  71501. name: string;
  71502. /**
  71503. * the first navmesh created. We might extend this to support multiple navmeshes
  71504. */
  71505. navMesh: any;
  71506. private _maximumSubStepCount;
  71507. private _timeStep;
  71508. /**
  71509. * Initializes the recastJS plugin
  71510. * @param recastInjection can be used to inject your own recast reference
  71511. */
  71512. constructor(recastInjection?: any);
  71513. /**
  71514. * Set the time step of the navigation tick update.
  71515. * Default is 1/60.
  71516. * A value of 0 will disable fixed time update
  71517. * @param newTimeStep the new timestep to apply to this world.
  71518. */
  71519. setTimeStep(newTimeStep?: number): void;
  71520. /**
  71521. * Get the time step of the navigation tick update.
  71522. * @returns the current time step
  71523. */
  71524. getTimeStep(): number;
  71525. /**
  71526. * If delta time in navigation tick update is greater than the time step
  71527. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71528. * they will be discarded.
  71529. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71530. * @param newStepCount the maximum number of iterations
  71531. */
  71532. setMaximumSubStepCount(newStepCount?: number): void;
  71533. /**
  71534. * Get the maximum number of iterations per navigation tick update
  71535. * @returns the maximum number of iterations
  71536. */
  71537. getMaximumSubStepCount(): number;
  71538. /**
  71539. * Creates a navigation mesh
  71540. * @param meshes array of all the geometry used to compute the navigatio mesh
  71541. * @param parameters bunch of parameters used to filter geometry
  71542. */
  71543. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71544. /**
  71545. * Create a navigation mesh debug mesh
  71546. * @param scene is where the mesh will be added
  71547. * @returns debug display mesh
  71548. */
  71549. createDebugNavMesh(scene: Scene): Mesh;
  71550. /**
  71551. * Get a navigation mesh constrained position, closest to the parameter position
  71552. * @param position world position
  71553. * @returns the closest point to position constrained by the navigation mesh
  71554. */
  71555. getClosestPoint(position: Vector3): Vector3;
  71556. /**
  71557. * Get a navigation mesh constrained position, closest to the parameter position
  71558. * @param position world position
  71559. * @param result output the closest point to position constrained by the navigation mesh
  71560. */
  71561. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71562. /**
  71563. * Get a navigation mesh constrained position, within a particular radius
  71564. * @param position world position
  71565. * @param maxRadius the maximum distance to the constrained world position
  71566. * @returns the closest point to position constrained by the navigation mesh
  71567. */
  71568. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71569. /**
  71570. * Get a navigation mesh constrained position, within a particular radius
  71571. * @param position world position
  71572. * @param maxRadius the maximum distance to the constrained world position
  71573. * @param result output the closest point to position constrained by the navigation mesh
  71574. */
  71575. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71576. /**
  71577. * Compute the final position from a segment made of destination-position
  71578. * @param position world position
  71579. * @param destination world position
  71580. * @returns the resulting point along the navmesh
  71581. */
  71582. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71583. /**
  71584. * Compute the final position from a segment made of destination-position
  71585. * @param position world position
  71586. * @param destination world position
  71587. * @param result output the resulting point along the navmesh
  71588. */
  71589. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71590. /**
  71591. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71592. * @param start world position
  71593. * @param end world position
  71594. * @returns array containing world position composing the path
  71595. */
  71596. computePath(start: Vector3, end: Vector3): Vector3[];
  71597. /**
  71598. * Create a new Crowd so you can add agents
  71599. * @param maxAgents the maximum agent count in the crowd
  71600. * @param maxAgentRadius the maximum radius an agent can have
  71601. * @param scene to attach the crowd to
  71602. * @returns the crowd you can add agents to
  71603. */
  71604. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71605. /**
  71606. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71607. * The queries will try to find a solution within those bounds
  71608. * default is (1,1,1)
  71609. * @param extent x,y,z value that define the extent around the queries point of reference
  71610. */
  71611. setDefaultQueryExtent(extent: Vector3): void;
  71612. /**
  71613. * Get the Bounding box extent specified by setDefaultQueryExtent
  71614. * @returns the box extent values
  71615. */
  71616. getDefaultQueryExtent(): Vector3;
  71617. /**
  71618. * build the navmesh from a previously saved state using getNavmeshData
  71619. * @param data the Uint8Array returned by getNavmeshData
  71620. */
  71621. buildFromNavmeshData(data: Uint8Array): void;
  71622. /**
  71623. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71624. * @returns data the Uint8Array that can be saved and reused
  71625. */
  71626. getNavmeshData(): Uint8Array;
  71627. /**
  71628. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71629. * @param result output the box extent values
  71630. */
  71631. getDefaultQueryExtentToRef(result: Vector3): void;
  71632. /**
  71633. * Disposes
  71634. */
  71635. dispose(): void;
  71636. /**
  71637. * If this plugin is supported
  71638. * @returns true if plugin is supported
  71639. */
  71640. isSupported(): boolean;
  71641. }
  71642. /**
  71643. * Recast detour crowd implementation
  71644. */
  71645. export class RecastJSCrowd implements ICrowd {
  71646. /**
  71647. * Recast/detour plugin
  71648. */
  71649. bjsRECASTPlugin: RecastJSPlugin;
  71650. /**
  71651. * Link to the detour crowd
  71652. */
  71653. recastCrowd: any;
  71654. /**
  71655. * One transform per agent
  71656. */
  71657. transforms: TransformNode[];
  71658. /**
  71659. * All agents created
  71660. */
  71661. agents: number[];
  71662. /**
  71663. * Link to the scene is kept to unregister the crowd from the scene
  71664. */
  71665. private _scene;
  71666. /**
  71667. * Observer for crowd updates
  71668. */
  71669. private _onBeforeAnimationsObserver;
  71670. /**
  71671. * Constructor
  71672. * @param plugin recastJS plugin
  71673. * @param maxAgents the maximum agent count in the crowd
  71674. * @param maxAgentRadius the maximum radius an agent can have
  71675. * @param scene to attach the crowd to
  71676. * @returns the crowd you can add agents to
  71677. */
  71678. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71679. /**
  71680. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71681. * You can attach anything to that node. The node position is updated in the scene update tick.
  71682. * @param pos world position that will be constrained by the navigation mesh
  71683. * @param parameters agent parameters
  71684. * @param transform hooked to the agent that will be update by the scene
  71685. * @returns agent index
  71686. */
  71687. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71688. /**
  71689. * Returns the agent position in world space
  71690. * @param index agent index returned by addAgent
  71691. * @returns world space position
  71692. */
  71693. getAgentPosition(index: number): Vector3;
  71694. /**
  71695. * Returns the agent position result in world space
  71696. * @param index agent index returned by addAgent
  71697. * @param result output world space position
  71698. */
  71699. getAgentPositionToRef(index: number, result: Vector3): void;
  71700. /**
  71701. * Returns the agent velocity in world space
  71702. * @param index agent index returned by addAgent
  71703. * @returns world space velocity
  71704. */
  71705. getAgentVelocity(index: number): Vector3;
  71706. /**
  71707. * Returns the agent velocity result in world space
  71708. * @param index agent index returned by addAgent
  71709. * @param result output world space velocity
  71710. */
  71711. getAgentVelocityToRef(index: number, result: Vector3): void;
  71712. /**
  71713. * Returns the agent next target point on the path
  71714. * @param index agent index returned by addAgent
  71715. * @returns world space position
  71716. */
  71717. getAgentNextTargetPath(index: number): Vector3;
  71718. /**
  71719. * Returns the agent next target point on the path
  71720. * @param index agent index returned by addAgent
  71721. * @param result output world space position
  71722. */
  71723. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71724. /**
  71725. * Gets the agent state
  71726. * @param index agent index returned by addAgent
  71727. * @returns agent state
  71728. */
  71729. getAgentState(index: number): number;
  71730. /**
  71731. * returns true if the agent in over an off mesh link connection
  71732. * @param index agent index returned by addAgent
  71733. * @returns true if over an off mesh link connection
  71734. */
  71735. overOffmeshConnection(index: number): boolean;
  71736. /**
  71737. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71738. * @param index agent index returned by addAgent
  71739. * @param destination targeted world position
  71740. */
  71741. agentGoto(index: number, destination: Vector3): void;
  71742. /**
  71743. * Teleport the agent to a new position
  71744. * @param index agent index returned by addAgent
  71745. * @param destination targeted world position
  71746. */
  71747. agentTeleport(index: number, destination: Vector3): void;
  71748. /**
  71749. * Update agent parameters
  71750. * @param index agent index returned by addAgent
  71751. * @param parameters agent parameters
  71752. */
  71753. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71754. /**
  71755. * remove a particular agent previously created
  71756. * @param index agent index returned by addAgent
  71757. */
  71758. removeAgent(index: number): void;
  71759. /**
  71760. * get the list of all agents attached to this crowd
  71761. * @returns list of agent indices
  71762. */
  71763. getAgents(): number[];
  71764. /**
  71765. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71766. * @param deltaTime in seconds
  71767. */
  71768. update(deltaTime: number): void;
  71769. /**
  71770. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71771. * The queries will try to find a solution within those bounds
  71772. * default is (1,1,1)
  71773. * @param extent x,y,z value that define the extent around the queries point of reference
  71774. */
  71775. setDefaultQueryExtent(extent: Vector3): void;
  71776. /**
  71777. * Get the Bounding box extent specified by setDefaultQueryExtent
  71778. * @returns the box extent values
  71779. */
  71780. getDefaultQueryExtent(): Vector3;
  71781. /**
  71782. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71783. * @param result output the box extent values
  71784. */
  71785. getDefaultQueryExtentToRef(result: Vector3): void;
  71786. /**
  71787. * Release all resources
  71788. */
  71789. dispose(): void;
  71790. }
  71791. }
  71792. declare module BABYLON {
  71793. /**
  71794. * Class used to enable access to IndexedDB
  71795. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71796. */
  71797. export class Database implements IOfflineProvider {
  71798. private _callbackManifestChecked;
  71799. private _currentSceneUrl;
  71800. private _db;
  71801. private _enableSceneOffline;
  71802. private _enableTexturesOffline;
  71803. private _manifestVersionFound;
  71804. private _mustUpdateRessources;
  71805. private _hasReachedQuota;
  71806. private _isSupported;
  71807. private _idbFactory;
  71808. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71809. private static IsUASupportingBlobStorage;
  71810. /**
  71811. * Gets a boolean indicating if Database storate is enabled (off by default)
  71812. */
  71813. static IDBStorageEnabled: boolean;
  71814. /**
  71815. * Gets a boolean indicating if scene must be saved in the database
  71816. */
  71817. get enableSceneOffline(): boolean;
  71818. /**
  71819. * Gets a boolean indicating if textures must be saved in the database
  71820. */
  71821. get enableTexturesOffline(): boolean;
  71822. /**
  71823. * Creates a new Database
  71824. * @param urlToScene defines the url to load the scene
  71825. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71826. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71827. */
  71828. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71829. private static _ParseURL;
  71830. private static _ReturnFullUrlLocation;
  71831. private _checkManifestFile;
  71832. /**
  71833. * Open the database and make it available
  71834. * @param successCallback defines the callback to call on success
  71835. * @param errorCallback defines the callback to call on error
  71836. */
  71837. open(successCallback: () => void, errorCallback: () => void): void;
  71838. /**
  71839. * Loads an image from the database
  71840. * @param url defines the url to load from
  71841. * @param image defines the target DOM image
  71842. */
  71843. loadImage(url: string, image: HTMLImageElement): void;
  71844. private _loadImageFromDBAsync;
  71845. private _saveImageIntoDBAsync;
  71846. private _checkVersionFromDB;
  71847. private _loadVersionFromDBAsync;
  71848. private _saveVersionIntoDBAsync;
  71849. /**
  71850. * Loads a file from database
  71851. * @param url defines the URL to load from
  71852. * @param sceneLoaded defines a callback to call on success
  71853. * @param progressCallBack defines a callback to call when progress changed
  71854. * @param errorCallback defines a callback to call on error
  71855. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71856. */
  71857. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71858. private _loadFileAsync;
  71859. private _saveFileAsync;
  71860. /**
  71861. * Validates if xhr data is correct
  71862. * @param xhr defines the request to validate
  71863. * @param dataType defines the expected data type
  71864. * @returns true if data is correct
  71865. */
  71866. private static _ValidateXHRData;
  71867. }
  71868. }
  71869. declare module BABYLON {
  71870. /** @hidden */
  71871. export var gpuUpdateParticlesPixelShader: {
  71872. name: string;
  71873. shader: string;
  71874. };
  71875. }
  71876. declare module BABYLON {
  71877. /** @hidden */
  71878. export var gpuUpdateParticlesVertexShader: {
  71879. name: string;
  71880. shader: string;
  71881. };
  71882. }
  71883. declare module BABYLON {
  71884. /** @hidden */
  71885. export var clipPlaneFragmentDeclaration2: {
  71886. name: string;
  71887. shader: string;
  71888. };
  71889. }
  71890. declare module BABYLON {
  71891. /** @hidden */
  71892. export var gpuRenderParticlesPixelShader: {
  71893. name: string;
  71894. shader: string;
  71895. };
  71896. }
  71897. declare module BABYLON {
  71898. /** @hidden */
  71899. export var clipPlaneVertexDeclaration2: {
  71900. name: string;
  71901. shader: string;
  71902. };
  71903. }
  71904. declare module BABYLON {
  71905. /** @hidden */
  71906. export var gpuRenderParticlesVertexShader: {
  71907. name: string;
  71908. shader: string;
  71909. };
  71910. }
  71911. declare module BABYLON {
  71912. /**
  71913. * This represents a GPU particle system in Babylon
  71914. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71915. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71916. */
  71917. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71918. /**
  71919. * The layer mask we are rendering the particles through.
  71920. */
  71921. layerMask: number;
  71922. private _capacity;
  71923. private _activeCount;
  71924. private _currentActiveCount;
  71925. private _accumulatedCount;
  71926. private _renderEffect;
  71927. private _updateEffect;
  71928. private _buffer0;
  71929. private _buffer1;
  71930. private _spriteBuffer;
  71931. private _updateVAO;
  71932. private _renderVAO;
  71933. private _targetIndex;
  71934. private _sourceBuffer;
  71935. private _targetBuffer;
  71936. private _currentRenderId;
  71937. private _started;
  71938. private _stopped;
  71939. private _timeDelta;
  71940. private _randomTexture;
  71941. private _randomTexture2;
  71942. private _attributesStrideSize;
  71943. private _updateEffectOptions;
  71944. private _randomTextureSize;
  71945. private _actualFrame;
  71946. private _customEffect;
  71947. private readonly _rawTextureWidth;
  71948. /**
  71949. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71950. */
  71951. static get IsSupported(): boolean;
  71952. /**
  71953. * An event triggered when the system is disposed.
  71954. */
  71955. onDisposeObservable: Observable<IParticleSystem>;
  71956. /**
  71957. * An event triggered when the system is stopped
  71958. */
  71959. onStoppedObservable: Observable<IParticleSystem>;
  71960. /**
  71961. * Gets the maximum number of particles active at the same time.
  71962. * @returns The max number of active particles.
  71963. */
  71964. getCapacity(): number;
  71965. /**
  71966. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71967. * to override the particles.
  71968. */
  71969. forceDepthWrite: boolean;
  71970. /**
  71971. * Gets or set the number of active particles
  71972. */
  71973. get activeParticleCount(): number;
  71974. set activeParticleCount(value: number);
  71975. private _preWarmDone;
  71976. /**
  71977. * Specifies if the particles are updated in emitter local space or world space.
  71978. */
  71979. isLocal: boolean;
  71980. /** Gets or sets a matrix to use to compute projection */
  71981. defaultProjectionMatrix: Matrix;
  71982. /**
  71983. * Is this system ready to be used/rendered
  71984. * @return true if the system is ready
  71985. */
  71986. isReady(): boolean;
  71987. /**
  71988. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71989. * @returns True if it has been started, otherwise false.
  71990. */
  71991. isStarted(): boolean;
  71992. /**
  71993. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71994. * @returns True if it has been stopped, otherwise false.
  71995. */
  71996. isStopped(): boolean;
  71997. /**
  71998. * Gets a boolean indicating that the system is stopping
  71999. * @returns true if the system is currently stopping
  72000. */
  72001. isStopping(): boolean;
  72002. /**
  72003. * Gets the number of particles active at the same time.
  72004. * @returns The number of active particles.
  72005. */
  72006. getActiveCount(): number;
  72007. /**
  72008. * Starts the particle system and begins to emit
  72009. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72010. */
  72011. start(delay?: number): void;
  72012. /**
  72013. * Stops the particle system.
  72014. */
  72015. stop(): void;
  72016. /**
  72017. * Remove all active particles
  72018. */
  72019. reset(): void;
  72020. /**
  72021. * Returns the string "GPUParticleSystem"
  72022. * @returns a string containing the class name
  72023. */
  72024. getClassName(): string;
  72025. /**
  72026. * Gets the custom effect used to render the particles
  72027. * @param blendMode Blend mode for which the effect should be retrieved
  72028. * @returns The effect
  72029. */
  72030. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72031. /**
  72032. * Sets the custom effect used to render the particles
  72033. * @param effect The effect to set
  72034. * @param blendMode Blend mode for which the effect should be set
  72035. */
  72036. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72037. /** @hidden */
  72038. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72039. /**
  72040. * Observable that will be called just before the particles are drawn
  72041. */
  72042. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72043. /**
  72044. * Gets the name of the particle vertex shader
  72045. */
  72046. get vertexShaderName(): string;
  72047. private _colorGradientsTexture;
  72048. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72049. /**
  72050. * Adds a new color gradient
  72051. * @param gradient defines the gradient to use (between 0 and 1)
  72052. * @param color1 defines the color to affect to the specified gradient
  72053. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72054. * @returns the current particle system
  72055. */
  72056. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72057. private _refreshColorGradient;
  72058. /** Force the system to rebuild all gradients that need to be resync */
  72059. forceRefreshGradients(): void;
  72060. /**
  72061. * Remove a specific color gradient
  72062. * @param gradient defines the gradient to remove
  72063. * @returns the current particle system
  72064. */
  72065. removeColorGradient(gradient: number): GPUParticleSystem;
  72066. private _angularSpeedGradientsTexture;
  72067. private _sizeGradientsTexture;
  72068. private _velocityGradientsTexture;
  72069. private _limitVelocityGradientsTexture;
  72070. private _dragGradientsTexture;
  72071. private _addFactorGradient;
  72072. /**
  72073. * Adds a new size gradient
  72074. * @param gradient defines the gradient to use (between 0 and 1)
  72075. * @param factor defines the size factor to affect to the specified gradient
  72076. * @returns the current particle system
  72077. */
  72078. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72079. /**
  72080. * Remove a specific size gradient
  72081. * @param gradient defines the gradient to remove
  72082. * @returns the current particle system
  72083. */
  72084. removeSizeGradient(gradient: number): GPUParticleSystem;
  72085. private _refreshFactorGradient;
  72086. /**
  72087. * Adds a new angular speed gradient
  72088. * @param gradient defines the gradient to use (between 0 and 1)
  72089. * @param factor defines the angular speed to affect to the specified gradient
  72090. * @returns the current particle system
  72091. */
  72092. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72093. /**
  72094. * Remove a specific angular speed gradient
  72095. * @param gradient defines the gradient to remove
  72096. * @returns the current particle system
  72097. */
  72098. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72099. /**
  72100. * Adds a new velocity gradient
  72101. * @param gradient defines the gradient to use (between 0 and 1)
  72102. * @param factor defines the velocity to affect to the specified gradient
  72103. * @returns the current particle system
  72104. */
  72105. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72106. /**
  72107. * Remove a specific velocity gradient
  72108. * @param gradient defines the gradient to remove
  72109. * @returns the current particle system
  72110. */
  72111. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72112. /**
  72113. * Adds a new limit velocity gradient
  72114. * @param gradient defines the gradient to use (between 0 and 1)
  72115. * @param factor defines the limit velocity value to affect to the specified gradient
  72116. * @returns the current particle system
  72117. */
  72118. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72119. /**
  72120. * Remove a specific limit velocity gradient
  72121. * @param gradient defines the gradient to remove
  72122. * @returns the current particle system
  72123. */
  72124. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72125. /**
  72126. * Adds a new drag gradient
  72127. * @param gradient defines the gradient to use (between 0 and 1)
  72128. * @param factor defines the drag value to affect to the specified gradient
  72129. * @returns the current particle system
  72130. */
  72131. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72132. /**
  72133. * Remove a specific drag gradient
  72134. * @param gradient defines the gradient to remove
  72135. * @returns the current particle system
  72136. */
  72137. removeDragGradient(gradient: number): GPUParticleSystem;
  72138. /**
  72139. * Not supported by GPUParticleSystem
  72140. * @param gradient defines the gradient to use (between 0 and 1)
  72141. * @param factor defines the emit rate value to affect to the specified gradient
  72142. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72143. * @returns the current particle system
  72144. */
  72145. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72146. /**
  72147. * Not supported by GPUParticleSystem
  72148. * @param gradient defines the gradient to remove
  72149. * @returns the current particle system
  72150. */
  72151. removeEmitRateGradient(gradient: number): IParticleSystem;
  72152. /**
  72153. * Not supported by GPUParticleSystem
  72154. * @param gradient defines the gradient to use (between 0 and 1)
  72155. * @param factor defines the start size value to affect to the specified gradient
  72156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72157. * @returns the current particle system
  72158. */
  72159. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72160. /**
  72161. * Not supported by GPUParticleSystem
  72162. * @param gradient defines the gradient to remove
  72163. * @returns the current particle system
  72164. */
  72165. removeStartSizeGradient(gradient: number): IParticleSystem;
  72166. /**
  72167. * Not supported by GPUParticleSystem
  72168. * @param gradient defines the gradient to use (between 0 and 1)
  72169. * @param min defines the color remap minimal range
  72170. * @param max defines the color remap maximal range
  72171. * @returns the current particle system
  72172. */
  72173. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72174. /**
  72175. * Not supported by GPUParticleSystem
  72176. * @param gradient defines the gradient to remove
  72177. * @returns the current particle system
  72178. */
  72179. removeColorRemapGradient(): IParticleSystem;
  72180. /**
  72181. * Not supported by GPUParticleSystem
  72182. * @param gradient defines the gradient to use (between 0 and 1)
  72183. * @param min defines the alpha remap minimal range
  72184. * @param max defines the alpha remap maximal range
  72185. * @returns the current particle system
  72186. */
  72187. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72188. /**
  72189. * Not supported by GPUParticleSystem
  72190. * @param gradient defines the gradient to remove
  72191. * @returns the current particle system
  72192. */
  72193. removeAlphaRemapGradient(): IParticleSystem;
  72194. /**
  72195. * Not supported by GPUParticleSystem
  72196. * @param gradient defines the gradient to use (between 0 and 1)
  72197. * @param color defines the color to affect to the specified gradient
  72198. * @returns the current particle system
  72199. */
  72200. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72201. /**
  72202. * Not supported by GPUParticleSystem
  72203. * @param gradient defines the gradient to remove
  72204. * @returns the current particle system
  72205. */
  72206. removeRampGradient(): IParticleSystem;
  72207. /**
  72208. * Not supported by GPUParticleSystem
  72209. * @returns the list of ramp gradients
  72210. */
  72211. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72212. /**
  72213. * Not supported by GPUParticleSystem
  72214. * Gets or sets a boolean indicating that ramp gradients must be used
  72215. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72216. */
  72217. get useRampGradients(): boolean;
  72218. set useRampGradients(value: boolean);
  72219. /**
  72220. * Not supported by GPUParticleSystem
  72221. * @param gradient defines the gradient to use (between 0 and 1)
  72222. * @param factor defines the life time factor to affect to the specified gradient
  72223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72224. * @returns the current particle system
  72225. */
  72226. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72227. /**
  72228. * Not supported by GPUParticleSystem
  72229. * @param gradient defines the gradient to remove
  72230. * @returns the current particle system
  72231. */
  72232. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72233. /**
  72234. * Instantiates a GPU particle system.
  72235. * 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.
  72236. * @param name The name of the particle system
  72237. * @param options The options used to create the system
  72238. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72239. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72240. * @param customEffect a custom effect used to change the way particles are rendered by default
  72241. */
  72242. constructor(name: string, options: Partial<{
  72243. capacity: number;
  72244. randomTextureSize: number;
  72245. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72246. protected _reset(): void;
  72247. private _createUpdateVAO;
  72248. private _createRenderVAO;
  72249. private _initialize;
  72250. /** @hidden */
  72251. _recreateUpdateEffect(): void;
  72252. private _getEffect;
  72253. /**
  72254. * Fill the defines array according to the current settings of the particle system
  72255. * @param defines Array to be updated
  72256. * @param blendMode blend mode to take into account when updating the array
  72257. */
  72258. fillDefines(defines: Array<string>, blendMode?: number): void;
  72259. /**
  72260. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72261. * @param uniforms Uniforms array to fill
  72262. * @param attributes Attributes array to fill
  72263. * @param samplers Samplers array to fill
  72264. */
  72265. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72266. /** @hidden */
  72267. _recreateRenderEffect(): Effect;
  72268. /**
  72269. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72270. * @param preWarm defines if we are in the pre-warmimg phase
  72271. */
  72272. animate(preWarm?: boolean): void;
  72273. private _createFactorGradientTexture;
  72274. private _createSizeGradientTexture;
  72275. private _createAngularSpeedGradientTexture;
  72276. private _createVelocityGradientTexture;
  72277. private _createLimitVelocityGradientTexture;
  72278. private _createDragGradientTexture;
  72279. private _createColorGradientTexture;
  72280. /**
  72281. * Renders the particle system in its current state
  72282. * @param preWarm defines if the system should only update the particles but not render them
  72283. * @returns the current number of particles
  72284. */
  72285. render(preWarm?: boolean): number;
  72286. /**
  72287. * Rebuilds the particle system
  72288. */
  72289. rebuild(): void;
  72290. private _releaseBuffers;
  72291. private _releaseVAOs;
  72292. /**
  72293. * Disposes the particle system and free the associated resources
  72294. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72295. */
  72296. dispose(disposeTexture?: boolean): void;
  72297. /**
  72298. * Clones the particle system.
  72299. * @param name The name of the cloned object
  72300. * @param newEmitter The new emitter to use
  72301. * @returns the cloned particle system
  72302. */
  72303. clone(name: string, newEmitter: any): GPUParticleSystem;
  72304. /**
  72305. * Serializes the particle system to a JSON object
  72306. * @param serializeTexture defines if the texture must be serialized as well
  72307. * @returns the JSON object
  72308. */
  72309. serialize(serializeTexture?: boolean): any;
  72310. /**
  72311. * Parses a JSON object to create a GPU particle system.
  72312. * @param parsedParticleSystem The JSON object to parse
  72313. * @param sceneOrEngine The scene or the engine to create the particle system in
  72314. * @param rootUrl The root url to use to load external dependencies like texture
  72315. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72316. * @returns the parsed GPU particle system
  72317. */
  72318. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72319. }
  72320. }
  72321. declare module BABYLON {
  72322. /**
  72323. * Represents a set of particle systems working together to create a specific effect
  72324. */
  72325. export class ParticleSystemSet implements IDisposable {
  72326. /**
  72327. * Gets or sets base Assets URL
  72328. */
  72329. static BaseAssetsUrl: string;
  72330. private _emitterCreationOptions;
  72331. private _emitterNode;
  72332. /**
  72333. * Gets the particle system list
  72334. */
  72335. systems: IParticleSystem[];
  72336. /**
  72337. * Gets the emitter node used with this set
  72338. */
  72339. get emitterNode(): Nullable<TransformNode>;
  72340. /**
  72341. * Creates a new emitter mesh as a sphere
  72342. * @param options defines the options used to create the sphere
  72343. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72344. * @param scene defines the hosting scene
  72345. */
  72346. setEmitterAsSphere(options: {
  72347. diameter: number;
  72348. segments: number;
  72349. color: Color3;
  72350. }, renderingGroupId: number, scene: Scene): void;
  72351. /**
  72352. * Starts all particle systems of the set
  72353. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72354. */
  72355. start(emitter?: AbstractMesh): void;
  72356. /**
  72357. * Release all associated resources
  72358. */
  72359. dispose(): void;
  72360. /**
  72361. * Serialize the set into a JSON compatible object
  72362. * @param serializeTexture defines if the texture must be serialized as well
  72363. * @returns a JSON compatible representation of the set
  72364. */
  72365. serialize(serializeTexture?: boolean): any;
  72366. /**
  72367. * Parse a new ParticleSystemSet from a serialized source
  72368. * @param data defines a JSON compatible representation of the set
  72369. * @param scene defines the hosting scene
  72370. * @param gpu defines if we want GPU particles or CPU particles
  72371. * @returns a new ParticleSystemSet
  72372. */
  72373. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72374. }
  72375. }
  72376. declare module BABYLON {
  72377. /**
  72378. * This class is made for on one-liner static method to help creating particle system set.
  72379. */
  72380. export class ParticleHelper {
  72381. /**
  72382. * Gets or sets base Assets URL
  72383. */
  72384. static BaseAssetsUrl: string;
  72385. /** Define the Url to load snippets */
  72386. static SnippetUrl: string;
  72387. /**
  72388. * Create a default particle system that you can tweak
  72389. * @param emitter defines the emitter to use
  72390. * @param capacity defines the system capacity (default is 500 particles)
  72391. * @param scene defines the hosting scene
  72392. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72393. * @returns the new Particle system
  72394. */
  72395. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72396. /**
  72397. * This is the main static method (one-liner) of this helper to create different particle systems
  72398. * @param type This string represents the type to the particle system to create
  72399. * @param scene The scene where the particle system should live
  72400. * @param gpu If the system will use gpu
  72401. * @returns the ParticleSystemSet created
  72402. */
  72403. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72404. /**
  72405. * Static function used to export a particle system to a ParticleSystemSet variable.
  72406. * Please note that the emitter shape is not exported
  72407. * @param systems defines the particle systems to export
  72408. * @returns the created particle system set
  72409. */
  72410. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72411. /**
  72412. * Creates a particle system from a snippet saved in a remote file
  72413. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72414. * @param url defines the url to load from
  72415. * @param scene defines the hosting scene
  72416. * @param gpu If the system will use gpu
  72417. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72418. * @returns a promise that will resolve to the new particle system
  72419. */
  72420. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72421. /**
  72422. * Creates a particle system from a snippet saved by the particle system editor
  72423. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72424. * @param scene defines the hosting scene
  72425. * @param gpu If the system will use gpu
  72426. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72427. * @returns a promise that will resolve to the new particle system
  72428. */
  72429. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72430. }
  72431. }
  72432. declare module BABYLON {
  72433. interface Engine {
  72434. /**
  72435. * Create an effect to use with particle systems.
  72436. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72437. * the particle system for which you want to create a custom effect in the last parameter
  72438. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72439. * @param uniformsNames defines a list of attribute names
  72440. * @param samplers defines an array of string used to represent textures
  72441. * @param defines defines the string containing the defines to use to compile the shaders
  72442. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72443. * @param onCompiled defines a function to call when the effect creation is successful
  72444. * @param onError defines a function to call when the effect creation has failed
  72445. * @param particleSystem the particle system you want to create the effect for
  72446. * @returns the new Effect
  72447. */
  72448. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72449. }
  72450. interface Mesh {
  72451. /**
  72452. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72453. * @returns an array of IParticleSystem
  72454. */
  72455. getEmittedParticleSystems(): IParticleSystem[];
  72456. /**
  72457. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72458. * @returns an array of IParticleSystem
  72459. */
  72460. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72461. }
  72462. }
  72463. declare module BABYLON {
  72464. /** Defines the 4 color options */
  72465. export enum PointColor {
  72466. /** color value */
  72467. Color = 2,
  72468. /** uv value */
  72469. UV = 1,
  72470. /** random value */
  72471. Random = 0,
  72472. /** stated value */
  72473. Stated = 3
  72474. }
  72475. /**
  72476. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72477. * 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.
  72478. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72479. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72480. *
  72481. * Full documentation here : TO BE ENTERED
  72482. */
  72483. export class PointsCloudSystem implements IDisposable {
  72484. /**
  72485. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72486. * Example : var p = SPS.particles[i];
  72487. */
  72488. particles: CloudPoint[];
  72489. /**
  72490. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72491. */
  72492. nbParticles: number;
  72493. /**
  72494. * This a counter for your own usage. It's not set by any SPS functions.
  72495. */
  72496. counter: number;
  72497. /**
  72498. * The PCS name. This name is also given to the underlying mesh.
  72499. */
  72500. name: string;
  72501. /**
  72502. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72503. */
  72504. mesh: Mesh;
  72505. /**
  72506. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72507. * Please read :
  72508. */
  72509. vars: any;
  72510. /**
  72511. * @hidden
  72512. */
  72513. _size: number;
  72514. private _scene;
  72515. private _promises;
  72516. private _positions;
  72517. private _indices;
  72518. private _normals;
  72519. private _colors;
  72520. private _uvs;
  72521. private _indices32;
  72522. private _positions32;
  72523. private _colors32;
  72524. private _uvs32;
  72525. private _updatable;
  72526. private _isVisibilityBoxLocked;
  72527. private _alwaysVisible;
  72528. private _groups;
  72529. private _groupCounter;
  72530. private _computeParticleColor;
  72531. private _computeParticleTexture;
  72532. private _computeParticleRotation;
  72533. private _computeBoundingBox;
  72534. private _isReady;
  72535. /**
  72536. * Creates a PCS (Points Cloud System) object
  72537. * @param name (String) is the PCS name, this will be the underlying mesh name
  72538. * @param pointSize (number) is the size for each point
  72539. * @param scene (Scene) is the scene in which the PCS is added
  72540. * @param options defines the options of the PCS e.g.
  72541. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72542. */
  72543. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72544. updatable?: boolean;
  72545. });
  72546. /**
  72547. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72548. * If no points were added to the PCS, the returned mesh is just a single point.
  72549. * @returns a promise for the created mesh
  72550. */
  72551. buildMeshAsync(): Promise<Mesh>;
  72552. /**
  72553. * @hidden
  72554. */
  72555. private _buildMesh;
  72556. private _addParticle;
  72557. private _randomUnitVector;
  72558. private _getColorIndicesForCoord;
  72559. private _setPointsColorOrUV;
  72560. private _colorFromTexture;
  72561. private _calculateDensity;
  72562. /**
  72563. * Adds points to the PCS in random positions within a unit sphere
  72564. * @param nb (positive integer) the number of particles to be created from this model
  72565. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72566. * @returns the number of groups in the system
  72567. */
  72568. addPoints(nb: number, pointFunction?: any): number;
  72569. /**
  72570. * Adds points to the PCS from the surface of the model shape
  72571. * @param mesh is any Mesh object that will be used as a surface model for the points
  72572. * @param nb (positive integer) the number of particles to be created from this model
  72573. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72574. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72575. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72576. * @returns the number of groups in the system
  72577. */
  72578. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72579. /**
  72580. * Adds points to the PCS inside the model shape
  72581. * @param mesh is any Mesh object that will be used as a surface model for the points
  72582. * @param nb (positive integer) the number of particles to be created from this model
  72583. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72584. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72585. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72586. * @returns the number of groups in the system
  72587. */
  72588. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72589. /**
  72590. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72591. * This method calls `updateParticle()` for each particle of the SPS.
  72592. * For an animated SPS, it is usually called within the render loop.
  72593. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72594. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72595. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72596. * @returns the PCS.
  72597. */
  72598. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72599. /**
  72600. * Disposes the PCS.
  72601. */
  72602. dispose(): void;
  72603. /**
  72604. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72605. * doc :
  72606. * @returns the PCS.
  72607. */
  72608. refreshVisibleSize(): PointsCloudSystem;
  72609. /**
  72610. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72611. * @param size the size (float) of the visibility box
  72612. * note : this doesn't lock the PCS mesh bounding box.
  72613. * doc :
  72614. */
  72615. setVisibilityBox(size: number): void;
  72616. /**
  72617. * Gets whether the PCS is always visible or not
  72618. * doc :
  72619. */
  72620. get isAlwaysVisible(): boolean;
  72621. /**
  72622. * Sets the PCS as always visible or not
  72623. * doc :
  72624. */
  72625. set isAlwaysVisible(val: boolean);
  72626. /**
  72627. * Tells to `setParticles()` to compute the particle rotations or not
  72628. * Default value : false. The PCS is faster when it's set to false
  72629. * Note : particle rotations are only applied to parent particles
  72630. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72631. */
  72632. set computeParticleRotation(val: boolean);
  72633. /**
  72634. * Tells to `setParticles()` to compute the particle colors or not.
  72635. * Default value : true. The PCS is faster when it's set to false.
  72636. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72637. */
  72638. set computeParticleColor(val: boolean);
  72639. set computeParticleTexture(val: boolean);
  72640. /**
  72641. * Gets if `setParticles()` computes the particle colors or not.
  72642. * Default value : false. The PCS is faster when it's set to false.
  72643. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72644. */
  72645. get computeParticleColor(): boolean;
  72646. /**
  72647. * Gets if `setParticles()` computes the particle textures or not.
  72648. * Default value : false. The PCS is faster when it's set to false.
  72649. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72650. */
  72651. get computeParticleTexture(): boolean;
  72652. /**
  72653. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72654. */
  72655. set computeBoundingBox(val: boolean);
  72656. /**
  72657. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72658. */
  72659. get computeBoundingBox(): boolean;
  72660. /**
  72661. * This function does nothing. It may be overwritten to set all the particle first values.
  72662. * The PCS doesn't call this function, you may have to call it by your own.
  72663. * doc :
  72664. */
  72665. initParticles(): void;
  72666. /**
  72667. * This function does nothing. It may be overwritten to recycle a particle
  72668. * The PCS doesn't call this function, you can to call it
  72669. * doc :
  72670. * @param particle The particle to recycle
  72671. * @returns the recycled particle
  72672. */
  72673. recycleParticle(particle: CloudPoint): CloudPoint;
  72674. /**
  72675. * Updates a particle : this function should be overwritten by the user.
  72676. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72677. * doc :
  72678. * @example : just set a particle position or velocity and recycle conditions
  72679. * @param particle The particle to update
  72680. * @returns the updated particle
  72681. */
  72682. updateParticle(particle: CloudPoint): CloudPoint;
  72683. /**
  72684. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72685. * This does nothing and may be overwritten by the user.
  72686. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72687. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72688. * @param update the boolean update value actually passed to setParticles()
  72689. */
  72690. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72691. /**
  72692. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72693. * This will be passed three parameters.
  72694. * This does nothing and may be overwritten by the user.
  72695. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72696. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72697. * @param update the boolean update value actually passed to setParticles()
  72698. */
  72699. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72700. }
  72701. }
  72702. declare module BABYLON {
  72703. /**
  72704. * Represents one particle of a points cloud system.
  72705. */
  72706. export class CloudPoint {
  72707. /**
  72708. * particle global index
  72709. */
  72710. idx: number;
  72711. /**
  72712. * The color of the particle
  72713. */
  72714. color: Nullable<Color4>;
  72715. /**
  72716. * The world space position of the particle.
  72717. */
  72718. position: Vector3;
  72719. /**
  72720. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72721. */
  72722. rotation: Vector3;
  72723. /**
  72724. * The world space rotation quaternion of the particle.
  72725. */
  72726. rotationQuaternion: Nullable<Quaternion>;
  72727. /**
  72728. * The uv of the particle.
  72729. */
  72730. uv: Nullable<Vector2>;
  72731. /**
  72732. * The current speed of the particle.
  72733. */
  72734. velocity: Vector3;
  72735. /**
  72736. * The pivot point in the particle local space.
  72737. */
  72738. pivot: Vector3;
  72739. /**
  72740. * Must the particle be translated from its pivot point in its local space ?
  72741. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72742. * Default : false
  72743. */
  72744. translateFromPivot: boolean;
  72745. /**
  72746. * Index of this particle in the global "positions" array (Internal use)
  72747. * @hidden
  72748. */
  72749. _pos: number;
  72750. /**
  72751. * @hidden Index of this particle in the global "indices" array (Internal use)
  72752. */
  72753. _ind: number;
  72754. /**
  72755. * Group this particle belongs to
  72756. */
  72757. _group: PointsGroup;
  72758. /**
  72759. * Group id of this particle
  72760. */
  72761. groupId: number;
  72762. /**
  72763. * Index of the particle in its group id (Internal use)
  72764. */
  72765. idxInGroup: number;
  72766. /**
  72767. * @hidden Particle BoundingInfo object (Internal use)
  72768. */
  72769. _boundingInfo: BoundingInfo;
  72770. /**
  72771. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72772. */
  72773. _pcs: PointsCloudSystem;
  72774. /**
  72775. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72776. */
  72777. _stillInvisible: boolean;
  72778. /**
  72779. * @hidden Last computed particle rotation matrix
  72780. */
  72781. _rotationMatrix: number[];
  72782. /**
  72783. * Parent particle Id, if any.
  72784. * Default null.
  72785. */
  72786. parentId: Nullable<number>;
  72787. /**
  72788. * @hidden Internal global position in the PCS.
  72789. */
  72790. _globalPosition: Vector3;
  72791. /**
  72792. * Creates a Point Cloud object.
  72793. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72794. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72795. * @param group (PointsGroup) is the group the particle belongs to
  72796. * @param groupId (integer) is the group identifier in the PCS.
  72797. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72798. * @param pcs defines the PCS it is associated to
  72799. */
  72800. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72801. /**
  72802. * get point size
  72803. */
  72804. get size(): Vector3;
  72805. /**
  72806. * Set point size
  72807. */
  72808. set size(scale: Vector3);
  72809. /**
  72810. * Legacy support, changed quaternion to rotationQuaternion
  72811. */
  72812. get quaternion(): Nullable<Quaternion>;
  72813. /**
  72814. * Legacy support, changed quaternion to rotationQuaternion
  72815. */
  72816. set quaternion(q: Nullable<Quaternion>);
  72817. /**
  72818. * Returns a boolean. True if the particle intersects a mesh, else false
  72819. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72820. * @param target is the object (point or mesh) what the intersection is computed against
  72821. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72822. * @returns true if it intersects
  72823. */
  72824. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72825. /**
  72826. * get the rotation matrix of the particle
  72827. * @hidden
  72828. */
  72829. getRotationMatrix(m: Matrix): void;
  72830. }
  72831. /**
  72832. * Represents a group of points in a points cloud system
  72833. * * PCS internal tool, don't use it manually.
  72834. */
  72835. export class PointsGroup {
  72836. /**
  72837. * The group id
  72838. * @hidden
  72839. */
  72840. groupID: number;
  72841. /**
  72842. * image data for group (internal use)
  72843. * @hidden
  72844. */
  72845. _groupImageData: Nullable<ArrayBufferView>;
  72846. /**
  72847. * Image Width (internal use)
  72848. * @hidden
  72849. */
  72850. _groupImgWidth: number;
  72851. /**
  72852. * Image Height (internal use)
  72853. * @hidden
  72854. */
  72855. _groupImgHeight: number;
  72856. /**
  72857. * Custom position function (internal use)
  72858. * @hidden
  72859. */
  72860. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72861. /**
  72862. * density per facet for surface points
  72863. * @hidden
  72864. */
  72865. _groupDensity: number[];
  72866. /**
  72867. * Only when points are colored by texture carries pointer to texture list array
  72868. * @hidden
  72869. */
  72870. _textureNb: number;
  72871. /**
  72872. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72873. * PCS internal tool, don't use it manually.
  72874. * @hidden
  72875. */
  72876. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72877. }
  72878. }
  72879. declare module BABYLON {
  72880. interface Scene {
  72881. /** @hidden (Backing field) */
  72882. _physicsEngine: Nullable<IPhysicsEngine>;
  72883. /** @hidden */
  72884. _physicsTimeAccumulator: number;
  72885. /**
  72886. * Gets the current physics engine
  72887. * @returns a IPhysicsEngine or null if none attached
  72888. */
  72889. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72890. /**
  72891. * Enables physics to the current scene
  72892. * @param gravity defines the scene's gravity for the physics engine
  72893. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72894. * @return a boolean indicating if the physics engine was initialized
  72895. */
  72896. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72897. /**
  72898. * Disables and disposes the physics engine associated with the scene
  72899. */
  72900. disablePhysicsEngine(): void;
  72901. /**
  72902. * Gets a boolean indicating if there is an active physics engine
  72903. * @returns a boolean indicating if there is an active physics engine
  72904. */
  72905. isPhysicsEnabled(): boolean;
  72906. /**
  72907. * Deletes a physics compound impostor
  72908. * @param compound defines the compound to delete
  72909. */
  72910. deleteCompoundImpostor(compound: any): void;
  72911. /**
  72912. * An event triggered when physic simulation is about to be run
  72913. */
  72914. onBeforePhysicsObservable: Observable<Scene>;
  72915. /**
  72916. * An event triggered when physic simulation has been done
  72917. */
  72918. onAfterPhysicsObservable: Observable<Scene>;
  72919. }
  72920. interface AbstractMesh {
  72921. /** @hidden */
  72922. _physicsImpostor: Nullable<PhysicsImpostor>;
  72923. /**
  72924. * Gets or sets impostor used for physic simulation
  72925. * @see https://doc.babylonjs.com/features/physics_engine
  72926. */
  72927. physicsImpostor: Nullable<PhysicsImpostor>;
  72928. /**
  72929. * Gets the current physics impostor
  72930. * @see https://doc.babylonjs.com/features/physics_engine
  72931. * @returns a physics impostor or null
  72932. */
  72933. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72934. /** Apply a physic impulse to the mesh
  72935. * @param force defines the force to apply
  72936. * @param contactPoint defines where to apply the force
  72937. * @returns the current mesh
  72938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72939. */
  72940. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72941. /**
  72942. * Creates a physic joint between two meshes
  72943. * @param otherMesh defines the other mesh to use
  72944. * @param pivot1 defines the pivot to use on this mesh
  72945. * @param pivot2 defines the pivot to use on the other mesh
  72946. * @param options defines additional options (can be plugin dependent)
  72947. * @returns the current mesh
  72948. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72949. */
  72950. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72951. /** @hidden */
  72952. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72953. }
  72954. /**
  72955. * Defines the physics engine scene component responsible to manage a physics engine
  72956. */
  72957. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72958. /**
  72959. * The component name helpful to identify the component in the list of scene components.
  72960. */
  72961. readonly name: string;
  72962. /**
  72963. * The scene the component belongs to.
  72964. */
  72965. scene: Scene;
  72966. /**
  72967. * Creates a new instance of the component for the given scene
  72968. * @param scene Defines the scene to register the component in
  72969. */
  72970. constructor(scene: Scene);
  72971. /**
  72972. * Registers the component in a given scene
  72973. */
  72974. register(): void;
  72975. /**
  72976. * Rebuilds the elements related to this component in case of
  72977. * context lost for instance.
  72978. */
  72979. rebuild(): void;
  72980. /**
  72981. * Disposes the component and the associated ressources
  72982. */
  72983. dispose(): void;
  72984. }
  72985. }
  72986. declare module BABYLON {
  72987. /**
  72988. * A helper for physics simulations
  72989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72990. */
  72991. export class PhysicsHelper {
  72992. private _scene;
  72993. private _physicsEngine;
  72994. /**
  72995. * Initializes the Physics helper
  72996. * @param scene Babylon.js scene
  72997. */
  72998. constructor(scene: Scene);
  72999. /**
  73000. * Applies a radial explosion impulse
  73001. * @param origin the origin of the explosion
  73002. * @param radiusOrEventOptions the radius or the options of radial explosion
  73003. * @param strength the explosion strength
  73004. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73005. * @returns A physics radial explosion event, or null
  73006. */
  73007. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73008. /**
  73009. * Applies a radial explosion force
  73010. * @param origin the origin of the explosion
  73011. * @param radiusOrEventOptions the radius or the options of radial explosion
  73012. * @param strength the explosion strength
  73013. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73014. * @returns A physics radial explosion event, or null
  73015. */
  73016. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73017. /**
  73018. * Creates a gravitational field
  73019. * @param origin the origin of the explosion
  73020. * @param radiusOrEventOptions the radius or the options of radial explosion
  73021. * @param strength the explosion strength
  73022. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73023. * @returns A physics gravitational field event, or null
  73024. */
  73025. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73026. /**
  73027. * Creates a physics updraft event
  73028. * @param origin the origin of the updraft
  73029. * @param radiusOrEventOptions the radius or the options of the updraft
  73030. * @param strength the strength of the updraft
  73031. * @param height the height of the updraft
  73032. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73033. * @returns A physics updraft event, or null
  73034. */
  73035. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73036. /**
  73037. * Creates a physics vortex event
  73038. * @param origin the of the vortex
  73039. * @param radiusOrEventOptions the radius or the options of the vortex
  73040. * @param strength the strength of the vortex
  73041. * @param height the height of the vortex
  73042. * @returns a Physics vortex event, or null
  73043. * A physics vortex event or null
  73044. */
  73045. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73046. }
  73047. /**
  73048. * Represents a physics radial explosion event
  73049. */
  73050. class PhysicsRadialExplosionEvent {
  73051. private _scene;
  73052. private _options;
  73053. private _sphere;
  73054. private _dataFetched;
  73055. /**
  73056. * Initializes a radial explosioin event
  73057. * @param _scene BabylonJS scene
  73058. * @param _options The options for the vortex event
  73059. */
  73060. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73061. /**
  73062. * Returns the data related to the radial explosion event (sphere).
  73063. * @returns The radial explosion event data
  73064. */
  73065. getData(): PhysicsRadialExplosionEventData;
  73066. /**
  73067. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73068. * @param impostor A physics imposter
  73069. * @param origin the origin of the explosion
  73070. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73071. */
  73072. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73073. /**
  73074. * Triggers affecterd impostors callbacks
  73075. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73076. */
  73077. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73078. /**
  73079. * Disposes the sphere.
  73080. * @param force Specifies if the sphere should be disposed by force
  73081. */
  73082. dispose(force?: boolean): void;
  73083. /*** Helpers ***/
  73084. private _prepareSphere;
  73085. private _intersectsWithSphere;
  73086. }
  73087. /**
  73088. * Represents a gravitational field event
  73089. */
  73090. class PhysicsGravitationalFieldEvent {
  73091. private _physicsHelper;
  73092. private _scene;
  73093. private _origin;
  73094. private _options;
  73095. private _tickCallback;
  73096. private _sphere;
  73097. private _dataFetched;
  73098. /**
  73099. * Initializes the physics gravitational field event
  73100. * @param _physicsHelper A physics helper
  73101. * @param _scene BabylonJS scene
  73102. * @param _origin The origin position of the gravitational field event
  73103. * @param _options The options for the vortex event
  73104. */
  73105. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73106. /**
  73107. * Returns the data related to the gravitational field event (sphere).
  73108. * @returns A gravitational field event
  73109. */
  73110. getData(): PhysicsGravitationalFieldEventData;
  73111. /**
  73112. * Enables the gravitational field.
  73113. */
  73114. enable(): void;
  73115. /**
  73116. * Disables the gravitational field.
  73117. */
  73118. disable(): void;
  73119. /**
  73120. * Disposes the sphere.
  73121. * @param force The force to dispose from the gravitational field event
  73122. */
  73123. dispose(force?: boolean): void;
  73124. private _tick;
  73125. }
  73126. /**
  73127. * Represents a physics updraft event
  73128. */
  73129. class PhysicsUpdraftEvent {
  73130. private _scene;
  73131. private _origin;
  73132. private _options;
  73133. private _physicsEngine;
  73134. private _originTop;
  73135. private _originDirection;
  73136. private _tickCallback;
  73137. private _cylinder;
  73138. private _cylinderPosition;
  73139. private _dataFetched;
  73140. /**
  73141. * Initializes the physics updraft event
  73142. * @param _scene BabylonJS scene
  73143. * @param _origin The origin position of the updraft
  73144. * @param _options The options for the updraft event
  73145. */
  73146. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73147. /**
  73148. * Returns the data related to the updraft event (cylinder).
  73149. * @returns A physics updraft event
  73150. */
  73151. getData(): PhysicsUpdraftEventData;
  73152. /**
  73153. * Enables the updraft.
  73154. */
  73155. enable(): void;
  73156. /**
  73157. * Disables the updraft.
  73158. */
  73159. disable(): void;
  73160. /**
  73161. * Disposes the cylinder.
  73162. * @param force Specifies if the updraft should be disposed by force
  73163. */
  73164. dispose(force?: boolean): void;
  73165. private getImpostorHitData;
  73166. private _tick;
  73167. /*** Helpers ***/
  73168. private _prepareCylinder;
  73169. private _intersectsWithCylinder;
  73170. }
  73171. /**
  73172. * Represents a physics vortex event
  73173. */
  73174. class PhysicsVortexEvent {
  73175. private _scene;
  73176. private _origin;
  73177. private _options;
  73178. private _physicsEngine;
  73179. private _originTop;
  73180. private _tickCallback;
  73181. private _cylinder;
  73182. private _cylinderPosition;
  73183. private _dataFetched;
  73184. /**
  73185. * Initializes the physics vortex event
  73186. * @param _scene The BabylonJS scene
  73187. * @param _origin The origin position of the vortex
  73188. * @param _options The options for the vortex event
  73189. */
  73190. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73191. /**
  73192. * Returns the data related to the vortex event (cylinder).
  73193. * @returns The physics vortex event data
  73194. */
  73195. getData(): PhysicsVortexEventData;
  73196. /**
  73197. * Enables the vortex.
  73198. */
  73199. enable(): void;
  73200. /**
  73201. * Disables the cortex.
  73202. */
  73203. disable(): void;
  73204. /**
  73205. * Disposes the sphere.
  73206. * @param force
  73207. */
  73208. dispose(force?: boolean): void;
  73209. private getImpostorHitData;
  73210. private _tick;
  73211. /*** Helpers ***/
  73212. private _prepareCylinder;
  73213. private _intersectsWithCylinder;
  73214. }
  73215. /**
  73216. * Options fot the radial explosion event
  73217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73218. */
  73219. export class PhysicsRadialExplosionEventOptions {
  73220. /**
  73221. * The radius of the sphere for the radial explosion.
  73222. */
  73223. radius: number;
  73224. /**
  73225. * The strenth of the explosion.
  73226. */
  73227. strength: number;
  73228. /**
  73229. * The strenght of the force in correspondence to the distance of the affected object
  73230. */
  73231. falloff: PhysicsRadialImpulseFalloff;
  73232. /**
  73233. * Sphere options for the radial explosion.
  73234. */
  73235. sphere: {
  73236. segments: number;
  73237. diameter: number;
  73238. };
  73239. /**
  73240. * Sphere options for the radial explosion.
  73241. */
  73242. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73243. }
  73244. /**
  73245. * Options fot the updraft event
  73246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73247. */
  73248. export class PhysicsUpdraftEventOptions {
  73249. /**
  73250. * The radius of the cylinder for the vortex
  73251. */
  73252. radius: number;
  73253. /**
  73254. * The strenth of the updraft.
  73255. */
  73256. strength: number;
  73257. /**
  73258. * The height of the cylinder for the updraft.
  73259. */
  73260. height: number;
  73261. /**
  73262. * The mode for the the updraft.
  73263. */
  73264. updraftMode: PhysicsUpdraftMode;
  73265. }
  73266. /**
  73267. * Options fot the vortex event
  73268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73269. */
  73270. export class PhysicsVortexEventOptions {
  73271. /**
  73272. * The radius of the cylinder for the vortex
  73273. */
  73274. radius: number;
  73275. /**
  73276. * The strenth of the vortex.
  73277. */
  73278. strength: number;
  73279. /**
  73280. * The height of the cylinder for the vortex.
  73281. */
  73282. height: number;
  73283. /**
  73284. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73285. */
  73286. centripetalForceThreshold: number;
  73287. /**
  73288. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73289. */
  73290. centripetalForceMultiplier: number;
  73291. /**
  73292. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73293. */
  73294. centrifugalForceMultiplier: number;
  73295. /**
  73296. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73297. */
  73298. updraftForceMultiplier: number;
  73299. }
  73300. /**
  73301. * The strenght of the force in correspondence to the distance of the affected object
  73302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73303. */
  73304. export enum PhysicsRadialImpulseFalloff {
  73305. /** Defines that impulse is constant in strength across it's whole radius */
  73306. Constant = 0,
  73307. /** Defines that impulse gets weaker if it's further from the origin */
  73308. Linear = 1
  73309. }
  73310. /**
  73311. * The strength of the force in correspondence to the distance of the affected object
  73312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73313. */
  73314. export enum PhysicsUpdraftMode {
  73315. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73316. Center = 0,
  73317. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73318. Perpendicular = 1
  73319. }
  73320. /**
  73321. * Interface for a physics hit data
  73322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73323. */
  73324. export interface PhysicsHitData {
  73325. /**
  73326. * The force applied at the contact point
  73327. */
  73328. force: Vector3;
  73329. /**
  73330. * The contact point
  73331. */
  73332. contactPoint: Vector3;
  73333. /**
  73334. * The distance from the origin to the contact point
  73335. */
  73336. distanceFromOrigin: number;
  73337. }
  73338. /**
  73339. * Interface for radial explosion event data
  73340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73341. */
  73342. export interface PhysicsRadialExplosionEventData {
  73343. /**
  73344. * A sphere used for the radial explosion event
  73345. */
  73346. sphere: Mesh;
  73347. }
  73348. /**
  73349. * Interface for gravitational field event data
  73350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73351. */
  73352. export interface PhysicsGravitationalFieldEventData {
  73353. /**
  73354. * A sphere mesh used for the gravitational field event
  73355. */
  73356. sphere: Mesh;
  73357. }
  73358. /**
  73359. * Interface for updraft event data
  73360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73361. */
  73362. export interface PhysicsUpdraftEventData {
  73363. /**
  73364. * A cylinder used for the updraft event
  73365. */
  73366. cylinder: Mesh;
  73367. }
  73368. /**
  73369. * Interface for vortex event data
  73370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73371. */
  73372. export interface PhysicsVortexEventData {
  73373. /**
  73374. * A cylinder used for the vortex event
  73375. */
  73376. cylinder: Mesh;
  73377. }
  73378. /**
  73379. * Interface for an affected physics impostor
  73380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73381. */
  73382. export interface PhysicsAffectedImpostorWithData {
  73383. /**
  73384. * The impostor affected by the effect
  73385. */
  73386. impostor: PhysicsImpostor;
  73387. /**
  73388. * The data about the hit/horce from the explosion
  73389. */
  73390. hitData: PhysicsHitData;
  73391. }
  73392. }
  73393. declare module BABYLON {
  73394. /** @hidden */
  73395. export var blackAndWhitePixelShader: {
  73396. name: string;
  73397. shader: string;
  73398. };
  73399. }
  73400. declare module BABYLON {
  73401. /**
  73402. * Post process used to render in black and white
  73403. */
  73404. export class BlackAndWhitePostProcess extends PostProcess {
  73405. /**
  73406. * Linear about to convert he result to black and white (default: 1)
  73407. */
  73408. degree: number;
  73409. /**
  73410. * Gets a string identifying the name of the class
  73411. * @returns "BlackAndWhitePostProcess" string
  73412. */
  73413. getClassName(): string;
  73414. /**
  73415. * Creates a black and white post process
  73416. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73417. * @param name The name of the effect.
  73418. * @param options The required width/height ratio to downsize to before computing the render pass.
  73419. * @param camera The camera to apply the render pass to.
  73420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73421. * @param engine The engine which the post process will be applied. (default: current engine)
  73422. * @param reusable If the post process can be reused on the same frame. (default: false)
  73423. */
  73424. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73425. /** @hidden */
  73426. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73427. }
  73428. }
  73429. declare module BABYLON {
  73430. /**
  73431. * This represents a set of one or more post processes in Babylon.
  73432. * A post process can be used to apply a shader to a texture after it is rendered.
  73433. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73434. */
  73435. export class PostProcessRenderEffect {
  73436. private _postProcesses;
  73437. private _getPostProcesses;
  73438. private _singleInstance;
  73439. private _cameras;
  73440. private _indicesForCamera;
  73441. /**
  73442. * Name of the effect
  73443. * @hidden
  73444. */
  73445. _name: string;
  73446. /**
  73447. * Instantiates a post process render effect.
  73448. * A post process can be used to apply a shader to a texture after it is rendered.
  73449. * @param engine The engine the effect is tied to
  73450. * @param name The name of the effect
  73451. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73452. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73453. */
  73454. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73455. /**
  73456. * Checks if all the post processes in the effect are supported.
  73457. */
  73458. get isSupported(): boolean;
  73459. /**
  73460. * Updates the current state of the effect
  73461. * @hidden
  73462. */
  73463. _update(): void;
  73464. /**
  73465. * Attaches the effect on cameras
  73466. * @param cameras The camera to attach to.
  73467. * @hidden
  73468. */
  73469. _attachCameras(cameras: Camera): void;
  73470. /**
  73471. * Attaches the effect on cameras
  73472. * @param cameras The camera to attach to.
  73473. * @hidden
  73474. */
  73475. _attachCameras(cameras: Camera[]): void;
  73476. /**
  73477. * Detaches the effect on cameras
  73478. * @param cameras The camera to detatch from.
  73479. * @hidden
  73480. */
  73481. _detachCameras(cameras: Camera): void;
  73482. /**
  73483. * Detatches the effect on cameras
  73484. * @param cameras The camera to detatch from.
  73485. * @hidden
  73486. */
  73487. _detachCameras(cameras: Camera[]): void;
  73488. /**
  73489. * Enables the effect on given cameras
  73490. * @param cameras The camera to enable.
  73491. * @hidden
  73492. */
  73493. _enable(cameras: Camera): void;
  73494. /**
  73495. * Enables the effect on given cameras
  73496. * @param cameras The camera to enable.
  73497. * @hidden
  73498. */
  73499. _enable(cameras: Nullable<Camera[]>): void;
  73500. /**
  73501. * Disables the effect on the given cameras
  73502. * @param cameras The camera to disable.
  73503. * @hidden
  73504. */
  73505. _disable(cameras: Camera): void;
  73506. /**
  73507. * Disables the effect on the given cameras
  73508. * @param cameras The camera to disable.
  73509. * @hidden
  73510. */
  73511. _disable(cameras: Nullable<Camera[]>): void;
  73512. /**
  73513. * Gets a list of the post processes contained in the effect.
  73514. * @param camera The camera to get the post processes on.
  73515. * @returns The list of the post processes in the effect.
  73516. */
  73517. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73518. }
  73519. }
  73520. declare module BABYLON {
  73521. /** @hidden */
  73522. export var extractHighlightsPixelShader: {
  73523. name: string;
  73524. shader: string;
  73525. };
  73526. }
  73527. declare module BABYLON {
  73528. /**
  73529. * 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.
  73530. */
  73531. export class ExtractHighlightsPostProcess extends PostProcess {
  73532. /**
  73533. * The luminance threshold, pixels below this value will be set to black.
  73534. */
  73535. threshold: number;
  73536. /** @hidden */
  73537. _exposure: number;
  73538. /**
  73539. * Post process which has the input texture to be used when performing highlight extraction
  73540. * @hidden
  73541. */
  73542. _inputPostProcess: Nullable<PostProcess>;
  73543. /**
  73544. * Gets a string identifying the name of the class
  73545. * @returns "ExtractHighlightsPostProcess" string
  73546. */
  73547. getClassName(): string;
  73548. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73549. }
  73550. }
  73551. declare module BABYLON {
  73552. /** @hidden */
  73553. export var bloomMergePixelShader: {
  73554. name: string;
  73555. shader: string;
  73556. };
  73557. }
  73558. declare module BABYLON {
  73559. /**
  73560. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73561. */
  73562. export class BloomMergePostProcess extends PostProcess {
  73563. /** Weight of the bloom to be added to the original input. */
  73564. weight: number;
  73565. /**
  73566. * Gets a string identifying the name of the class
  73567. * @returns "BloomMergePostProcess" string
  73568. */
  73569. getClassName(): string;
  73570. /**
  73571. * Creates a new instance of @see BloomMergePostProcess
  73572. * @param name The name of the effect.
  73573. * @param originalFromInput Post process which's input will be used for the merge.
  73574. * @param blurred Blurred highlights post process which's output will be used.
  73575. * @param weight Weight of the bloom to be added to the original input.
  73576. * @param options The required width/height ratio to downsize to before computing the render pass.
  73577. * @param camera The camera to apply the render pass to.
  73578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73579. * @param engine The engine which the post process will be applied. (default: current engine)
  73580. * @param reusable If the post process can be reused on the same frame. (default: false)
  73581. * @param textureType Type of textures used when performing the post process. (default: 0)
  73582. * @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)
  73583. */
  73584. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73585. /** Weight of the bloom to be added to the original input. */
  73586. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73587. }
  73588. }
  73589. declare module BABYLON {
  73590. /**
  73591. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73592. */
  73593. export class BloomEffect extends PostProcessRenderEffect {
  73594. private bloomScale;
  73595. /**
  73596. * @hidden Internal
  73597. */
  73598. _effects: Array<PostProcess>;
  73599. /**
  73600. * @hidden Internal
  73601. */
  73602. _downscale: ExtractHighlightsPostProcess;
  73603. private _blurX;
  73604. private _blurY;
  73605. private _merge;
  73606. /**
  73607. * The luminance threshold to find bright areas of the image to bloom.
  73608. */
  73609. get threshold(): number;
  73610. set threshold(value: number);
  73611. /**
  73612. * The strength of the bloom.
  73613. */
  73614. get weight(): number;
  73615. set weight(value: number);
  73616. /**
  73617. * Specifies the size of the bloom blur kernel, relative to the final output size
  73618. */
  73619. get kernel(): number;
  73620. set kernel(value: number);
  73621. /**
  73622. * Creates a new instance of @see BloomEffect
  73623. * @param scene The scene the effect belongs to.
  73624. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73625. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73626. * @param bloomWeight The the strength of bloom.
  73627. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73628. * @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)
  73629. */
  73630. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73631. /**
  73632. * Disposes each of the internal effects for a given camera.
  73633. * @param camera The camera to dispose the effect on.
  73634. */
  73635. disposeEffects(camera: Camera): void;
  73636. /**
  73637. * @hidden Internal
  73638. */
  73639. _updateEffects(): void;
  73640. /**
  73641. * Internal
  73642. * @returns if all the contained post processes are ready.
  73643. * @hidden
  73644. */
  73645. _isReady(): boolean;
  73646. }
  73647. }
  73648. declare module BABYLON {
  73649. /** @hidden */
  73650. export var chromaticAberrationPixelShader: {
  73651. name: string;
  73652. shader: string;
  73653. };
  73654. }
  73655. declare module BABYLON {
  73656. /**
  73657. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73658. */
  73659. export class ChromaticAberrationPostProcess extends PostProcess {
  73660. /**
  73661. * The amount of seperation of rgb channels (default: 30)
  73662. */
  73663. aberrationAmount: number;
  73664. /**
  73665. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73666. */
  73667. radialIntensity: number;
  73668. /**
  73669. * 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))
  73670. */
  73671. direction: Vector2;
  73672. /**
  73673. * 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))
  73674. */
  73675. centerPosition: Vector2;
  73676. /** The width of the screen to apply the effect on */
  73677. screenWidth: number;
  73678. /** The height of the screen to apply the effect on */
  73679. screenHeight: number;
  73680. /**
  73681. * Gets a string identifying the name of the class
  73682. * @returns "ChromaticAberrationPostProcess" string
  73683. */
  73684. getClassName(): string;
  73685. /**
  73686. * Creates a new instance ChromaticAberrationPostProcess
  73687. * @param name The name of the effect.
  73688. * @param screenWidth The width of the screen to apply the effect on.
  73689. * @param screenHeight The height of the screen to apply the effect on.
  73690. * @param options The required width/height ratio to downsize to before computing the render pass.
  73691. * @param camera The camera to apply the render pass to.
  73692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73693. * @param engine The engine which the post process will be applied. (default: current engine)
  73694. * @param reusable If the post process can be reused on the same frame. (default: false)
  73695. * @param textureType Type of textures used when performing the post process. (default: 0)
  73696. * @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)
  73697. */
  73698. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73699. /** @hidden */
  73700. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73701. }
  73702. }
  73703. declare module BABYLON {
  73704. /** @hidden */
  73705. export var circleOfConfusionPixelShader: {
  73706. name: string;
  73707. shader: string;
  73708. };
  73709. }
  73710. declare module BABYLON {
  73711. /**
  73712. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73713. */
  73714. export class CircleOfConfusionPostProcess extends PostProcess {
  73715. /**
  73716. * 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.
  73717. */
  73718. lensSize: number;
  73719. /**
  73720. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73721. */
  73722. fStop: number;
  73723. /**
  73724. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73725. */
  73726. focusDistance: number;
  73727. /**
  73728. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73729. */
  73730. focalLength: number;
  73731. /**
  73732. * Gets a string identifying the name of the class
  73733. * @returns "CircleOfConfusionPostProcess" string
  73734. */
  73735. getClassName(): string;
  73736. private _depthTexture;
  73737. /**
  73738. * Creates a new instance CircleOfConfusionPostProcess
  73739. * @param name The name of the effect.
  73740. * @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.
  73741. * @param options The required width/height ratio to downsize to before computing the render pass.
  73742. * @param camera The camera to apply the render pass to.
  73743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73744. * @param engine The engine which the post process will be applied. (default: current engine)
  73745. * @param reusable If the post process can be reused on the same frame. (default: false)
  73746. * @param textureType Type of textures used when performing the post process. (default: 0)
  73747. * @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)
  73748. */
  73749. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73750. /**
  73751. * 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.
  73752. */
  73753. set depthTexture(value: RenderTargetTexture);
  73754. }
  73755. }
  73756. declare module BABYLON {
  73757. /** @hidden */
  73758. export var colorCorrectionPixelShader: {
  73759. name: string;
  73760. shader: string;
  73761. };
  73762. }
  73763. declare module BABYLON {
  73764. /**
  73765. *
  73766. * This post-process allows the modification of rendered colors by using
  73767. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73768. *
  73769. * The object needs to be provided an url to a texture containing the color
  73770. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73771. * Use an image editing software to tweak the LUT to match your needs.
  73772. *
  73773. * For an example of a color LUT, see here:
  73774. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73775. * For explanations on color grading, see here:
  73776. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73777. *
  73778. */
  73779. export class ColorCorrectionPostProcess extends PostProcess {
  73780. private _colorTableTexture;
  73781. /**
  73782. * Gets the color table url used to create the LUT texture
  73783. */
  73784. colorTableUrl: string;
  73785. /**
  73786. * Gets a string identifying the name of the class
  73787. * @returns "ColorCorrectionPostProcess" string
  73788. */
  73789. getClassName(): string;
  73790. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73791. /** @hidden */
  73792. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73793. }
  73794. }
  73795. declare module BABYLON {
  73796. /** @hidden */
  73797. export var convolutionPixelShader: {
  73798. name: string;
  73799. shader: string;
  73800. };
  73801. }
  73802. declare module BABYLON {
  73803. /**
  73804. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73805. * input texture to perform effects such as edge detection or sharpening
  73806. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73807. */
  73808. export class ConvolutionPostProcess extends PostProcess {
  73809. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73810. kernel: number[];
  73811. /**
  73812. * Gets a string identifying the name of the class
  73813. * @returns "ConvolutionPostProcess" string
  73814. */
  73815. getClassName(): string;
  73816. /**
  73817. * Creates a new instance ConvolutionPostProcess
  73818. * @param name The name of the effect.
  73819. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73820. * @param options The required width/height ratio to downsize to before computing the render pass.
  73821. * @param camera The camera to apply the render pass to.
  73822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73823. * @param engine The engine which the post process will be applied. (default: current engine)
  73824. * @param reusable If the post process can be reused on the same frame. (default: false)
  73825. * @param textureType Type of textures used when performing the post process. (default: 0)
  73826. */
  73827. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73828. /** @hidden */
  73829. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73830. /**
  73831. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73832. */
  73833. static EdgeDetect0Kernel: number[];
  73834. /**
  73835. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73836. */
  73837. static EdgeDetect1Kernel: number[];
  73838. /**
  73839. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73840. */
  73841. static EdgeDetect2Kernel: number[];
  73842. /**
  73843. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73844. */
  73845. static SharpenKernel: number[];
  73846. /**
  73847. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73848. */
  73849. static EmbossKernel: number[];
  73850. /**
  73851. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73852. */
  73853. static GaussianKernel: number[];
  73854. }
  73855. }
  73856. declare module BABYLON {
  73857. /**
  73858. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73859. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73860. * based on samples that have a large difference in distance than the center pixel.
  73861. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73862. */
  73863. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73864. /**
  73865. * The direction the blur should be applied
  73866. */
  73867. direction: Vector2;
  73868. /**
  73869. * Gets a string identifying the name of the class
  73870. * @returns "DepthOfFieldBlurPostProcess" string
  73871. */
  73872. getClassName(): string;
  73873. /**
  73874. * Creates a new instance CircleOfConfusionPostProcess
  73875. * @param name The name of the effect.
  73876. * @param scene The scene the effect belongs to.
  73877. * @param direction The direction the blur should be applied.
  73878. * @param kernel The size of the kernel used to blur.
  73879. * @param options The required width/height ratio to downsize to before computing the render pass.
  73880. * @param camera The camera to apply the render pass to.
  73881. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73882. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73884. * @param engine The engine which the post process will be applied. (default: current engine)
  73885. * @param reusable If the post process can be reused on the same frame. (default: false)
  73886. * @param textureType Type of textures used when performing the post process. (default: 0)
  73887. * @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)
  73888. */
  73889. 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);
  73890. }
  73891. }
  73892. declare module BABYLON {
  73893. /** @hidden */
  73894. export var depthOfFieldMergePixelShader: {
  73895. name: string;
  73896. shader: string;
  73897. };
  73898. }
  73899. declare module BABYLON {
  73900. /**
  73901. * Options to be set when merging outputs from the default pipeline.
  73902. */
  73903. export class DepthOfFieldMergePostProcessOptions {
  73904. /**
  73905. * The original image to merge on top of
  73906. */
  73907. originalFromInput: PostProcess;
  73908. /**
  73909. * Parameters to perform the merge of the depth of field effect
  73910. */
  73911. depthOfField?: {
  73912. circleOfConfusion: PostProcess;
  73913. blurSteps: Array<PostProcess>;
  73914. };
  73915. /**
  73916. * Parameters to perform the merge of bloom effect
  73917. */
  73918. bloom?: {
  73919. blurred: PostProcess;
  73920. weight: number;
  73921. };
  73922. }
  73923. /**
  73924. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73925. */
  73926. export class DepthOfFieldMergePostProcess extends PostProcess {
  73927. private blurSteps;
  73928. /**
  73929. * Gets a string identifying the name of the class
  73930. * @returns "DepthOfFieldMergePostProcess" string
  73931. */
  73932. getClassName(): string;
  73933. /**
  73934. * Creates a new instance of DepthOfFieldMergePostProcess
  73935. * @param name The name of the effect.
  73936. * @param originalFromInput Post process which's input will be used for the merge.
  73937. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73938. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73939. * @param options The required width/height ratio to downsize to before computing the render pass.
  73940. * @param camera The camera to apply the render pass to.
  73941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73942. * @param engine The engine which the post process will be applied. (default: current engine)
  73943. * @param reusable If the post process can be reused on the same frame. (default: false)
  73944. * @param textureType Type of textures used when performing the post process. (default: 0)
  73945. * @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)
  73946. */
  73947. 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);
  73948. /**
  73949. * Updates the effect with the current post process compile time values and recompiles the shader.
  73950. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73951. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73952. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73953. * @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
  73954. * @param onCompiled Called when the shader has been compiled.
  73955. * @param onError Called if there is an error when compiling a shader.
  73956. */
  73957. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73958. }
  73959. }
  73960. declare module BABYLON {
  73961. /**
  73962. * Specifies the level of max blur that should be applied when using the depth of field effect
  73963. */
  73964. export enum DepthOfFieldEffectBlurLevel {
  73965. /**
  73966. * Subtle blur
  73967. */
  73968. Low = 0,
  73969. /**
  73970. * Medium blur
  73971. */
  73972. Medium = 1,
  73973. /**
  73974. * Large blur
  73975. */
  73976. High = 2
  73977. }
  73978. /**
  73979. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73980. */
  73981. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73982. private _circleOfConfusion;
  73983. /**
  73984. * @hidden Internal, blurs from high to low
  73985. */
  73986. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73987. private _depthOfFieldBlurY;
  73988. private _dofMerge;
  73989. /**
  73990. * @hidden Internal post processes in depth of field effect
  73991. */
  73992. _effects: Array<PostProcess>;
  73993. /**
  73994. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73995. */
  73996. set focalLength(value: number);
  73997. get focalLength(): number;
  73998. /**
  73999. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74000. */
  74001. set fStop(value: number);
  74002. get fStop(): number;
  74003. /**
  74004. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74005. */
  74006. set focusDistance(value: number);
  74007. get focusDistance(): number;
  74008. /**
  74009. * 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.
  74010. */
  74011. set lensSize(value: number);
  74012. get lensSize(): number;
  74013. /**
  74014. * Creates a new instance DepthOfFieldEffect
  74015. * @param scene The scene the effect belongs to.
  74016. * @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.
  74017. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74018. * @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)
  74019. */
  74020. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74021. /**
  74022. * Get the current class name of the current effet
  74023. * @returns "DepthOfFieldEffect"
  74024. */
  74025. getClassName(): string;
  74026. /**
  74027. * 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.
  74028. */
  74029. set depthTexture(value: RenderTargetTexture);
  74030. /**
  74031. * Disposes each of the internal effects for a given camera.
  74032. * @param camera The camera to dispose the effect on.
  74033. */
  74034. disposeEffects(camera: Camera): void;
  74035. /**
  74036. * @hidden Internal
  74037. */
  74038. _updateEffects(): void;
  74039. /**
  74040. * Internal
  74041. * @returns if all the contained post processes are ready.
  74042. * @hidden
  74043. */
  74044. _isReady(): boolean;
  74045. }
  74046. }
  74047. declare module BABYLON {
  74048. /** @hidden */
  74049. export var displayPassPixelShader: {
  74050. name: string;
  74051. shader: string;
  74052. };
  74053. }
  74054. declare module BABYLON {
  74055. /**
  74056. * DisplayPassPostProcess which produces an output the same as it's input
  74057. */
  74058. export class DisplayPassPostProcess extends PostProcess {
  74059. /**
  74060. * Gets a string identifying the name of the class
  74061. * @returns "DisplayPassPostProcess" string
  74062. */
  74063. getClassName(): string;
  74064. /**
  74065. * Creates the DisplayPassPostProcess
  74066. * @param name The name of the effect.
  74067. * @param options The required width/height ratio to downsize to before computing the render pass.
  74068. * @param camera The camera to apply the render pass to.
  74069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74070. * @param engine The engine which the post process will be applied. (default: current engine)
  74071. * @param reusable If the post process can be reused on the same frame. (default: false)
  74072. */
  74073. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74074. /** @hidden */
  74075. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74076. }
  74077. }
  74078. declare module BABYLON {
  74079. /** @hidden */
  74080. export var filterPixelShader: {
  74081. name: string;
  74082. shader: string;
  74083. };
  74084. }
  74085. declare module BABYLON {
  74086. /**
  74087. * Applies a kernel filter to the image
  74088. */
  74089. export class FilterPostProcess extends PostProcess {
  74090. /** The matrix to be applied to the image */
  74091. kernelMatrix: Matrix;
  74092. /**
  74093. * Gets a string identifying the name of the class
  74094. * @returns "FilterPostProcess" string
  74095. */
  74096. getClassName(): string;
  74097. /**
  74098. *
  74099. * @param name The name of the effect.
  74100. * @param kernelMatrix The matrix to be applied to the image
  74101. * @param options The required width/height ratio to downsize to before computing the render pass.
  74102. * @param camera The camera to apply the render pass to.
  74103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74104. * @param engine The engine which the post process will be applied. (default: current engine)
  74105. * @param reusable If the post process can be reused on the same frame. (default: false)
  74106. */
  74107. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74108. /** @hidden */
  74109. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74110. }
  74111. }
  74112. declare module BABYLON {
  74113. /** @hidden */
  74114. export var fxaaPixelShader: {
  74115. name: string;
  74116. shader: string;
  74117. };
  74118. }
  74119. declare module BABYLON {
  74120. /** @hidden */
  74121. export var fxaaVertexShader: {
  74122. name: string;
  74123. shader: string;
  74124. };
  74125. }
  74126. declare module BABYLON {
  74127. /**
  74128. * Fxaa post process
  74129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74130. */
  74131. export class FxaaPostProcess extends PostProcess {
  74132. /**
  74133. * Gets a string identifying the name of the class
  74134. * @returns "FxaaPostProcess" string
  74135. */
  74136. getClassName(): string;
  74137. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74138. private _getDefines;
  74139. /** @hidden */
  74140. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74141. }
  74142. }
  74143. declare module BABYLON {
  74144. /** @hidden */
  74145. export var grainPixelShader: {
  74146. name: string;
  74147. shader: string;
  74148. };
  74149. }
  74150. declare module BABYLON {
  74151. /**
  74152. * The GrainPostProcess adds noise to the image at mid luminance levels
  74153. */
  74154. export class GrainPostProcess extends PostProcess {
  74155. /**
  74156. * The intensity of the grain added (default: 30)
  74157. */
  74158. intensity: number;
  74159. /**
  74160. * If the grain should be randomized on every frame
  74161. */
  74162. animated: boolean;
  74163. /**
  74164. * Gets a string identifying the name of the class
  74165. * @returns "GrainPostProcess" string
  74166. */
  74167. getClassName(): string;
  74168. /**
  74169. * Creates a new instance of @see GrainPostProcess
  74170. * @param name The name of the effect.
  74171. * @param options The required width/height ratio to downsize to before computing the render pass.
  74172. * @param camera The camera to apply the render pass to.
  74173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74174. * @param engine The engine which the post process will be applied. (default: current engine)
  74175. * @param reusable If the post process can be reused on the same frame. (default: false)
  74176. * @param textureType Type of textures used when performing the post process. (default: 0)
  74177. * @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)
  74178. */
  74179. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74180. /** @hidden */
  74181. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74182. }
  74183. }
  74184. declare module BABYLON {
  74185. /** @hidden */
  74186. export var highlightsPixelShader: {
  74187. name: string;
  74188. shader: string;
  74189. };
  74190. }
  74191. declare module BABYLON {
  74192. /**
  74193. * Extracts highlights from the image
  74194. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74195. */
  74196. export class HighlightsPostProcess extends PostProcess {
  74197. /**
  74198. * Gets a string identifying the name of the class
  74199. * @returns "HighlightsPostProcess" string
  74200. */
  74201. getClassName(): string;
  74202. /**
  74203. * Extracts highlights from the image
  74204. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74205. * @param name The name of the effect.
  74206. * @param options The required width/height ratio to downsize to before computing the render pass.
  74207. * @param camera The camera to apply the render pass to.
  74208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74209. * @param engine The engine which the post process will be applied. (default: current engine)
  74210. * @param reusable If the post process can be reused on the same frame. (default: false)
  74211. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74212. */
  74213. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74214. }
  74215. }
  74216. declare module BABYLON {
  74217. /**
  74218. * Contains all parameters needed for the prepass to perform
  74219. * motion blur
  74220. */
  74221. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74222. /**
  74223. * Is motion blur enabled
  74224. */
  74225. enabled: boolean;
  74226. /**
  74227. * Name of the configuration
  74228. */
  74229. name: string;
  74230. /**
  74231. * Textures that should be present in the MRT for this effect to work
  74232. */
  74233. readonly texturesRequired: number[];
  74234. }
  74235. }
  74236. declare module BABYLON {
  74237. interface Scene {
  74238. /** @hidden (Backing field) */
  74239. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74240. /**
  74241. * Gets or Sets the current geometry buffer associated to the scene.
  74242. */
  74243. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74244. /**
  74245. * Enables a GeometryBufferRender and associates it with the scene
  74246. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74247. * @returns the GeometryBufferRenderer
  74248. */
  74249. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74250. /**
  74251. * Disables the GeometryBufferRender associated with the scene
  74252. */
  74253. disableGeometryBufferRenderer(): void;
  74254. }
  74255. /**
  74256. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74257. * in several rendering techniques.
  74258. */
  74259. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74260. /**
  74261. * The component name helpful to identify the component in the list of scene components.
  74262. */
  74263. readonly name: string;
  74264. /**
  74265. * The scene the component belongs to.
  74266. */
  74267. scene: Scene;
  74268. /**
  74269. * Creates a new instance of the component for the given scene
  74270. * @param scene Defines the scene to register the component in
  74271. */
  74272. constructor(scene: Scene);
  74273. /**
  74274. * Registers the component in a given scene
  74275. */
  74276. register(): void;
  74277. /**
  74278. * Rebuilds the elements related to this component in case of
  74279. * context lost for instance.
  74280. */
  74281. rebuild(): void;
  74282. /**
  74283. * Disposes the component and the associated ressources
  74284. */
  74285. dispose(): void;
  74286. private _gatherRenderTargets;
  74287. }
  74288. }
  74289. declare module BABYLON {
  74290. /** @hidden */
  74291. export var motionBlurPixelShader: {
  74292. name: string;
  74293. shader: string;
  74294. };
  74295. }
  74296. declare module BABYLON {
  74297. /**
  74298. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74299. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74300. * As an example, all you have to do is to create the post-process:
  74301. * var mb = new BABYLON.MotionBlurPostProcess(
  74302. * 'mb', // The name of the effect.
  74303. * scene, // The scene containing the objects to blur according to their velocity.
  74304. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74305. * camera // The camera to apply the render pass to.
  74306. * );
  74307. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74308. */
  74309. export class MotionBlurPostProcess extends PostProcess {
  74310. /**
  74311. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74312. */
  74313. motionStrength: number;
  74314. /**
  74315. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74316. */
  74317. get motionBlurSamples(): number;
  74318. /**
  74319. * Sets the number of iterations to be used for motion blur quality
  74320. */
  74321. set motionBlurSamples(samples: number);
  74322. private _motionBlurSamples;
  74323. /**
  74324. * Gets wether or not the motion blur post-process is in object based mode.
  74325. */
  74326. get isObjectBased(): boolean;
  74327. /**
  74328. * Sets wether or not the motion blur post-process is in object based mode.
  74329. */
  74330. set isObjectBased(value: boolean);
  74331. private _isObjectBased;
  74332. private _forceGeometryBuffer;
  74333. private _geometryBufferRenderer;
  74334. private _prePassRenderer;
  74335. private _invViewProjection;
  74336. private _previousViewProjection;
  74337. /**
  74338. * Gets a string identifying the name of the class
  74339. * @returns "MotionBlurPostProcess" string
  74340. */
  74341. getClassName(): string;
  74342. /**
  74343. * Creates a new instance MotionBlurPostProcess
  74344. * @param name The name of the effect.
  74345. * @param scene The scene containing the objects to blur according to their velocity.
  74346. * @param options The required width/height ratio to downsize to before computing the render pass.
  74347. * @param camera The camera to apply the render pass to.
  74348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74349. * @param engine The engine which the post process will be applied. (default: current engine)
  74350. * @param reusable If the post process can be reused on the same frame. (default: false)
  74351. * @param textureType Type of textures used when performing the post process. (default: 0)
  74352. * @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)
  74353. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74354. */
  74355. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74356. /**
  74357. * Excludes the given skinned mesh from computing bones velocities.
  74358. * 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.
  74359. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74360. */
  74361. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74362. /**
  74363. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74364. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74365. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74366. */
  74367. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74368. /**
  74369. * Disposes the post process.
  74370. * @param camera The camera to dispose the post process on.
  74371. */
  74372. dispose(camera?: Camera): void;
  74373. /**
  74374. * Called on the mode changed (object based or screen based).
  74375. */
  74376. private _applyMode;
  74377. /**
  74378. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74379. */
  74380. private _onApplyObjectBased;
  74381. /**
  74382. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74383. */
  74384. private _onApplyScreenBased;
  74385. /**
  74386. * Called on the effect must be updated (changed mode, samples count, etc.).
  74387. */
  74388. private _updateEffect;
  74389. /** @hidden */
  74390. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74391. }
  74392. }
  74393. declare module BABYLON {
  74394. /** @hidden */
  74395. export var refractionPixelShader: {
  74396. name: string;
  74397. shader: string;
  74398. };
  74399. }
  74400. declare module BABYLON {
  74401. /**
  74402. * Post process which applies a refractin texture
  74403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74404. */
  74405. export class RefractionPostProcess extends PostProcess {
  74406. private _refTexture;
  74407. private _ownRefractionTexture;
  74408. /** the base color of the refraction (used to taint the rendering) */
  74409. color: Color3;
  74410. /** simulated refraction depth */
  74411. depth: number;
  74412. /** the coefficient of the base color (0 to remove base color tainting) */
  74413. colorLevel: number;
  74414. /** Gets the url used to load the refraction texture */
  74415. refractionTextureUrl: string;
  74416. /**
  74417. * Gets or sets the refraction texture
  74418. * Please note that you are responsible for disposing the texture if you set it manually
  74419. */
  74420. get refractionTexture(): Texture;
  74421. set refractionTexture(value: Texture);
  74422. /**
  74423. * Gets a string identifying the name of the class
  74424. * @returns "RefractionPostProcess" string
  74425. */
  74426. getClassName(): string;
  74427. /**
  74428. * Initializes the RefractionPostProcess
  74429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74430. * @param name The name of the effect.
  74431. * @param refractionTextureUrl Url of the refraction texture to use
  74432. * @param color the base color of the refraction (used to taint the rendering)
  74433. * @param depth simulated refraction depth
  74434. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74435. * @param camera The camera to apply the render pass to.
  74436. * @param options The required width/height ratio to downsize to before computing the render pass.
  74437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74438. * @param engine The engine which the post process will be applied. (default: current engine)
  74439. * @param reusable If the post process can be reused on the same frame. (default: false)
  74440. */
  74441. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74442. /**
  74443. * Disposes of the post process
  74444. * @param camera Camera to dispose post process on
  74445. */
  74446. dispose(camera: Camera): void;
  74447. /** @hidden */
  74448. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74449. }
  74450. }
  74451. declare module BABYLON {
  74452. /** @hidden */
  74453. export var sharpenPixelShader: {
  74454. name: string;
  74455. shader: string;
  74456. };
  74457. }
  74458. declare module BABYLON {
  74459. /**
  74460. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74461. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74462. */
  74463. export class SharpenPostProcess extends PostProcess {
  74464. /**
  74465. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74466. */
  74467. colorAmount: number;
  74468. /**
  74469. * How much sharpness should be applied (default: 0.3)
  74470. */
  74471. edgeAmount: number;
  74472. /**
  74473. * Gets a string identifying the name of the class
  74474. * @returns "SharpenPostProcess" string
  74475. */
  74476. getClassName(): string;
  74477. /**
  74478. * Creates a new instance ConvolutionPostProcess
  74479. * @param name The name of the effect.
  74480. * @param options The required width/height ratio to downsize to before computing the render pass.
  74481. * @param camera The camera to apply the render pass to.
  74482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74483. * @param engine The engine which the post process will be applied. (default: current engine)
  74484. * @param reusable If the post process can be reused on the same frame. (default: false)
  74485. * @param textureType Type of textures used when performing the post process. (default: 0)
  74486. * @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)
  74487. */
  74488. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74489. /** @hidden */
  74490. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74491. }
  74492. }
  74493. declare module BABYLON {
  74494. /**
  74495. * PostProcessRenderPipeline
  74496. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74497. */
  74498. export class PostProcessRenderPipeline {
  74499. private engine;
  74500. private _renderEffects;
  74501. private _renderEffectsForIsolatedPass;
  74502. /**
  74503. * List of inspectable custom properties (used by the Inspector)
  74504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74505. */
  74506. inspectableCustomProperties: IInspectable[];
  74507. /**
  74508. * @hidden
  74509. */
  74510. protected _cameras: Camera[];
  74511. /** @hidden */
  74512. _name: string;
  74513. /**
  74514. * Gets pipeline name
  74515. */
  74516. get name(): string;
  74517. /** Gets the list of attached cameras */
  74518. get cameras(): Camera[];
  74519. /**
  74520. * Initializes a PostProcessRenderPipeline
  74521. * @param engine engine to add the pipeline to
  74522. * @param name name of the pipeline
  74523. */
  74524. constructor(engine: Engine, name: string);
  74525. /**
  74526. * Gets the class name
  74527. * @returns "PostProcessRenderPipeline"
  74528. */
  74529. getClassName(): string;
  74530. /**
  74531. * If all the render effects in the pipeline are supported
  74532. */
  74533. get isSupported(): boolean;
  74534. /**
  74535. * Adds an effect to the pipeline
  74536. * @param renderEffect the effect to add
  74537. */
  74538. addEffect(renderEffect: PostProcessRenderEffect): void;
  74539. /** @hidden */
  74540. _rebuild(): void;
  74541. /** @hidden */
  74542. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74543. /** @hidden */
  74544. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74545. /** @hidden */
  74546. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74547. /** @hidden */
  74548. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74549. /** @hidden */
  74550. _attachCameras(cameras: Camera, unique: boolean): void;
  74551. /** @hidden */
  74552. _attachCameras(cameras: Camera[], unique: boolean): void;
  74553. /** @hidden */
  74554. _detachCameras(cameras: Camera): void;
  74555. /** @hidden */
  74556. _detachCameras(cameras: Nullable<Camera[]>): void;
  74557. /** @hidden */
  74558. _update(): void;
  74559. /** @hidden */
  74560. _reset(): void;
  74561. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74562. /**
  74563. * Sets the required values to the prepass renderer.
  74564. * @param prePassRenderer defines the prepass renderer to setup.
  74565. * @returns true if the pre pass is needed.
  74566. */
  74567. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74568. /**
  74569. * Disposes of the pipeline
  74570. */
  74571. dispose(): void;
  74572. }
  74573. }
  74574. declare module BABYLON {
  74575. /**
  74576. * PostProcessRenderPipelineManager class
  74577. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74578. */
  74579. export class PostProcessRenderPipelineManager {
  74580. private _renderPipelines;
  74581. /**
  74582. * Initializes a PostProcessRenderPipelineManager
  74583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74584. */
  74585. constructor();
  74586. /**
  74587. * Gets the list of supported render pipelines
  74588. */
  74589. get supportedPipelines(): PostProcessRenderPipeline[];
  74590. /**
  74591. * Adds a pipeline to the manager
  74592. * @param renderPipeline The pipeline to add
  74593. */
  74594. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74595. /**
  74596. * Attaches a camera to the pipeline
  74597. * @param renderPipelineName The name of the pipeline to attach to
  74598. * @param cameras the camera to attach
  74599. * @param unique if the camera can be attached multiple times to the pipeline
  74600. */
  74601. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74602. /**
  74603. * Detaches a camera from the pipeline
  74604. * @param renderPipelineName The name of the pipeline to detach from
  74605. * @param cameras the camera to detach
  74606. */
  74607. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74608. /**
  74609. * Enables an effect by name on a pipeline
  74610. * @param renderPipelineName the name of the pipeline to enable the effect in
  74611. * @param renderEffectName the name of the effect to enable
  74612. * @param cameras the cameras that the effect should be enabled on
  74613. */
  74614. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74615. /**
  74616. * Disables an effect by name on a pipeline
  74617. * @param renderPipelineName the name of the pipeline to disable the effect in
  74618. * @param renderEffectName the name of the effect to disable
  74619. * @param cameras the cameras that the effect should be disabled on
  74620. */
  74621. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74622. /**
  74623. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74624. */
  74625. update(): void;
  74626. /** @hidden */
  74627. _rebuild(): void;
  74628. /**
  74629. * Disposes of the manager and pipelines
  74630. */
  74631. dispose(): void;
  74632. }
  74633. }
  74634. declare module BABYLON {
  74635. interface Scene {
  74636. /** @hidden (Backing field) */
  74637. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74638. /**
  74639. * Gets the postprocess render pipeline manager
  74640. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74641. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74642. */
  74643. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74644. }
  74645. /**
  74646. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74647. */
  74648. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74649. /**
  74650. * The component name helpfull to identify the component in the list of scene components.
  74651. */
  74652. readonly name: string;
  74653. /**
  74654. * The scene the component belongs to.
  74655. */
  74656. scene: Scene;
  74657. /**
  74658. * Creates a new instance of the component for the given scene
  74659. * @param scene Defines the scene to register the component in
  74660. */
  74661. constructor(scene: Scene);
  74662. /**
  74663. * Registers the component in a given scene
  74664. */
  74665. register(): void;
  74666. /**
  74667. * Rebuilds the elements related to this component in case of
  74668. * context lost for instance.
  74669. */
  74670. rebuild(): void;
  74671. /**
  74672. * Disposes the component and the associated ressources
  74673. */
  74674. dispose(): void;
  74675. private _gatherRenderTargets;
  74676. }
  74677. }
  74678. declare module BABYLON {
  74679. /**
  74680. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74681. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74682. */
  74683. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74684. private _scene;
  74685. private _camerasToBeAttached;
  74686. /**
  74687. * ID of the sharpen post process,
  74688. */
  74689. private readonly SharpenPostProcessId;
  74690. /**
  74691. * @ignore
  74692. * ID of the image processing post process;
  74693. */
  74694. readonly ImageProcessingPostProcessId: string;
  74695. /**
  74696. * @ignore
  74697. * ID of the Fast Approximate Anti-Aliasing post process;
  74698. */
  74699. readonly FxaaPostProcessId: string;
  74700. /**
  74701. * ID of the chromatic aberration post process,
  74702. */
  74703. private readonly ChromaticAberrationPostProcessId;
  74704. /**
  74705. * ID of the grain post process
  74706. */
  74707. private readonly GrainPostProcessId;
  74708. /**
  74709. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74710. */
  74711. sharpen: SharpenPostProcess;
  74712. private _sharpenEffect;
  74713. private bloom;
  74714. /**
  74715. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74716. */
  74717. depthOfField: DepthOfFieldEffect;
  74718. /**
  74719. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74720. */
  74721. fxaa: FxaaPostProcess;
  74722. /**
  74723. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74724. */
  74725. imageProcessing: ImageProcessingPostProcess;
  74726. /**
  74727. * Chromatic aberration post process which will shift rgb colors in the image
  74728. */
  74729. chromaticAberration: ChromaticAberrationPostProcess;
  74730. private _chromaticAberrationEffect;
  74731. /**
  74732. * Grain post process which add noise to the image
  74733. */
  74734. grain: GrainPostProcess;
  74735. private _grainEffect;
  74736. /**
  74737. * Glow post process which adds a glow to emissive areas of the image
  74738. */
  74739. private _glowLayer;
  74740. /**
  74741. * Animations which can be used to tweak settings over a period of time
  74742. */
  74743. animations: Animation[];
  74744. private _imageProcessingConfigurationObserver;
  74745. private _sharpenEnabled;
  74746. private _bloomEnabled;
  74747. private _depthOfFieldEnabled;
  74748. private _depthOfFieldBlurLevel;
  74749. private _fxaaEnabled;
  74750. private _imageProcessingEnabled;
  74751. private _defaultPipelineTextureType;
  74752. private _bloomScale;
  74753. private _chromaticAberrationEnabled;
  74754. private _grainEnabled;
  74755. private _buildAllowed;
  74756. /**
  74757. * This is triggered each time the pipeline has been built.
  74758. */
  74759. onBuildObservable: Observable<DefaultRenderingPipeline>;
  74760. /**
  74761. * Gets active scene
  74762. */
  74763. get scene(): Scene;
  74764. /**
  74765. * Enable or disable the sharpen process from the pipeline
  74766. */
  74767. set sharpenEnabled(enabled: boolean);
  74768. get sharpenEnabled(): boolean;
  74769. private _resizeObserver;
  74770. private _hardwareScaleLevel;
  74771. private _bloomKernel;
  74772. /**
  74773. * Specifies the size of the bloom blur kernel, relative to the final output size
  74774. */
  74775. get bloomKernel(): number;
  74776. set bloomKernel(value: number);
  74777. /**
  74778. * Specifies the weight of the bloom in the final rendering
  74779. */
  74780. private _bloomWeight;
  74781. /**
  74782. * Specifies the luma threshold for the area that will be blurred by the bloom
  74783. */
  74784. private _bloomThreshold;
  74785. private _hdr;
  74786. /**
  74787. * The strength of the bloom.
  74788. */
  74789. set bloomWeight(value: number);
  74790. get bloomWeight(): number;
  74791. /**
  74792. * The strength of the bloom.
  74793. */
  74794. set bloomThreshold(value: number);
  74795. get bloomThreshold(): number;
  74796. /**
  74797. * The scale of the bloom, lower value will provide better performance.
  74798. */
  74799. set bloomScale(value: number);
  74800. get bloomScale(): number;
  74801. /**
  74802. * Enable or disable the bloom from the pipeline
  74803. */
  74804. set bloomEnabled(enabled: boolean);
  74805. get bloomEnabled(): boolean;
  74806. private _rebuildBloom;
  74807. /**
  74808. * If the depth of field is enabled.
  74809. */
  74810. get depthOfFieldEnabled(): boolean;
  74811. set depthOfFieldEnabled(enabled: boolean);
  74812. /**
  74813. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74814. */
  74815. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74816. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74817. /**
  74818. * If the anti aliasing is enabled.
  74819. */
  74820. set fxaaEnabled(enabled: boolean);
  74821. get fxaaEnabled(): boolean;
  74822. private _samples;
  74823. /**
  74824. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74825. */
  74826. set samples(sampleCount: number);
  74827. get samples(): number;
  74828. /**
  74829. * If image processing is enabled.
  74830. */
  74831. set imageProcessingEnabled(enabled: boolean);
  74832. get imageProcessingEnabled(): boolean;
  74833. /**
  74834. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74835. */
  74836. set glowLayerEnabled(enabled: boolean);
  74837. get glowLayerEnabled(): boolean;
  74838. /**
  74839. * Gets the glow layer (or null if not defined)
  74840. */
  74841. get glowLayer(): Nullable<GlowLayer>;
  74842. /**
  74843. * Enable or disable the chromaticAberration process from the pipeline
  74844. */
  74845. set chromaticAberrationEnabled(enabled: boolean);
  74846. get chromaticAberrationEnabled(): boolean;
  74847. /**
  74848. * Enable or disable the grain process from the pipeline
  74849. */
  74850. set grainEnabled(enabled: boolean);
  74851. get grainEnabled(): boolean;
  74852. /**
  74853. * @constructor
  74854. * @param name - The rendering pipeline name (default: "")
  74855. * @param hdr - If high dynamic range textures should be used (default: true)
  74856. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74857. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74858. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74859. */
  74860. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74861. /**
  74862. * Get the class name
  74863. * @returns "DefaultRenderingPipeline"
  74864. */
  74865. getClassName(): string;
  74866. /**
  74867. * Force the compilation of the entire pipeline.
  74868. */
  74869. prepare(): void;
  74870. private _hasCleared;
  74871. private _prevPostProcess;
  74872. private _prevPrevPostProcess;
  74873. private _setAutoClearAndTextureSharing;
  74874. private _depthOfFieldSceneObserver;
  74875. private _buildPipeline;
  74876. private _disposePostProcesses;
  74877. /**
  74878. * Adds a camera to the pipeline
  74879. * @param camera the camera to be added
  74880. */
  74881. addCamera(camera: Camera): void;
  74882. /**
  74883. * Removes a camera from the pipeline
  74884. * @param camera the camera to remove
  74885. */
  74886. removeCamera(camera: Camera): void;
  74887. /**
  74888. * Dispose of the pipeline and stop all post processes
  74889. */
  74890. dispose(): void;
  74891. /**
  74892. * Serialize the rendering pipeline (Used when exporting)
  74893. * @returns the serialized object
  74894. */
  74895. serialize(): any;
  74896. /**
  74897. * Parse the serialized pipeline
  74898. * @param source Source pipeline.
  74899. * @param scene The scene to load the pipeline to.
  74900. * @param rootUrl The URL of the serialized pipeline.
  74901. * @returns An instantiated pipeline from the serialized object.
  74902. */
  74903. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74904. }
  74905. }
  74906. declare module BABYLON {
  74907. /** @hidden */
  74908. export var lensHighlightsPixelShader: {
  74909. name: string;
  74910. shader: string;
  74911. };
  74912. }
  74913. declare module BABYLON {
  74914. /** @hidden */
  74915. export var depthOfFieldPixelShader: {
  74916. name: string;
  74917. shader: string;
  74918. };
  74919. }
  74920. declare module BABYLON {
  74921. /**
  74922. * BABYLON.JS Chromatic Aberration GLSL Shader
  74923. * Author: Olivier Guyot
  74924. * Separates very slightly R, G and B colors on the edges of the screen
  74925. * Inspired by Francois Tarlier & Martins Upitis
  74926. */
  74927. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74928. /**
  74929. * @ignore
  74930. * The chromatic aberration PostProcess id in the pipeline
  74931. */
  74932. LensChromaticAberrationEffect: string;
  74933. /**
  74934. * @ignore
  74935. * The highlights enhancing PostProcess id in the pipeline
  74936. */
  74937. HighlightsEnhancingEffect: string;
  74938. /**
  74939. * @ignore
  74940. * The depth-of-field PostProcess id in the pipeline
  74941. */
  74942. LensDepthOfFieldEffect: string;
  74943. private _scene;
  74944. private _depthTexture;
  74945. private _grainTexture;
  74946. private _chromaticAberrationPostProcess;
  74947. private _highlightsPostProcess;
  74948. private _depthOfFieldPostProcess;
  74949. private _edgeBlur;
  74950. private _grainAmount;
  74951. private _chromaticAberration;
  74952. private _distortion;
  74953. private _highlightsGain;
  74954. private _highlightsThreshold;
  74955. private _dofDistance;
  74956. private _dofAperture;
  74957. private _dofDarken;
  74958. private _dofPentagon;
  74959. private _blurNoise;
  74960. /**
  74961. * @constructor
  74962. *
  74963. * Effect parameters are as follow:
  74964. * {
  74965. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74966. * edge_blur: number; // from 0 to x (1 for realism)
  74967. * distortion: number; // from 0 to x (1 for realism)
  74968. * grain_amount: number; // from 0 to 1
  74969. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74970. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74971. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74972. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74973. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74974. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74975. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74976. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74977. * }
  74978. * Note: if an effect parameter is unset, effect is disabled
  74979. *
  74980. * @param name The rendering pipeline name
  74981. * @param parameters - An object containing all parameters (see above)
  74982. * @param scene The scene linked to this pipeline
  74983. * @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)
  74984. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74985. */
  74986. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74987. /**
  74988. * Get the class name
  74989. * @returns "LensRenderingPipeline"
  74990. */
  74991. getClassName(): string;
  74992. /**
  74993. * Gets associated scene
  74994. */
  74995. get scene(): Scene;
  74996. /**
  74997. * Gets or sets the edge blur
  74998. */
  74999. get edgeBlur(): number;
  75000. set edgeBlur(value: number);
  75001. /**
  75002. * Gets or sets the grain amount
  75003. */
  75004. get grainAmount(): number;
  75005. set grainAmount(value: number);
  75006. /**
  75007. * Gets or sets the chromatic aberration amount
  75008. */
  75009. get chromaticAberration(): number;
  75010. set chromaticAberration(value: number);
  75011. /**
  75012. * Gets or sets the depth of field aperture
  75013. */
  75014. get dofAperture(): number;
  75015. set dofAperture(value: number);
  75016. /**
  75017. * Gets or sets the edge distortion
  75018. */
  75019. get edgeDistortion(): number;
  75020. set edgeDistortion(value: number);
  75021. /**
  75022. * Gets or sets the depth of field distortion
  75023. */
  75024. get dofDistortion(): number;
  75025. set dofDistortion(value: number);
  75026. /**
  75027. * Gets or sets the darken out of focus amount
  75028. */
  75029. get darkenOutOfFocus(): number;
  75030. set darkenOutOfFocus(value: number);
  75031. /**
  75032. * Gets or sets a boolean indicating if blur noise is enabled
  75033. */
  75034. get blurNoise(): boolean;
  75035. set blurNoise(value: boolean);
  75036. /**
  75037. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75038. */
  75039. get pentagonBokeh(): boolean;
  75040. set pentagonBokeh(value: boolean);
  75041. /**
  75042. * Gets or sets the highlight grain amount
  75043. */
  75044. get highlightsGain(): number;
  75045. set highlightsGain(value: number);
  75046. /**
  75047. * Gets or sets the highlight threshold
  75048. */
  75049. get highlightsThreshold(): number;
  75050. set highlightsThreshold(value: number);
  75051. /**
  75052. * Sets the amount of blur at the edges
  75053. * @param amount blur amount
  75054. */
  75055. setEdgeBlur(amount: number): void;
  75056. /**
  75057. * Sets edge blur to 0
  75058. */
  75059. disableEdgeBlur(): void;
  75060. /**
  75061. * Sets the amout of grain
  75062. * @param amount Amount of grain
  75063. */
  75064. setGrainAmount(amount: number): void;
  75065. /**
  75066. * Set grain amount to 0
  75067. */
  75068. disableGrain(): void;
  75069. /**
  75070. * Sets the chromatic aberration amount
  75071. * @param amount amount of chromatic aberration
  75072. */
  75073. setChromaticAberration(amount: number): void;
  75074. /**
  75075. * Sets chromatic aberration amount to 0
  75076. */
  75077. disableChromaticAberration(): void;
  75078. /**
  75079. * Sets the EdgeDistortion amount
  75080. * @param amount amount of EdgeDistortion
  75081. */
  75082. setEdgeDistortion(amount: number): void;
  75083. /**
  75084. * Sets edge distortion to 0
  75085. */
  75086. disableEdgeDistortion(): void;
  75087. /**
  75088. * Sets the FocusDistance amount
  75089. * @param amount amount of FocusDistance
  75090. */
  75091. setFocusDistance(amount: number): void;
  75092. /**
  75093. * Disables depth of field
  75094. */
  75095. disableDepthOfField(): void;
  75096. /**
  75097. * Sets the Aperture amount
  75098. * @param amount amount of Aperture
  75099. */
  75100. setAperture(amount: number): void;
  75101. /**
  75102. * Sets the DarkenOutOfFocus amount
  75103. * @param amount amount of DarkenOutOfFocus
  75104. */
  75105. setDarkenOutOfFocus(amount: number): void;
  75106. private _pentagonBokehIsEnabled;
  75107. /**
  75108. * Creates a pentagon bokeh effect
  75109. */
  75110. enablePentagonBokeh(): void;
  75111. /**
  75112. * Disables the pentagon bokeh effect
  75113. */
  75114. disablePentagonBokeh(): void;
  75115. /**
  75116. * Enables noise blur
  75117. */
  75118. enableNoiseBlur(): void;
  75119. /**
  75120. * Disables noise blur
  75121. */
  75122. disableNoiseBlur(): void;
  75123. /**
  75124. * Sets the HighlightsGain amount
  75125. * @param amount amount of HighlightsGain
  75126. */
  75127. setHighlightsGain(amount: number): void;
  75128. /**
  75129. * Sets the HighlightsThreshold amount
  75130. * @param amount amount of HighlightsThreshold
  75131. */
  75132. setHighlightsThreshold(amount: number): void;
  75133. /**
  75134. * Disables highlights
  75135. */
  75136. disableHighlights(): void;
  75137. /**
  75138. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75139. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75140. */
  75141. dispose(disableDepthRender?: boolean): void;
  75142. private _createChromaticAberrationPostProcess;
  75143. private _createHighlightsPostProcess;
  75144. private _createDepthOfFieldPostProcess;
  75145. private _createGrainTexture;
  75146. }
  75147. }
  75148. declare module BABYLON {
  75149. /**
  75150. * Contains all parameters needed for the prepass to perform
  75151. * screen space subsurface scattering
  75152. */
  75153. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75154. /**
  75155. * Is subsurface enabled
  75156. */
  75157. enabled: boolean;
  75158. /**
  75159. * Name of the configuration
  75160. */
  75161. name: string;
  75162. /**
  75163. * Textures that should be present in the MRT for this effect to work
  75164. */
  75165. readonly texturesRequired: number[];
  75166. }
  75167. }
  75168. declare module BABYLON {
  75169. /** @hidden */
  75170. export var ssao2PixelShader: {
  75171. name: string;
  75172. shader: string;
  75173. };
  75174. }
  75175. declare module BABYLON {
  75176. /** @hidden */
  75177. export var ssaoCombinePixelShader: {
  75178. name: string;
  75179. shader: string;
  75180. };
  75181. }
  75182. declare module BABYLON {
  75183. /**
  75184. * Render pipeline to produce ssao effect
  75185. */
  75186. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75187. /**
  75188. * @ignore
  75189. * The PassPostProcess id in the pipeline that contains the original scene color
  75190. */
  75191. SSAOOriginalSceneColorEffect: string;
  75192. /**
  75193. * @ignore
  75194. * The SSAO PostProcess id in the pipeline
  75195. */
  75196. SSAORenderEffect: string;
  75197. /**
  75198. * @ignore
  75199. * The horizontal blur PostProcess id in the pipeline
  75200. */
  75201. SSAOBlurHRenderEffect: string;
  75202. /**
  75203. * @ignore
  75204. * The vertical blur PostProcess id in the pipeline
  75205. */
  75206. SSAOBlurVRenderEffect: string;
  75207. /**
  75208. * @ignore
  75209. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75210. */
  75211. SSAOCombineRenderEffect: string;
  75212. /**
  75213. * The output strength of the SSAO post-process. Default value is 1.0.
  75214. */
  75215. totalStrength: number;
  75216. /**
  75217. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75218. */
  75219. maxZ: number;
  75220. /**
  75221. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75222. */
  75223. minZAspect: number;
  75224. private _samples;
  75225. /**
  75226. * Number of samples used for the SSAO calculations. Default value is 8
  75227. */
  75228. set samples(n: number);
  75229. get samples(): number;
  75230. private _textureSamples;
  75231. /**
  75232. * Number of samples to use for antialiasing
  75233. */
  75234. set textureSamples(n: number);
  75235. get textureSamples(): number;
  75236. /**
  75237. * Force rendering the geometry through geometry buffer
  75238. */
  75239. private _forceGeometryBuffer;
  75240. /**
  75241. * Ratio object used for SSAO ratio and blur ratio
  75242. */
  75243. private _ratio;
  75244. /**
  75245. * Dynamically generated sphere sampler.
  75246. */
  75247. private _sampleSphere;
  75248. /**
  75249. * Blur filter offsets
  75250. */
  75251. private _samplerOffsets;
  75252. private _expensiveBlur;
  75253. /**
  75254. * If bilateral blur should be used
  75255. */
  75256. set expensiveBlur(b: boolean);
  75257. get expensiveBlur(): boolean;
  75258. /**
  75259. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75260. */
  75261. radius: number;
  75262. /**
  75263. * The base color of the SSAO post-process
  75264. * The final result is "base + ssao" between [0, 1]
  75265. */
  75266. base: number;
  75267. /**
  75268. * Support test.
  75269. */
  75270. static get IsSupported(): boolean;
  75271. private _scene;
  75272. private _randomTexture;
  75273. private _originalColorPostProcess;
  75274. private _ssaoPostProcess;
  75275. private _blurHPostProcess;
  75276. private _blurVPostProcess;
  75277. private _ssaoCombinePostProcess;
  75278. private _prePassRenderer;
  75279. /**
  75280. * Gets active scene
  75281. */
  75282. get scene(): Scene;
  75283. /**
  75284. * @constructor
  75285. * @param name The rendering pipeline name
  75286. * @param scene The scene linked to this pipeline
  75287. * @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 }
  75288. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75289. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75290. */
  75291. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75292. /**
  75293. * Get the class name
  75294. * @returns "SSAO2RenderingPipeline"
  75295. */
  75296. getClassName(): string;
  75297. /**
  75298. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75299. */
  75300. dispose(disableGeometryBufferRenderer?: boolean): void;
  75301. private _createBlurPostProcess;
  75302. /** @hidden */
  75303. _rebuild(): void;
  75304. private _bits;
  75305. private _radicalInverse_VdC;
  75306. private _hammersley;
  75307. private _hemisphereSample_uniform;
  75308. private _generateHemisphere;
  75309. private _getDefinesForSSAO;
  75310. private static readonly ORTHO_DEPTH_PROJECTION;
  75311. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75312. private _createSSAOPostProcess;
  75313. private _createSSAOCombinePostProcess;
  75314. private _createRandomTexture;
  75315. /**
  75316. * Serialize the rendering pipeline (Used when exporting)
  75317. * @returns the serialized object
  75318. */
  75319. serialize(): any;
  75320. /**
  75321. * Parse the serialized pipeline
  75322. * @param source Source pipeline.
  75323. * @param scene The scene to load the pipeline to.
  75324. * @param rootUrl The URL of the serialized pipeline.
  75325. * @returns An instantiated pipeline from the serialized object.
  75326. */
  75327. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75328. }
  75329. }
  75330. declare module BABYLON {
  75331. /** @hidden */
  75332. export var ssaoPixelShader: {
  75333. name: string;
  75334. shader: string;
  75335. };
  75336. }
  75337. declare module BABYLON {
  75338. /**
  75339. * Render pipeline to produce ssao effect
  75340. */
  75341. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75342. /**
  75343. * @ignore
  75344. * The PassPostProcess id in the pipeline that contains the original scene color
  75345. */
  75346. SSAOOriginalSceneColorEffect: string;
  75347. /**
  75348. * @ignore
  75349. * The SSAO PostProcess id in the pipeline
  75350. */
  75351. SSAORenderEffect: string;
  75352. /**
  75353. * @ignore
  75354. * The horizontal blur PostProcess id in the pipeline
  75355. */
  75356. SSAOBlurHRenderEffect: string;
  75357. /**
  75358. * @ignore
  75359. * The vertical blur PostProcess id in the pipeline
  75360. */
  75361. SSAOBlurVRenderEffect: string;
  75362. /**
  75363. * @ignore
  75364. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75365. */
  75366. SSAOCombineRenderEffect: string;
  75367. /**
  75368. * The output strength of the SSAO post-process. Default value is 1.0.
  75369. */
  75370. totalStrength: number;
  75371. /**
  75372. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75373. */
  75374. radius: number;
  75375. /**
  75376. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75377. * Must not be equal to fallOff and superior to fallOff.
  75378. * Default value is 0.0075
  75379. */
  75380. area: number;
  75381. /**
  75382. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75383. * Must not be equal to area and inferior to area.
  75384. * Default value is 0.000001
  75385. */
  75386. fallOff: number;
  75387. /**
  75388. * The base color of the SSAO post-process
  75389. * The final result is "base + ssao" between [0, 1]
  75390. */
  75391. base: number;
  75392. private _scene;
  75393. private _depthTexture;
  75394. private _randomTexture;
  75395. private _originalColorPostProcess;
  75396. private _ssaoPostProcess;
  75397. private _blurHPostProcess;
  75398. private _blurVPostProcess;
  75399. private _ssaoCombinePostProcess;
  75400. private _firstUpdate;
  75401. /**
  75402. * Gets active scene
  75403. */
  75404. get scene(): Scene;
  75405. /**
  75406. * @constructor
  75407. * @param name - The rendering pipeline name
  75408. * @param scene - The scene linked to this pipeline
  75409. * @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 }
  75410. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75411. */
  75412. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75413. /**
  75414. * Get the class name
  75415. * @returns "SSAORenderingPipeline"
  75416. */
  75417. getClassName(): string;
  75418. /**
  75419. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75420. */
  75421. dispose(disableDepthRender?: boolean): void;
  75422. private _createBlurPostProcess;
  75423. /** @hidden */
  75424. _rebuild(): void;
  75425. private _createSSAOPostProcess;
  75426. private _createSSAOCombinePostProcess;
  75427. private _createRandomTexture;
  75428. }
  75429. }
  75430. declare module BABYLON {
  75431. /**
  75432. * Contains all parameters needed for the prepass to perform
  75433. * screen space reflections
  75434. */
  75435. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75436. /**
  75437. * Is ssr enabled
  75438. */
  75439. enabled: boolean;
  75440. /**
  75441. * Name of the configuration
  75442. */
  75443. name: string;
  75444. /**
  75445. * Textures that should be present in the MRT for this effect to work
  75446. */
  75447. readonly texturesRequired: number[];
  75448. }
  75449. }
  75450. declare module BABYLON {
  75451. /** @hidden */
  75452. export var screenSpaceReflectionPixelShader: {
  75453. name: string;
  75454. shader: string;
  75455. };
  75456. }
  75457. declare module BABYLON {
  75458. /**
  75459. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75460. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75461. */
  75462. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75463. /**
  75464. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75465. */
  75466. threshold: number;
  75467. /**
  75468. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75469. */
  75470. strength: number;
  75471. /**
  75472. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75473. */
  75474. reflectionSpecularFalloffExponent: number;
  75475. /**
  75476. * 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]
  75477. */
  75478. step: number;
  75479. /**
  75480. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75481. */
  75482. roughnessFactor: number;
  75483. private _forceGeometryBuffer;
  75484. private _geometryBufferRenderer;
  75485. private _prePassRenderer;
  75486. private _enableSmoothReflections;
  75487. private _reflectionSamples;
  75488. private _smoothSteps;
  75489. /**
  75490. * Gets a string identifying the name of the class
  75491. * @returns "ScreenSpaceReflectionPostProcess" string
  75492. */
  75493. getClassName(): string;
  75494. /**
  75495. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75496. * @param name The name of the effect.
  75497. * @param scene The scene containing the objects to calculate reflections.
  75498. * @param options The required width/height ratio to downsize to before computing the render pass.
  75499. * @param camera The camera to apply the render pass to.
  75500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75501. * @param engine The engine which the post process will be applied. (default: current engine)
  75502. * @param reusable If the post process can be reused on the same frame. (default: false)
  75503. * @param textureType Type of textures used when performing the post process. (default: 0)
  75504. * @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)
  75505. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75506. */
  75507. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75508. /**
  75509. * Gets wether or not smoothing reflections is enabled.
  75510. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75511. */
  75512. get enableSmoothReflections(): boolean;
  75513. /**
  75514. * Sets wether or not smoothing reflections is enabled.
  75515. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75516. */
  75517. set enableSmoothReflections(enabled: boolean);
  75518. /**
  75519. * Gets the number of samples taken while computing reflections. More samples count is high,
  75520. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75521. */
  75522. get reflectionSamples(): number;
  75523. /**
  75524. * Sets the number of samples taken while computing reflections. More samples count is high,
  75525. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75526. */
  75527. set reflectionSamples(samples: number);
  75528. /**
  75529. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75530. * more the post-process will require GPU power and can generate a drop in FPS.
  75531. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75532. */
  75533. get smoothSteps(): number;
  75534. set smoothSteps(steps: number);
  75535. private _updateEffectDefines;
  75536. /** @hidden */
  75537. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75538. }
  75539. }
  75540. declare module BABYLON {
  75541. /** @hidden */
  75542. export var standardPixelShader: {
  75543. name: string;
  75544. shader: string;
  75545. };
  75546. }
  75547. declare module BABYLON {
  75548. /**
  75549. * Standard rendering pipeline
  75550. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75551. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75552. */
  75553. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75554. /**
  75555. * Public members
  75556. */
  75557. /**
  75558. * Post-process which contains the original scene color before the pipeline applies all the effects
  75559. */
  75560. originalPostProcess: Nullable<PostProcess>;
  75561. /**
  75562. * Post-process used to down scale an image x4
  75563. */
  75564. downSampleX4PostProcess: Nullable<PostProcess>;
  75565. /**
  75566. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75567. */
  75568. brightPassPostProcess: Nullable<PostProcess>;
  75569. /**
  75570. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75571. */
  75572. blurHPostProcesses: PostProcess[];
  75573. /**
  75574. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75575. */
  75576. blurVPostProcesses: PostProcess[];
  75577. /**
  75578. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75579. */
  75580. textureAdderPostProcess: Nullable<PostProcess>;
  75581. /**
  75582. * Post-process used to create volumetric lighting effect
  75583. */
  75584. volumetricLightPostProcess: Nullable<PostProcess>;
  75585. /**
  75586. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75587. */
  75588. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75589. /**
  75590. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75591. */
  75592. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75593. /**
  75594. * Post-process used to merge the volumetric light effect and the real scene color
  75595. */
  75596. volumetricLightMergePostProces: Nullable<PostProcess>;
  75597. /**
  75598. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75599. */
  75600. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75601. /**
  75602. * Base post-process used to calculate the average luminance of the final image for HDR
  75603. */
  75604. luminancePostProcess: Nullable<PostProcess>;
  75605. /**
  75606. * Post-processes used to create down sample post-processes in order to get
  75607. * the average luminance of the final image for HDR
  75608. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75609. */
  75610. luminanceDownSamplePostProcesses: PostProcess[];
  75611. /**
  75612. * Post-process used to create a HDR effect (light adaptation)
  75613. */
  75614. hdrPostProcess: Nullable<PostProcess>;
  75615. /**
  75616. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75617. */
  75618. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75619. /**
  75620. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75621. */
  75622. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75623. /**
  75624. * Post-process used to merge the final HDR post-process and the real scene color
  75625. */
  75626. hdrFinalPostProcess: Nullable<PostProcess>;
  75627. /**
  75628. * Post-process used to create a lens flare effect
  75629. */
  75630. lensFlarePostProcess: Nullable<PostProcess>;
  75631. /**
  75632. * Post-process that merges the result of the lens flare post-process and the real scene color
  75633. */
  75634. lensFlareComposePostProcess: Nullable<PostProcess>;
  75635. /**
  75636. * Post-process used to create a motion blur effect
  75637. */
  75638. motionBlurPostProcess: Nullable<PostProcess>;
  75639. /**
  75640. * Post-process used to create a depth of field effect
  75641. */
  75642. depthOfFieldPostProcess: Nullable<PostProcess>;
  75643. /**
  75644. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75645. */
  75646. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75647. /**
  75648. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75649. */
  75650. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75651. /**
  75652. * Represents the brightness threshold in order to configure the illuminated surfaces
  75653. */
  75654. brightThreshold: number;
  75655. /**
  75656. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75657. */
  75658. blurWidth: number;
  75659. /**
  75660. * Sets if the blur for highlighted surfaces must be only horizontal
  75661. */
  75662. horizontalBlur: boolean;
  75663. /**
  75664. * Gets the overall exposure used by the pipeline
  75665. */
  75666. get exposure(): number;
  75667. /**
  75668. * Sets the overall exposure used by the pipeline
  75669. */
  75670. set exposure(value: number);
  75671. /**
  75672. * Texture used typically to simulate "dirty" on camera lens
  75673. */
  75674. lensTexture: Nullable<Texture>;
  75675. /**
  75676. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75677. */
  75678. volumetricLightCoefficient: number;
  75679. /**
  75680. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75681. */
  75682. volumetricLightPower: number;
  75683. /**
  75684. * Used the set the blur intensity to smooth the volumetric lights
  75685. */
  75686. volumetricLightBlurScale: number;
  75687. /**
  75688. * Light (spot or directional) used to generate the volumetric lights rays
  75689. * The source light must have a shadow generate so the pipeline can get its
  75690. * depth map
  75691. */
  75692. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75693. /**
  75694. * For eye adaptation, represents the minimum luminance the eye can see
  75695. */
  75696. hdrMinimumLuminance: number;
  75697. /**
  75698. * For eye adaptation, represents the decrease luminance speed
  75699. */
  75700. hdrDecreaseRate: number;
  75701. /**
  75702. * For eye adaptation, represents the increase luminance speed
  75703. */
  75704. hdrIncreaseRate: number;
  75705. /**
  75706. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75707. */
  75708. get hdrAutoExposure(): boolean;
  75709. /**
  75710. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75711. */
  75712. set hdrAutoExposure(value: boolean);
  75713. /**
  75714. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75715. */
  75716. lensColorTexture: Nullable<Texture>;
  75717. /**
  75718. * The overall strengh for the lens flare effect
  75719. */
  75720. lensFlareStrength: number;
  75721. /**
  75722. * Dispersion coefficient for lens flare ghosts
  75723. */
  75724. lensFlareGhostDispersal: number;
  75725. /**
  75726. * Main lens flare halo width
  75727. */
  75728. lensFlareHaloWidth: number;
  75729. /**
  75730. * Based on the lens distortion effect, defines how much the lens flare result
  75731. * is distorted
  75732. */
  75733. lensFlareDistortionStrength: number;
  75734. /**
  75735. * Configures the blur intensity used for for lens flare (halo)
  75736. */
  75737. lensFlareBlurWidth: number;
  75738. /**
  75739. * Lens star texture must be used to simulate rays on the flares and is available
  75740. * in the documentation
  75741. */
  75742. lensStarTexture: Nullable<Texture>;
  75743. /**
  75744. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75745. * flare effect by taking account of the dirt texture
  75746. */
  75747. lensFlareDirtTexture: Nullable<Texture>;
  75748. /**
  75749. * Represents the focal length for the depth of field effect
  75750. */
  75751. depthOfFieldDistance: number;
  75752. /**
  75753. * Represents the blur intensity for the blurred part of the depth of field effect
  75754. */
  75755. depthOfFieldBlurWidth: number;
  75756. /**
  75757. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75758. */
  75759. get motionStrength(): number;
  75760. /**
  75761. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75762. */
  75763. set motionStrength(strength: number);
  75764. /**
  75765. * Gets wether or not the motion blur post-process is object based or screen based.
  75766. */
  75767. get objectBasedMotionBlur(): boolean;
  75768. /**
  75769. * Sets wether or not the motion blur post-process should be object based or screen based
  75770. */
  75771. set objectBasedMotionBlur(value: boolean);
  75772. /**
  75773. * List of animations for the pipeline (IAnimatable implementation)
  75774. */
  75775. animations: Animation[];
  75776. /**
  75777. * Private members
  75778. */
  75779. private _scene;
  75780. private _currentDepthOfFieldSource;
  75781. private _basePostProcess;
  75782. private _fixedExposure;
  75783. private _currentExposure;
  75784. private _hdrAutoExposure;
  75785. private _hdrCurrentLuminance;
  75786. private _motionStrength;
  75787. private _isObjectBasedMotionBlur;
  75788. private _floatTextureType;
  75789. private _camerasToBeAttached;
  75790. private _ratio;
  75791. private _bloomEnabled;
  75792. private _depthOfFieldEnabled;
  75793. private _vlsEnabled;
  75794. private _lensFlareEnabled;
  75795. private _hdrEnabled;
  75796. private _motionBlurEnabled;
  75797. private _fxaaEnabled;
  75798. private _screenSpaceReflectionsEnabled;
  75799. private _motionBlurSamples;
  75800. private _volumetricLightStepsCount;
  75801. private _samples;
  75802. /**
  75803. * @ignore
  75804. * Specifies if the bloom pipeline is enabled
  75805. */
  75806. get BloomEnabled(): boolean;
  75807. set BloomEnabled(enabled: boolean);
  75808. /**
  75809. * @ignore
  75810. * Specifies if the depth of field pipeline is enabed
  75811. */
  75812. get DepthOfFieldEnabled(): boolean;
  75813. set DepthOfFieldEnabled(enabled: boolean);
  75814. /**
  75815. * @ignore
  75816. * Specifies if the lens flare pipeline is enabed
  75817. */
  75818. get LensFlareEnabled(): boolean;
  75819. set LensFlareEnabled(enabled: boolean);
  75820. /**
  75821. * @ignore
  75822. * Specifies if the HDR pipeline is enabled
  75823. */
  75824. get HDREnabled(): boolean;
  75825. set HDREnabled(enabled: boolean);
  75826. /**
  75827. * @ignore
  75828. * Specifies if the volumetric lights scattering effect is enabled
  75829. */
  75830. get VLSEnabled(): boolean;
  75831. set VLSEnabled(enabled: boolean);
  75832. /**
  75833. * @ignore
  75834. * Specifies if the motion blur effect is enabled
  75835. */
  75836. get MotionBlurEnabled(): boolean;
  75837. set MotionBlurEnabled(enabled: boolean);
  75838. /**
  75839. * Specifies if anti-aliasing is enabled
  75840. */
  75841. get fxaaEnabled(): boolean;
  75842. set fxaaEnabled(enabled: boolean);
  75843. /**
  75844. * Specifies if screen space reflections are enabled.
  75845. */
  75846. get screenSpaceReflectionsEnabled(): boolean;
  75847. set screenSpaceReflectionsEnabled(enabled: boolean);
  75848. /**
  75849. * Specifies the number of steps used to calculate the volumetric lights
  75850. * Typically in interval [50, 200]
  75851. */
  75852. get volumetricLightStepsCount(): number;
  75853. set volumetricLightStepsCount(count: number);
  75854. /**
  75855. * Specifies the number of samples used for the motion blur effect
  75856. * Typically in interval [16, 64]
  75857. */
  75858. get motionBlurSamples(): number;
  75859. set motionBlurSamples(samples: number);
  75860. /**
  75861. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75862. */
  75863. get samples(): number;
  75864. set samples(sampleCount: number);
  75865. /**
  75866. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75867. * @constructor
  75868. * @param name The rendering pipeline name
  75869. * @param scene The scene linked to this pipeline
  75870. * @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)
  75871. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75872. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75873. */
  75874. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75875. private _buildPipeline;
  75876. private _createDownSampleX4PostProcess;
  75877. private _createBrightPassPostProcess;
  75878. private _createBlurPostProcesses;
  75879. private _createTextureAdderPostProcess;
  75880. private _createVolumetricLightPostProcess;
  75881. private _createLuminancePostProcesses;
  75882. private _createHdrPostProcess;
  75883. private _createLensFlarePostProcess;
  75884. private _createDepthOfFieldPostProcess;
  75885. private _createMotionBlurPostProcess;
  75886. private _getDepthTexture;
  75887. private _disposePostProcesses;
  75888. /**
  75889. * Dispose of the pipeline and stop all post processes
  75890. */
  75891. dispose(): void;
  75892. /**
  75893. * Serialize the rendering pipeline (Used when exporting)
  75894. * @returns the serialized object
  75895. */
  75896. serialize(): any;
  75897. /**
  75898. * Parse the serialized pipeline
  75899. * @param source Source pipeline.
  75900. * @param scene The scene to load the pipeline to.
  75901. * @param rootUrl The URL of the serialized pipeline.
  75902. * @returns An instantiated pipeline from the serialized object.
  75903. */
  75904. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75905. /**
  75906. * Luminance steps
  75907. */
  75908. static LuminanceSteps: number;
  75909. }
  75910. }
  75911. declare module BABYLON {
  75912. /** @hidden */
  75913. export var tonemapPixelShader: {
  75914. name: string;
  75915. shader: string;
  75916. };
  75917. }
  75918. declare module BABYLON {
  75919. /** Defines operator used for tonemapping */
  75920. export enum TonemappingOperator {
  75921. /** Hable */
  75922. Hable = 0,
  75923. /** Reinhard */
  75924. Reinhard = 1,
  75925. /** HejiDawson */
  75926. HejiDawson = 2,
  75927. /** Photographic */
  75928. Photographic = 3
  75929. }
  75930. /**
  75931. * Defines a post process to apply tone mapping
  75932. */
  75933. export class TonemapPostProcess extends PostProcess {
  75934. private _operator;
  75935. /** Defines the required exposure adjustement */
  75936. exposureAdjustment: number;
  75937. /**
  75938. * Gets a string identifying the name of the class
  75939. * @returns "TonemapPostProcess" string
  75940. */
  75941. getClassName(): string;
  75942. /**
  75943. * Creates a new TonemapPostProcess
  75944. * @param name defines the name of the postprocess
  75945. * @param _operator defines the operator to use
  75946. * @param exposureAdjustment defines the required exposure adjustement
  75947. * @param camera defines the camera to use (can be null)
  75948. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75949. * @param engine defines the hosting engine (can be ignore if camera is set)
  75950. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75951. */
  75952. constructor(name: string, _operator: TonemappingOperator,
  75953. /** Defines the required exposure adjustement */
  75954. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75955. }
  75956. }
  75957. declare module BABYLON {
  75958. /** @hidden */
  75959. export var volumetricLightScatteringPixelShader: {
  75960. name: string;
  75961. shader: string;
  75962. };
  75963. }
  75964. declare module BABYLON {
  75965. /** @hidden */
  75966. export var volumetricLightScatteringPassVertexShader: {
  75967. name: string;
  75968. shader: string;
  75969. };
  75970. }
  75971. declare module BABYLON {
  75972. /** @hidden */
  75973. export var volumetricLightScatteringPassPixelShader: {
  75974. name: string;
  75975. shader: string;
  75976. };
  75977. }
  75978. declare module BABYLON {
  75979. /**
  75980. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75981. */
  75982. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75983. private _volumetricLightScatteringPass;
  75984. private _volumetricLightScatteringRTT;
  75985. private _viewPort;
  75986. private _screenCoordinates;
  75987. private _cachedDefines;
  75988. /**
  75989. * If not undefined, the mesh position is computed from the attached node position
  75990. */
  75991. attachedNode: {
  75992. position: Vector3;
  75993. };
  75994. /**
  75995. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75996. */
  75997. customMeshPosition: Vector3;
  75998. /**
  75999. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76000. */
  76001. useCustomMeshPosition: boolean;
  76002. /**
  76003. * If the post-process should inverse the light scattering direction
  76004. */
  76005. invert: boolean;
  76006. /**
  76007. * The internal mesh used by the post-process
  76008. */
  76009. mesh: Mesh;
  76010. /**
  76011. * @hidden
  76012. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76013. */
  76014. get useDiffuseColor(): boolean;
  76015. set useDiffuseColor(useDiffuseColor: boolean);
  76016. /**
  76017. * Array containing the excluded meshes not rendered in the internal pass
  76018. */
  76019. excludedMeshes: AbstractMesh[];
  76020. /**
  76021. * Controls the overall intensity of the post-process
  76022. */
  76023. exposure: number;
  76024. /**
  76025. * Dissipates each sample's contribution in range [0, 1]
  76026. */
  76027. decay: number;
  76028. /**
  76029. * Controls the overall intensity of each sample
  76030. */
  76031. weight: number;
  76032. /**
  76033. * Controls the density of each sample
  76034. */
  76035. density: number;
  76036. /**
  76037. * @constructor
  76038. * @param name The post-process name
  76039. * @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)
  76040. * @param camera The camera that the post-process will be attached to
  76041. * @param mesh The mesh used to create the light scattering
  76042. * @param samples The post-process quality, default 100
  76043. * @param samplingModeThe post-process filtering mode
  76044. * @param engine The babylon engine
  76045. * @param reusable If the post-process is reusable
  76046. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76047. */
  76048. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76049. /**
  76050. * Returns the string "VolumetricLightScatteringPostProcess"
  76051. * @returns "VolumetricLightScatteringPostProcess"
  76052. */
  76053. getClassName(): string;
  76054. private _isReady;
  76055. /**
  76056. * Sets the new light position for light scattering effect
  76057. * @param position The new custom light position
  76058. */
  76059. setCustomMeshPosition(position: Vector3): void;
  76060. /**
  76061. * Returns the light position for light scattering effect
  76062. * @return Vector3 The custom light position
  76063. */
  76064. getCustomMeshPosition(): Vector3;
  76065. /**
  76066. * Disposes the internal assets and detaches the post-process from the camera
  76067. */
  76068. dispose(camera: Camera): void;
  76069. /**
  76070. * Returns the render target texture used by the post-process
  76071. * @return the render target texture used by the post-process
  76072. */
  76073. getPass(): RenderTargetTexture;
  76074. private _meshExcluded;
  76075. private _createPass;
  76076. private _updateMeshScreenCoordinates;
  76077. /**
  76078. * Creates a default mesh for the Volumeric Light Scattering post-process
  76079. * @param name The mesh name
  76080. * @param scene The scene where to create the mesh
  76081. * @return the default mesh
  76082. */
  76083. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76084. }
  76085. }
  76086. declare module BABYLON {
  76087. /** @hidden */
  76088. export var screenSpaceCurvaturePixelShader: {
  76089. name: string;
  76090. shader: string;
  76091. };
  76092. }
  76093. declare module BABYLON {
  76094. /**
  76095. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76096. */
  76097. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76098. /**
  76099. * Defines how much ridge the curvature effect displays.
  76100. */
  76101. ridge: number;
  76102. /**
  76103. * Defines how much valley the curvature effect displays.
  76104. */
  76105. valley: number;
  76106. private _geometryBufferRenderer;
  76107. /**
  76108. * Gets a string identifying the name of the class
  76109. * @returns "ScreenSpaceCurvaturePostProcess" string
  76110. */
  76111. getClassName(): string;
  76112. /**
  76113. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76114. * @param name The name of the effect.
  76115. * @param scene The scene containing the objects to blur according to their velocity.
  76116. * @param options The required width/height ratio to downsize to before computing the render pass.
  76117. * @param camera The camera to apply the render pass to.
  76118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76119. * @param engine The engine which the post process will be applied. (default: current engine)
  76120. * @param reusable If the post process can be reused on the same frame. (default: false)
  76121. * @param textureType Type of textures used when performing the post process. (default: 0)
  76122. * @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)
  76123. */
  76124. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76125. /**
  76126. * Support test.
  76127. */
  76128. static get IsSupported(): boolean;
  76129. /** @hidden */
  76130. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76131. }
  76132. }
  76133. declare module BABYLON {
  76134. interface Scene {
  76135. /** @hidden (Backing field) */
  76136. _boundingBoxRenderer: BoundingBoxRenderer;
  76137. /** @hidden (Backing field) */
  76138. _forceShowBoundingBoxes: boolean;
  76139. /**
  76140. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76141. */
  76142. forceShowBoundingBoxes: boolean;
  76143. /**
  76144. * Gets the bounding box renderer associated with the scene
  76145. * @returns a BoundingBoxRenderer
  76146. */
  76147. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76148. }
  76149. interface AbstractMesh {
  76150. /** @hidden (Backing field) */
  76151. _showBoundingBox: boolean;
  76152. /**
  76153. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76154. */
  76155. showBoundingBox: boolean;
  76156. }
  76157. /**
  76158. * Component responsible of rendering the bounding box of the meshes in a scene.
  76159. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76160. */
  76161. export class BoundingBoxRenderer implements ISceneComponent {
  76162. /**
  76163. * The component name helpfull to identify the component in the list of scene components.
  76164. */
  76165. readonly name: string;
  76166. /**
  76167. * The scene the component belongs to.
  76168. */
  76169. scene: Scene;
  76170. /**
  76171. * Color of the bounding box lines placed in front of an object
  76172. */
  76173. frontColor: Color3;
  76174. /**
  76175. * Color of the bounding box lines placed behind an object
  76176. */
  76177. backColor: Color3;
  76178. /**
  76179. * Defines if the renderer should show the back lines or not
  76180. */
  76181. showBackLines: boolean;
  76182. /**
  76183. * Observable raised before rendering a bounding box
  76184. */
  76185. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76186. /**
  76187. * Observable raised after rendering a bounding box
  76188. */
  76189. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76190. /**
  76191. * Observable raised after resources are created
  76192. */
  76193. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76194. /**
  76195. * When false, no bounding boxes will be rendered
  76196. */
  76197. enabled: boolean;
  76198. /**
  76199. * @hidden
  76200. */
  76201. renderList: SmartArray<BoundingBox>;
  76202. private _colorShader;
  76203. private _vertexBuffers;
  76204. private _indexBuffer;
  76205. private _fillIndexBuffer;
  76206. private _fillIndexData;
  76207. /**
  76208. * Instantiates a new bounding box renderer in a scene.
  76209. * @param scene the scene the renderer renders in
  76210. */
  76211. constructor(scene: Scene);
  76212. /**
  76213. * Registers the component in a given scene
  76214. */
  76215. register(): void;
  76216. private _evaluateSubMesh;
  76217. private _preActiveMesh;
  76218. private _prepareResources;
  76219. private _createIndexBuffer;
  76220. /**
  76221. * Rebuilds the elements related to this component in case of
  76222. * context lost for instance.
  76223. */
  76224. rebuild(): void;
  76225. /**
  76226. * @hidden
  76227. */
  76228. reset(): void;
  76229. /**
  76230. * Render the bounding boxes of a specific rendering group
  76231. * @param renderingGroupId defines the rendering group to render
  76232. */
  76233. render(renderingGroupId: number): void;
  76234. /**
  76235. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76236. * @param mesh Define the mesh to render the occlusion bounding box for
  76237. */
  76238. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76239. /**
  76240. * Dispose and release the resources attached to this renderer.
  76241. */
  76242. dispose(): void;
  76243. }
  76244. }
  76245. declare module BABYLON {
  76246. interface Scene {
  76247. /** @hidden (Backing field) */
  76248. _depthRenderer: {
  76249. [id: string]: DepthRenderer;
  76250. };
  76251. /**
  76252. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76253. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76254. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76255. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76256. * @returns the created depth renderer
  76257. */
  76258. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76259. /**
  76260. * Disables a depth renderer for a given camera
  76261. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76262. */
  76263. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76264. }
  76265. /**
  76266. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76267. * in several rendering techniques.
  76268. */
  76269. export class DepthRendererSceneComponent implements ISceneComponent {
  76270. /**
  76271. * The component name helpfull to identify the component in the list of scene components.
  76272. */
  76273. readonly name: string;
  76274. /**
  76275. * The scene the component belongs to.
  76276. */
  76277. scene: Scene;
  76278. /**
  76279. * Creates a new instance of the component for the given scene
  76280. * @param scene Defines the scene to register the component in
  76281. */
  76282. constructor(scene: Scene);
  76283. /**
  76284. * Registers the component in a given scene
  76285. */
  76286. register(): void;
  76287. /**
  76288. * Rebuilds the elements related to this component in case of
  76289. * context lost for instance.
  76290. */
  76291. rebuild(): void;
  76292. /**
  76293. * Disposes the component and the associated ressources
  76294. */
  76295. dispose(): void;
  76296. private _gatherRenderTargets;
  76297. private _gatherActiveCameraRenderTargets;
  76298. }
  76299. }
  76300. declare module BABYLON {
  76301. interface AbstractScene {
  76302. /** @hidden (Backing field) */
  76303. _prePassRenderer: Nullable<PrePassRenderer>;
  76304. /**
  76305. * Gets or Sets the current prepass renderer associated to the scene.
  76306. */
  76307. prePassRenderer: Nullable<PrePassRenderer>;
  76308. /**
  76309. * Enables the prepass and associates it with the scene
  76310. * @returns the PrePassRenderer
  76311. */
  76312. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76313. /**
  76314. * Disables the prepass associated with the scene
  76315. */
  76316. disablePrePassRenderer(): void;
  76317. }
  76318. /**
  76319. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76320. * in several rendering techniques.
  76321. */
  76322. export class PrePassRendererSceneComponent implements ISceneComponent {
  76323. /**
  76324. * The component name helpful to identify the component in the list of scene components.
  76325. */
  76326. readonly name: string;
  76327. /**
  76328. * The scene the component belongs to.
  76329. */
  76330. scene: Scene;
  76331. /**
  76332. * Creates a new instance of the component for the given scene
  76333. * @param scene Defines the scene to register the component in
  76334. */
  76335. constructor(scene: Scene);
  76336. /**
  76337. * Registers the component in a given scene
  76338. */
  76339. register(): void;
  76340. private _beforeCameraDraw;
  76341. private _afterCameraDraw;
  76342. private _beforeClearStage;
  76343. private _beforeRenderingMeshStage;
  76344. private _afterRenderingMeshStage;
  76345. /**
  76346. * Rebuilds the elements related to this component in case of
  76347. * context lost for instance.
  76348. */
  76349. rebuild(): void;
  76350. /**
  76351. * Disposes the component and the associated ressources
  76352. */
  76353. dispose(): void;
  76354. }
  76355. }
  76356. declare module BABYLON {
  76357. /** @hidden */
  76358. export var fibonacci: {
  76359. name: string;
  76360. shader: string;
  76361. };
  76362. }
  76363. declare module BABYLON {
  76364. /** @hidden */
  76365. export var diffusionProfile: {
  76366. name: string;
  76367. shader: string;
  76368. };
  76369. }
  76370. declare module BABYLON {
  76371. /** @hidden */
  76372. export var subSurfaceScatteringPixelShader: {
  76373. name: string;
  76374. shader: string;
  76375. };
  76376. }
  76377. declare module BABYLON {
  76378. /**
  76379. * Sub surface scattering post process
  76380. */
  76381. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76382. /**
  76383. * Gets a string identifying the name of the class
  76384. * @returns "SubSurfaceScatteringPostProcess" string
  76385. */
  76386. getClassName(): string;
  76387. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76388. }
  76389. }
  76390. declare module BABYLON {
  76391. /**
  76392. * Contains all parameters needed for the prepass to perform
  76393. * screen space subsurface scattering
  76394. */
  76395. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76396. /** @hidden */
  76397. static _SceneComponentInitialization: (scene: Scene) => void;
  76398. private _ssDiffusionS;
  76399. private _ssFilterRadii;
  76400. private _ssDiffusionD;
  76401. /**
  76402. * Post process to attach for screen space subsurface scattering
  76403. */
  76404. postProcess: SubSurfaceScatteringPostProcess;
  76405. /**
  76406. * Diffusion profile color for subsurface scattering
  76407. */
  76408. get ssDiffusionS(): number[];
  76409. /**
  76410. * Diffusion profile max color channel value for subsurface scattering
  76411. */
  76412. get ssDiffusionD(): number[];
  76413. /**
  76414. * Diffusion profile filter radius for subsurface scattering
  76415. */
  76416. get ssFilterRadii(): number[];
  76417. /**
  76418. * Is subsurface enabled
  76419. */
  76420. enabled: boolean;
  76421. /**
  76422. * Name of the configuration
  76423. */
  76424. name: string;
  76425. /**
  76426. * Diffusion profile colors for subsurface scattering
  76427. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76428. * See ...
  76429. * Note that you can only store up to 5 of them
  76430. */
  76431. ssDiffusionProfileColors: Color3[];
  76432. /**
  76433. * Defines the ratio real world => scene units.
  76434. * Used for subsurface scattering
  76435. */
  76436. metersPerUnit: number;
  76437. /**
  76438. * Textures that should be present in the MRT for this effect to work
  76439. */
  76440. readonly texturesRequired: number[];
  76441. private _scene;
  76442. /**
  76443. * Builds a subsurface configuration object
  76444. * @param scene The scene
  76445. */
  76446. constructor(scene: Scene);
  76447. /**
  76448. * Adds a new diffusion profile.
  76449. * Useful for more realistic subsurface scattering on diverse materials.
  76450. * @param color The color of the diffusion profile. Should be the average color of the material.
  76451. * @return The index of the diffusion profile for the material subsurface configuration
  76452. */
  76453. addDiffusionProfile(color: Color3): number;
  76454. /**
  76455. * Creates the sss post process
  76456. * @return The created post process
  76457. */
  76458. createPostProcess(): SubSurfaceScatteringPostProcess;
  76459. /**
  76460. * Deletes all diffusion profiles.
  76461. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76462. */
  76463. clearAllDiffusionProfiles(): void;
  76464. /**
  76465. * Disposes this object
  76466. */
  76467. dispose(): void;
  76468. /**
  76469. * @hidden
  76470. * https://zero-radiance.github.io/post/sampling-diffusion/
  76471. *
  76472. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76473. * ------------------------------------------------------------------------------------
  76474. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76475. * PDF[r, phi, s] = r * R[r, phi, s]
  76476. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76477. * ------------------------------------------------------------------------------------
  76478. * We importance sample the color channel with the widest scattering distance.
  76479. */
  76480. getDiffusionProfileParameters(color: Color3): number;
  76481. /**
  76482. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76483. * 'u' is the random number (the value of the CDF): [0, 1).
  76484. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76485. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76486. */
  76487. private _sampleBurleyDiffusionProfile;
  76488. }
  76489. }
  76490. declare module BABYLON {
  76491. interface AbstractScene {
  76492. /** @hidden (Backing field) */
  76493. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76494. /**
  76495. * Gets or Sets the current prepass renderer associated to the scene.
  76496. */
  76497. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76498. /**
  76499. * Enables the subsurface effect for prepass
  76500. * @returns the SubSurfaceConfiguration
  76501. */
  76502. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76503. /**
  76504. * Disables the subsurface effect for prepass
  76505. */
  76506. disableSubSurfaceForPrePass(): void;
  76507. }
  76508. /**
  76509. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76510. * in several rendering techniques.
  76511. */
  76512. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76513. /**
  76514. * The component name helpful to identify the component in the list of scene components.
  76515. */
  76516. readonly name: string;
  76517. /**
  76518. * The scene the component belongs to.
  76519. */
  76520. scene: Scene;
  76521. /**
  76522. * Creates a new instance of the component for the given scene
  76523. * @param scene Defines the scene to register the component in
  76524. */
  76525. constructor(scene: Scene);
  76526. /**
  76527. * Registers the component in a given scene
  76528. */
  76529. register(): void;
  76530. /**
  76531. * Serializes the component data to the specified json object
  76532. * @param serializationObject The object to serialize to
  76533. */
  76534. serialize(serializationObject: any): void;
  76535. /**
  76536. * Adds all the elements from the container to the scene
  76537. * @param container the container holding the elements
  76538. */
  76539. addFromContainer(container: AbstractScene): void;
  76540. /**
  76541. * Removes all the elements in the container from the scene
  76542. * @param container contains the elements to remove
  76543. * @param dispose if the removed element should be disposed (default: false)
  76544. */
  76545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76546. /**
  76547. * Rebuilds the elements related to this component in case of
  76548. * context lost for instance.
  76549. */
  76550. rebuild(): void;
  76551. /**
  76552. * Disposes the component and the associated ressources
  76553. */
  76554. dispose(): void;
  76555. }
  76556. }
  76557. declare module BABYLON {
  76558. /** @hidden */
  76559. export var outlinePixelShader: {
  76560. name: string;
  76561. shader: string;
  76562. };
  76563. }
  76564. declare module BABYLON {
  76565. /** @hidden */
  76566. export var outlineVertexShader: {
  76567. name: string;
  76568. shader: string;
  76569. };
  76570. }
  76571. declare module BABYLON {
  76572. interface Scene {
  76573. /** @hidden */
  76574. _outlineRenderer: OutlineRenderer;
  76575. /**
  76576. * Gets the outline renderer associated with the scene
  76577. * @returns a OutlineRenderer
  76578. */
  76579. getOutlineRenderer(): OutlineRenderer;
  76580. }
  76581. interface AbstractMesh {
  76582. /** @hidden (Backing field) */
  76583. _renderOutline: boolean;
  76584. /**
  76585. * Gets or sets a boolean indicating if the outline must be rendered as well
  76586. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76587. */
  76588. renderOutline: boolean;
  76589. /** @hidden (Backing field) */
  76590. _renderOverlay: boolean;
  76591. /**
  76592. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76593. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76594. */
  76595. renderOverlay: boolean;
  76596. }
  76597. /**
  76598. * This class is responsible to draw bothe outline/overlay of meshes.
  76599. * It should not be used directly but through the available method on mesh.
  76600. */
  76601. export class OutlineRenderer implements ISceneComponent {
  76602. /**
  76603. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76604. */
  76605. private static _StencilReference;
  76606. /**
  76607. * The name of the component. Each component must have a unique name.
  76608. */
  76609. name: string;
  76610. /**
  76611. * The scene the component belongs to.
  76612. */
  76613. scene: Scene;
  76614. /**
  76615. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76616. */
  76617. zOffset: number;
  76618. private _engine;
  76619. private _effect;
  76620. private _cachedDefines;
  76621. private _savedDepthWrite;
  76622. /**
  76623. * Instantiates a new outline renderer. (There could be only one per scene).
  76624. * @param scene Defines the scene it belongs to
  76625. */
  76626. constructor(scene: Scene);
  76627. /**
  76628. * Register the component to one instance of a scene.
  76629. */
  76630. register(): void;
  76631. /**
  76632. * Rebuilds the elements related to this component in case of
  76633. * context lost for instance.
  76634. */
  76635. rebuild(): void;
  76636. /**
  76637. * Disposes the component and the associated ressources.
  76638. */
  76639. dispose(): void;
  76640. /**
  76641. * Renders the outline in the canvas.
  76642. * @param subMesh Defines the sumesh to render
  76643. * @param batch Defines the batch of meshes in case of instances
  76644. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76645. */
  76646. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76647. /**
  76648. * Returns whether or not the outline renderer is ready for a given submesh.
  76649. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76650. * @param subMesh Defines the submesh to check readyness for
  76651. * @param useInstances Defines wheter wee are trying to render instances or not
  76652. * @returns true if ready otherwise false
  76653. */
  76654. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76655. private _beforeRenderingMesh;
  76656. private _afterRenderingMesh;
  76657. }
  76658. }
  76659. declare module BABYLON {
  76660. /**
  76661. * Defines the basic options interface of a Sprite Frame Source Size.
  76662. */
  76663. export interface ISpriteJSONSpriteSourceSize {
  76664. /**
  76665. * number of the original width of the Frame
  76666. */
  76667. w: number;
  76668. /**
  76669. * number of the original height of the Frame
  76670. */
  76671. h: number;
  76672. }
  76673. /**
  76674. * Defines the basic options interface of a Sprite Frame Data.
  76675. */
  76676. export interface ISpriteJSONSpriteFrameData {
  76677. /**
  76678. * number of the x offset of the Frame
  76679. */
  76680. x: number;
  76681. /**
  76682. * number of the y offset of the Frame
  76683. */
  76684. y: number;
  76685. /**
  76686. * number of the width of the Frame
  76687. */
  76688. w: number;
  76689. /**
  76690. * number of the height of the Frame
  76691. */
  76692. h: number;
  76693. }
  76694. /**
  76695. * Defines the basic options interface of a JSON Sprite.
  76696. */
  76697. export interface ISpriteJSONSprite {
  76698. /**
  76699. * string name of the Frame
  76700. */
  76701. filename: string;
  76702. /**
  76703. * ISpriteJSONSpriteFrame basic object of the frame data
  76704. */
  76705. frame: ISpriteJSONSpriteFrameData;
  76706. /**
  76707. * boolean to flag is the frame was rotated.
  76708. */
  76709. rotated: boolean;
  76710. /**
  76711. * boolean to flag is the frame was trimmed.
  76712. */
  76713. trimmed: boolean;
  76714. /**
  76715. * ISpriteJSONSpriteFrame basic object of the source data
  76716. */
  76717. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76718. /**
  76719. * ISpriteJSONSpriteFrame basic object of the source data
  76720. */
  76721. sourceSize: ISpriteJSONSpriteSourceSize;
  76722. }
  76723. /**
  76724. * Defines the basic options interface of a JSON atlas.
  76725. */
  76726. export interface ISpriteJSONAtlas {
  76727. /**
  76728. * Array of objects that contain the frame data.
  76729. */
  76730. frames: Array<ISpriteJSONSprite>;
  76731. /**
  76732. * object basic object containing the sprite meta data.
  76733. */
  76734. meta?: object;
  76735. }
  76736. }
  76737. declare module BABYLON {
  76738. /** @hidden */
  76739. export var spriteMapPixelShader: {
  76740. name: string;
  76741. shader: string;
  76742. };
  76743. }
  76744. declare module BABYLON {
  76745. /** @hidden */
  76746. export var spriteMapVertexShader: {
  76747. name: string;
  76748. shader: string;
  76749. };
  76750. }
  76751. declare module BABYLON {
  76752. /**
  76753. * Defines the basic options interface of a SpriteMap
  76754. */
  76755. export interface ISpriteMapOptions {
  76756. /**
  76757. * Vector2 of the number of cells in the grid.
  76758. */
  76759. stageSize?: Vector2;
  76760. /**
  76761. * Vector2 of the size of the output plane in World Units.
  76762. */
  76763. outputSize?: Vector2;
  76764. /**
  76765. * Vector3 of the position of the output plane in World Units.
  76766. */
  76767. outputPosition?: Vector3;
  76768. /**
  76769. * Vector3 of the rotation of the output plane.
  76770. */
  76771. outputRotation?: Vector3;
  76772. /**
  76773. * number of layers that the system will reserve in resources.
  76774. */
  76775. layerCount?: number;
  76776. /**
  76777. * number of max animation frames a single cell will reserve in resources.
  76778. */
  76779. maxAnimationFrames?: number;
  76780. /**
  76781. * number cell index of the base tile when the system compiles.
  76782. */
  76783. baseTile?: number;
  76784. /**
  76785. * boolean flip the sprite after its been repositioned by the framing data.
  76786. */
  76787. flipU?: boolean;
  76788. /**
  76789. * Vector3 scalar of the global RGB values of the SpriteMap.
  76790. */
  76791. colorMultiply?: Vector3;
  76792. }
  76793. /**
  76794. * Defines the IDisposable interface in order to be cleanable from resources.
  76795. */
  76796. export interface ISpriteMap extends IDisposable {
  76797. /**
  76798. * String name of the SpriteMap.
  76799. */
  76800. name: string;
  76801. /**
  76802. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76803. */
  76804. atlasJSON: ISpriteJSONAtlas;
  76805. /**
  76806. * Texture of the SpriteMap.
  76807. */
  76808. spriteSheet: Texture;
  76809. /**
  76810. * The parameters to initialize the SpriteMap with.
  76811. */
  76812. options: ISpriteMapOptions;
  76813. }
  76814. /**
  76815. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76816. */
  76817. export class SpriteMap implements ISpriteMap {
  76818. /** The Name of the spriteMap */
  76819. name: string;
  76820. /** The JSON file with the frame and meta data */
  76821. atlasJSON: ISpriteJSONAtlas;
  76822. /** The systems Sprite Sheet Texture */
  76823. spriteSheet: Texture;
  76824. /** Arguments passed with the Constructor */
  76825. options: ISpriteMapOptions;
  76826. /** Public Sprite Storage array, parsed from atlasJSON */
  76827. sprites: Array<ISpriteJSONSprite>;
  76828. /** Returns the Number of Sprites in the System */
  76829. get spriteCount(): number;
  76830. /** Returns the Position of Output Plane*/
  76831. get position(): Vector3;
  76832. /** Returns the Position of Output Plane*/
  76833. set position(v: Vector3);
  76834. /** Returns the Rotation of Output Plane*/
  76835. get rotation(): Vector3;
  76836. /** Returns the Rotation of Output Plane*/
  76837. set rotation(v: Vector3);
  76838. /** Sets the AnimationMap*/
  76839. get animationMap(): RawTexture;
  76840. /** Sets the AnimationMap*/
  76841. set animationMap(v: RawTexture);
  76842. /** Scene that the SpriteMap was created in */
  76843. private _scene;
  76844. /** Texture Buffer of Float32 that holds tile frame data*/
  76845. private _frameMap;
  76846. /** Texture Buffers of Float32 that holds tileMap data*/
  76847. private _tileMaps;
  76848. /** Texture Buffer of Float32 that holds Animation Data*/
  76849. private _animationMap;
  76850. /** Custom ShaderMaterial Central to the System*/
  76851. private _material;
  76852. /** Custom ShaderMaterial Central to the System*/
  76853. private _output;
  76854. /** Systems Time Ticker*/
  76855. private _time;
  76856. /**
  76857. * Creates a new SpriteMap
  76858. * @param name defines the SpriteMaps Name
  76859. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76860. * @param spriteSheet is the Texture that the Sprites are on.
  76861. * @param options a basic deployment configuration
  76862. * @param scene The Scene that the map is deployed on
  76863. */
  76864. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76865. /**
  76866. * Returns tileID location
  76867. * @returns Vector2 the cell position ID
  76868. */
  76869. getTileID(): Vector2;
  76870. /**
  76871. * Gets the UV location of the mouse over the SpriteMap.
  76872. * @returns Vector2 the UV position of the mouse interaction
  76873. */
  76874. getMousePosition(): Vector2;
  76875. /**
  76876. * Creates the "frame" texture Buffer
  76877. * -------------------------------------
  76878. * Structure of frames
  76879. * "filename": "Falling-Water-2.png",
  76880. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76881. * "rotated": true,
  76882. * "trimmed": true,
  76883. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76884. * "sourceSize": {"w":32,"h":32}
  76885. * @returns RawTexture of the frameMap
  76886. */
  76887. private _createFrameBuffer;
  76888. /**
  76889. * Creates the tileMap texture Buffer
  76890. * @param buffer normally and array of numbers, or a false to generate from scratch
  76891. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76892. * @returns RawTexture of the tileMap
  76893. */
  76894. private _createTileBuffer;
  76895. /**
  76896. * Modifies the data of the tileMaps
  76897. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76898. * @param pos is the iVector2 Coordinates of the Tile
  76899. * @param tile The SpriteIndex of the new Tile
  76900. */
  76901. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76902. /**
  76903. * Creates the animationMap texture Buffer
  76904. * @param buffer normally and array of numbers, or a false to generate from scratch
  76905. * @returns RawTexture of the animationMap
  76906. */
  76907. private _createTileAnimationBuffer;
  76908. /**
  76909. * Modifies the data of the animationMap
  76910. * @param cellID is the Index of the Sprite
  76911. * @param _frame is the target Animation frame
  76912. * @param toCell is the Target Index of the next frame of the animation
  76913. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76914. * @param speed is a global scalar of the time variable on the map.
  76915. */
  76916. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76917. /**
  76918. * Exports the .tilemaps file
  76919. */
  76920. saveTileMaps(): void;
  76921. /**
  76922. * Imports the .tilemaps file
  76923. * @param url of the .tilemaps file
  76924. */
  76925. loadTileMaps(url: string): void;
  76926. /**
  76927. * Release associated resources
  76928. */
  76929. dispose(): void;
  76930. }
  76931. }
  76932. declare module BABYLON {
  76933. /**
  76934. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76935. * @see https://doc.babylonjs.com/babylon101/sprites
  76936. */
  76937. export class SpritePackedManager extends SpriteManager {
  76938. /** defines the packed manager's name */
  76939. name: string;
  76940. /**
  76941. * Creates a new sprite manager from a packed sprite sheet
  76942. * @param name defines the manager's name
  76943. * @param imgUrl defines the sprite sheet url
  76944. * @param capacity defines the maximum allowed number of sprites
  76945. * @param scene defines the hosting scene
  76946. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76947. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76948. * @param samplingMode defines the smapling mode to use with spritesheet
  76949. * @param fromPacked set to true; do not alter
  76950. */
  76951. constructor(
  76952. /** defines the packed manager's name */
  76953. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76954. }
  76955. }
  76956. declare module BABYLON {
  76957. /**
  76958. * Defines the list of states available for a task inside a AssetsManager
  76959. */
  76960. export enum AssetTaskState {
  76961. /**
  76962. * Initialization
  76963. */
  76964. INIT = 0,
  76965. /**
  76966. * Running
  76967. */
  76968. RUNNING = 1,
  76969. /**
  76970. * Done
  76971. */
  76972. DONE = 2,
  76973. /**
  76974. * Error
  76975. */
  76976. ERROR = 3
  76977. }
  76978. /**
  76979. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76980. */
  76981. export abstract class AbstractAssetTask {
  76982. /**
  76983. * Task name
  76984. */ name: string;
  76985. /**
  76986. * Callback called when the task is successful
  76987. */
  76988. onSuccess: (task: any) => void;
  76989. /**
  76990. * Callback called when the task is not successful
  76991. */
  76992. onError: (task: any, message?: string, exception?: any) => void;
  76993. /**
  76994. * Creates a new AssetsManager
  76995. * @param name defines the name of the task
  76996. */
  76997. constructor(
  76998. /**
  76999. * Task name
  77000. */ name: string);
  77001. private _isCompleted;
  77002. private _taskState;
  77003. private _errorObject;
  77004. /**
  77005. * Get if the task is completed
  77006. */
  77007. get isCompleted(): boolean;
  77008. /**
  77009. * Gets the current state of the task
  77010. */
  77011. get taskState(): AssetTaskState;
  77012. /**
  77013. * Gets the current error object (if task is in error)
  77014. */
  77015. get errorObject(): {
  77016. message?: string;
  77017. exception?: any;
  77018. };
  77019. /**
  77020. * Internal only
  77021. * @hidden
  77022. */
  77023. _setErrorObject(message?: string, exception?: any): void;
  77024. /**
  77025. * Execute the current task
  77026. * @param scene defines the scene where you want your assets to be loaded
  77027. * @param onSuccess is a callback called when the task is successfully executed
  77028. * @param onError is a callback called if an error occurs
  77029. */
  77030. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77031. /**
  77032. * Execute the current task
  77033. * @param scene defines the scene where you want your assets to be loaded
  77034. * @param onSuccess is a callback called when the task is successfully executed
  77035. * @param onError is a callback called if an error occurs
  77036. */
  77037. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77038. /**
  77039. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77040. * This can be used with failed tasks that have the reason for failure fixed.
  77041. */
  77042. reset(): void;
  77043. private onErrorCallback;
  77044. private onDoneCallback;
  77045. }
  77046. /**
  77047. * Define the interface used by progress events raised during assets loading
  77048. */
  77049. export interface IAssetsProgressEvent {
  77050. /**
  77051. * Defines the number of remaining tasks to process
  77052. */
  77053. remainingCount: number;
  77054. /**
  77055. * Defines the total number of tasks
  77056. */
  77057. totalCount: number;
  77058. /**
  77059. * Defines the task that was just processed
  77060. */
  77061. task: AbstractAssetTask;
  77062. }
  77063. /**
  77064. * Class used to share progress information about assets loading
  77065. */
  77066. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77067. /**
  77068. * Defines the number of remaining tasks to process
  77069. */
  77070. remainingCount: number;
  77071. /**
  77072. * Defines the total number of tasks
  77073. */
  77074. totalCount: number;
  77075. /**
  77076. * Defines the task that was just processed
  77077. */
  77078. task: AbstractAssetTask;
  77079. /**
  77080. * Creates a AssetsProgressEvent
  77081. * @param remainingCount defines the number of remaining tasks to process
  77082. * @param totalCount defines the total number of tasks
  77083. * @param task defines the task that was just processed
  77084. */
  77085. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77086. }
  77087. /**
  77088. * Define a task used by AssetsManager to load assets into a container
  77089. */
  77090. export class ContainerAssetTask extends AbstractAssetTask {
  77091. /**
  77092. * Defines the name of the task
  77093. */
  77094. name: string;
  77095. /**
  77096. * Defines the list of mesh's names you want to load
  77097. */
  77098. meshesNames: any;
  77099. /**
  77100. * Defines the root url to use as a base to load your meshes and associated resources
  77101. */
  77102. rootUrl: string;
  77103. /**
  77104. * Defines the filename or File of the scene to load from
  77105. */
  77106. sceneFilename: string | File;
  77107. /**
  77108. * Get the loaded asset container
  77109. */
  77110. loadedContainer: AssetContainer;
  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: ContainerAssetTask) => void;
  77131. /**
  77132. * Callback called when the task is successful
  77133. */
  77134. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77135. /**
  77136. * Creates a new ContainerAssetTask
  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 meshes
  77169. */
  77170. export class MeshAssetTask extends AbstractAssetTask {
  77171. /**
  77172. * Defines the name of the task
  77173. */
  77174. name: string;
  77175. /**
  77176. * Defines the list of mesh's names you want to load
  77177. */
  77178. meshesNames: any;
  77179. /**
  77180. * Defines the root url to use as a base to load your meshes and associated resources
  77181. */
  77182. rootUrl: string;
  77183. /**
  77184. * Defines the filename or File of the scene to load from
  77185. */
  77186. sceneFilename: string | File;
  77187. /**
  77188. * Gets the list of loaded meshes
  77189. */
  77190. loadedMeshes: Array<AbstractMesh>;
  77191. /**
  77192. * Gets the list of loaded particle systems
  77193. */
  77194. loadedParticleSystems: Array<IParticleSystem>;
  77195. /**
  77196. * Gets the list of loaded skeletons
  77197. */
  77198. loadedSkeletons: Array<Skeleton>;
  77199. /**
  77200. * Gets the list of loaded animation groups
  77201. */
  77202. loadedAnimationGroups: Array<AnimationGroup>;
  77203. /**
  77204. * Callback called when the task is successful
  77205. */
  77206. onSuccess: (task: MeshAssetTask) => void;
  77207. /**
  77208. * Callback called when the task is successful
  77209. */
  77210. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77211. /**
  77212. * Creates a new MeshAssetTask
  77213. * @param name defines the name of the task
  77214. * @param meshesNames defines the list of mesh's names you want to load
  77215. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77216. * @param sceneFilename defines the filename or File of the scene to load from
  77217. */
  77218. constructor(
  77219. /**
  77220. * Defines the name of the task
  77221. */
  77222. name: string,
  77223. /**
  77224. * Defines the list of mesh's names you want to load
  77225. */
  77226. meshesNames: any,
  77227. /**
  77228. * Defines the root url to use as a base to load your meshes and associated resources
  77229. */
  77230. rootUrl: string,
  77231. /**
  77232. * Defines the filename or File of the scene to load from
  77233. */
  77234. sceneFilename: string | File);
  77235. /**
  77236. * Execute the current task
  77237. * @param scene defines the scene where you want your assets to be loaded
  77238. * @param onSuccess is a callback called when the task is successfully executed
  77239. * @param onError is a callback called if an error occurs
  77240. */
  77241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77242. }
  77243. /**
  77244. * Define a task used by AssetsManager to load text content
  77245. */
  77246. export class TextFileAssetTask extends AbstractAssetTask {
  77247. /**
  77248. * Defines the name of the task
  77249. */
  77250. name: string;
  77251. /**
  77252. * Defines the location of the file to load
  77253. */
  77254. url: string;
  77255. /**
  77256. * Gets the loaded text string
  77257. */
  77258. text: string;
  77259. /**
  77260. * Callback called when the task is successful
  77261. */
  77262. onSuccess: (task: TextFileAssetTask) => void;
  77263. /**
  77264. * Callback called when the task is successful
  77265. */
  77266. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77267. /**
  77268. * Creates a new TextFileAssetTask object
  77269. * @param name defines the name of the task
  77270. * @param url defines the location of the file to load
  77271. */
  77272. constructor(
  77273. /**
  77274. * Defines the name of the task
  77275. */
  77276. name: string,
  77277. /**
  77278. * Defines the location of the file to load
  77279. */
  77280. url: string);
  77281. /**
  77282. * Execute the current task
  77283. * @param scene defines the scene where you want your assets to be loaded
  77284. * @param onSuccess is a callback called when the task is successfully executed
  77285. * @param onError is a callback called if an error occurs
  77286. */
  77287. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77288. }
  77289. /**
  77290. * Define a task used by AssetsManager to load binary data
  77291. */
  77292. export class BinaryFileAssetTask extends AbstractAssetTask {
  77293. /**
  77294. * Defines the name of the task
  77295. */
  77296. name: string;
  77297. /**
  77298. * Defines the location of the file to load
  77299. */
  77300. url: string;
  77301. /**
  77302. * Gets the lodaded data (as an array buffer)
  77303. */
  77304. data: ArrayBuffer;
  77305. /**
  77306. * Callback called when the task is successful
  77307. */
  77308. onSuccess: (task: BinaryFileAssetTask) => void;
  77309. /**
  77310. * Callback called when the task is successful
  77311. */
  77312. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77313. /**
  77314. * Creates a new BinaryFileAssetTask object
  77315. * @param name defines the name of the new task
  77316. * @param url defines the location of the file to load
  77317. */
  77318. constructor(
  77319. /**
  77320. * Defines the name of the task
  77321. */
  77322. name: string,
  77323. /**
  77324. * Defines the location of the file to load
  77325. */
  77326. url: string);
  77327. /**
  77328. * Execute the current task
  77329. * @param scene defines the scene where you want your assets to be loaded
  77330. * @param onSuccess is a callback called when the task is successfully executed
  77331. * @param onError is a callback called if an error occurs
  77332. */
  77333. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77334. }
  77335. /**
  77336. * Define a task used by AssetsManager to load images
  77337. */
  77338. export class ImageAssetTask extends AbstractAssetTask {
  77339. /**
  77340. * Defines the name of the task
  77341. */
  77342. name: string;
  77343. /**
  77344. * Defines the location of the image to load
  77345. */
  77346. url: string;
  77347. /**
  77348. * Gets the loaded images
  77349. */
  77350. image: HTMLImageElement;
  77351. /**
  77352. * Callback called when the task is successful
  77353. */
  77354. onSuccess: (task: ImageAssetTask) => void;
  77355. /**
  77356. * Callback called when the task is successful
  77357. */
  77358. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77359. /**
  77360. * Creates a new ImageAssetTask
  77361. * @param name defines the name of the task
  77362. * @param url defines the location of the image to load
  77363. */
  77364. constructor(
  77365. /**
  77366. * Defines the name of the task
  77367. */
  77368. name: string,
  77369. /**
  77370. * Defines the location of the image to load
  77371. */
  77372. url: string);
  77373. /**
  77374. * Execute the current task
  77375. * @param scene defines the scene where you want your assets to be loaded
  77376. * @param onSuccess is a callback called when the task is successfully executed
  77377. * @param onError is a callback called if an error occurs
  77378. */
  77379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77380. }
  77381. /**
  77382. * Defines the interface used by texture loading tasks
  77383. */
  77384. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77385. /**
  77386. * Gets the loaded texture
  77387. */
  77388. texture: TEX;
  77389. }
  77390. /**
  77391. * Define a task used by AssetsManager to load 2D textures
  77392. */
  77393. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77394. /**
  77395. * Defines the name of the task
  77396. */
  77397. name: string;
  77398. /**
  77399. * Defines the location of the file to load
  77400. */
  77401. url: string;
  77402. /**
  77403. * Defines if mipmap should not be generated (default is false)
  77404. */
  77405. noMipmap?: boolean | undefined;
  77406. /**
  77407. * Defines if texture must be inverted on Y axis (default is true)
  77408. */
  77409. invertY: boolean;
  77410. /**
  77411. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77412. */
  77413. samplingMode: number;
  77414. /**
  77415. * Gets the loaded texture
  77416. */
  77417. texture: Texture;
  77418. /**
  77419. * Callback called when the task is successful
  77420. */
  77421. onSuccess: (task: TextureAssetTask) => void;
  77422. /**
  77423. * Callback called when the task is successful
  77424. */
  77425. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77426. /**
  77427. * Creates a new TextureAssetTask object
  77428. * @param name defines the name of the task
  77429. * @param url defines the location of the file to load
  77430. * @param noMipmap defines if mipmap should not be generated (default is false)
  77431. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77432. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77433. */
  77434. constructor(
  77435. /**
  77436. * Defines the name of the task
  77437. */
  77438. name: string,
  77439. /**
  77440. * Defines the location of the file to load
  77441. */
  77442. url: string,
  77443. /**
  77444. * Defines if mipmap should not be generated (default is false)
  77445. */
  77446. noMipmap?: boolean | undefined,
  77447. /**
  77448. * Defines if texture must be inverted on Y axis (default is true)
  77449. */
  77450. invertY?: boolean,
  77451. /**
  77452. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77453. */
  77454. samplingMode?: number);
  77455. /**
  77456. * Execute the current task
  77457. * @param scene defines the scene where you want your assets to be loaded
  77458. * @param onSuccess is a callback called when the task is successfully executed
  77459. * @param onError is a callback called if an error occurs
  77460. */
  77461. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77462. }
  77463. /**
  77464. * Define a task used by AssetsManager to load cube textures
  77465. */
  77466. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77467. /**
  77468. * Defines the name of the task
  77469. */
  77470. name: string;
  77471. /**
  77472. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77473. */
  77474. url: string;
  77475. /**
  77476. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77477. */
  77478. extensions?: string[] | undefined;
  77479. /**
  77480. * Defines if mipmaps should not be generated (default is false)
  77481. */
  77482. noMipmap?: boolean | undefined;
  77483. /**
  77484. * Defines the explicit list of files (undefined by default)
  77485. */
  77486. files?: string[] | undefined;
  77487. /**
  77488. * Gets the loaded texture
  77489. */
  77490. texture: CubeTexture;
  77491. /**
  77492. * Callback called when the task is successful
  77493. */
  77494. onSuccess: (task: CubeTextureAssetTask) => void;
  77495. /**
  77496. * Callback called when the task is successful
  77497. */
  77498. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77499. /**
  77500. * Creates a new CubeTextureAssetTask
  77501. * @param name defines the name of the task
  77502. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77503. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77504. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77505. * @param files defines the explicit list of files (undefined by default)
  77506. */
  77507. constructor(
  77508. /**
  77509. * Defines the name of the task
  77510. */
  77511. name: string,
  77512. /**
  77513. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77514. */
  77515. url: string,
  77516. /**
  77517. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77518. */
  77519. extensions?: string[] | undefined,
  77520. /**
  77521. * Defines if mipmaps should not be generated (default is false)
  77522. */
  77523. noMipmap?: boolean | undefined,
  77524. /**
  77525. * Defines the explicit list of files (undefined by default)
  77526. */
  77527. files?: string[] | undefined);
  77528. /**
  77529. * Execute the current task
  77530. * @param scene defines the scene where you want your assets to be loaded
  77531. * @param onSuccess is a callback called when the task is successfully executed
  77532. * @param onError is a callback called if an error occurs
  77533. */
  77534. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77535. }
  77536. /**
  77537. * Define a task used by AssetsManager to load HDR cube textures
  77538. */
  77539. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77540. /**
  77541. * Defines the name of the task
  77542. */
  77543. name: string;
  77544. /**
  77545. * Defines the location of the file to load
  77546. */
  77547. url: string;
  77548. /**
  77549. * Defines the desired size (the more it increases the longer the generation will be)
  77550. */
  77551. size: number;
  77552. /**
  77553. * Defines if mipmaps should not be generated (default is false)
  77554. */
  77555. noMipmap: boolean;
  77556. /**
  77557. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77558. */
  77559. generateHarmonics: boolean;
  77560. /**
  77561. * 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)
  77562. */
  77563. gammaSpace: boolean;
  77564. /**
  77565. * Internal Use Only
  77566. */
  77567. reserved: boolean;
  77568. /**
  77569. * Gets the loaded texture
  77570. */
  77571. texture: HDRCubeTexture;
  77572. /**
  77573. * Callback called when the task is successful
  77574. */
  77575. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77576. /**
  77577. * Callback called when the task is successful
  77578. */
  77579. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77580. /**
  77581. * Creates a new HDRCubeTextureAssetTask object
  77582. * @param name defines the name of the task
  77583. * @param url defines the location of the file to load
  77584. * @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.
  77585. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77586. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77587. * @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)
  77588. * @param reserved Internal use only
  77589. */
  77590. constructor(
  77591. /**
  77592. * Defines the name of the task
  77593. */
  77594. name: string,
  77595. /**
  77596. * Defines the location of the file to load
  77597. */
  77598. url: string,
  77599. /**
  77600. * Defines the desired size (the more it increases the longer the generation will be)
  77601. */
  77602. size: number,
  77603. /**
  77604. * Defines if mipmaps should not be generated (default is false)
  77605. */
  77606. noMipmap?: boolean,
  77607. /**
  77608. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77609. */
  77610. generateHarmonics?: boolean,
  77611. /**
  77612. * 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)
  77613. */
  77614. gammaSpace?: boolean,
  77615. /**
  77616. * Internal Use Only
  77617. */
  77618. reserved?: boolean);
  77619. /**
  77620. * Execute the current task
  77621. * @param scene defines the scene where you want your assets to be loaded
  77622. * @param onSuccess is a callback called when the task is successfully executed
  77623. * @param onError is a callback called if an error occurs
  77624. */
  77625. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77626. }
  77627. /**
  77628. * Define a task used by AssetsManager to load Equirectangular cube textures
  77629. */
  77630. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77631. /**
  77632. * Defines the name of the task
  77633. */
  77634. name: string;
  77635. /**
  77636. * Defines the location of the file to load
  77637. */
  77638. url: string;
  77639. /**
  77640. * Defines the desired size (the more it increases the longer the generation will be)
  77641. */
  77642. size: number;
  77643. /**
  77644. * Defines if mipmaps should not be generated (default is false)
  77645. */
  77646. noMipmap: boolean;
  77647. /**
  77648. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77649. * but the standard material would require them in Gamma space) (default is true)
  77650. */
  77651. gammaSpace: boolean;
  77652. /**
  77653. * Gets the loaded texture
  77654. */
  77655. texture: EquiRectangularCubeTexture;
  77656. /**
  77657. * Callback called when the task is successful
  77658. */
  77659. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77660. /**
  77661. * Callback called when the task is successful
  77662. */
  77663. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77664. /**
  77665. * Creates a new EquiRectangularCubeTextureAssetTask object
  77666. * @param name defines the name of the task
  77667. * @param url defines the location of the file to load
  77668. * @param size defines the desired size (the more it increases the longer the generation will be)
  77669. * If the size is omitted this implies you are using a preprocessed cubemap.
  77670. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77671. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77672. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77673. * (default is true)
  77674. */
  77675. constructor(
  77676. /**
  77677. * Defines the name of the task
  77678. */
  77679. name: string,
  77680. /**
  77681. * Defines the location of the file to load
  77682. */
  77683. url: string,
  77684. /**
  77685. * Defines the desired size (the more it increases the longer the generation will be)
  77686. */
  77687. size: number,
  77688. /**
  77689. * Defines if mipmaps should not be generated (default is false)
  77690. */
  77691. noMipmap?: boolean,
  77692. /**
  77693. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77694. * but the standard material would require them in Gamma space) (default is true)
  77695. */
  77696. gammaSpace?: boolean);
  77697. /**
  77698. * Execute the current task
  77699. * @param scene defines the scene where you want your assets to be loaded
  77700. * @param onSuccess is a callback called when the task is successfully executed
  77701. * @param onError is a callback called if an error occurs
  77702. */
  77703. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77704. }
  77705. /**
  77706. * This class can be used to easily import assets into a scene
  77707. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77708. */
  77709. export class AssetsManager {
  77710. private _scene;
  77711. private _isLoading;
  77712. protected _tasks: AbstractAssetTask[];
  77713. protected _waitingTasksCount: number;
  77714. protected _totalTasksCount: number;
  77715. /**
  77716. * Callback called when all tasks are processed
  77717. */
  77718. onFinish: (tasks: AbstractAssetTask[]) => void;
  77719. /**
  77720. * Callback called when a task is successful
  77721. */
  77722. onTaskSuccess: (task: AbstractAssetTask) => void;
  77723. /**
  77724. * Callback called when a task had an error
  77725. */
  77726. onTaskError: (task: AbstractAssetTask) => void;
  77727. /**
  77728. * Callback called when a task is done (whatever the result is)
  77729. */
  77730. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77731. /**
  77732. * Observable called when all tasks are processed
  77733. */
  77734. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77735. /**
  77736. * Observable called when a task had an error
  77737. */
  77738. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77739. /**
  77740. * Observable called when all tasks were executed
  77741. */
  77742. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77743. /**
  77744. * Observable called when a task is done (whatever the result is)
  77745. */
  77746. onProgressObservable: Observable<IAssetsProgressEvent>;
  77747. /**
  77748. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77749. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77750. */
  77751. useDefaultLoadingScreen: boolean;
  77752. /**
  77753. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77754. * when all assets have been downloaded.
  77755. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77756. */
  77757. autoHideLoadingUI: boolean;
  77758. /**
  77759. * Creates a new AssetsManager
  77760. * @param scene defines the scene to work on
  77761. */
  77762. constructor(scene: Scene);
  77763. /**
  77764. * Add a ContainerAssetTask to the list of active tasks
  77765. * @param taskName defines the name of the new task
  77766. * @param meshesNames defines the name of meshes to load
  77767. * @param rootUrl defines the root url to use to locate files
  77768. * @param sceneFilename defines the filename of the scene file
  77769. * @returns a new ContainerAssetTask object
  77770. */
  77771. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77772. /**
  77773. * Add a MeshAssetTask to the list of active tasks
  77774. * @param taskName defines the name of the new task
  77775. * @param meshesNames defines the name of meshes to load
  77776. * @param rootUrl defines the root url to use to locate files
  77777. * @param sceneFilename defines the filename of the scene file
  77778. * @returns a new MeshAssetTask object
  77779. */
  77780. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77781. /**
  77782. * Add a TextFileAssetTask to the list of active tasks
  77783. * @param taskName defines the name of the new task
  77784. * @param url defines the url of the file to load
  77785. * @returns a new TextFileAssetTask object
  77786. */
  77787. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77788. /**
  77789. * Add a BinaryFileAssetTask to the list of active tasks
  77790. * @param taskName defines the name of the new task
  77791. * @param url defines the url of the file to load
  77792. * @returns a new BinaryFileAssetTask object
  77793. */
  77794. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77795. /**
  77796. * Add a ImageAssetTask to the list of active tasks
  77797. * @param taskName defines the name of the new task
  77798. * @param url defines the url of the file to load
  77799. * @returns a new ImageAssetTask object
  77800. */
  77801. addImageTask(taskName: string, url: string): ImageAssetTask;
  77802. /**
  77803. * Add a TextureAssetTask to the list of active tasks
  77804. * @param taskName defines the name of the new task
  77805. * @param url defines the url of the file to load
  77806. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77807. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77808. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77809. * @returns a new TextureAssetTask object
  77810. */
  77811. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77812. /**
  77813. * Add a CubeTextureAssetTask to the list of active tasks
  77814. * @param taskName defines the name of the new task
  77815. * @param url defines the url of the file to load
  77816. * @param extensions defines the extension to use to load the cube map (can be null)
  77817. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77818. * @param files defines the list of files to load (can be null)
  77819. * @returns a new CubeTextureAssetTask object
  77820. */
  77821. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77822. /**
  77823. *
  77824. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77825. * @param taskName defines the name of the new task
  77826. * @param url defines the url of the file to load
  77827. * @param size defines the size you want for the cubemap (can be null)
  77828. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77829. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77830. * @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)
  77831. * @param reserved Internal use only
  77832. * @returns a new HDRCubeTextureAssetTask object
  77833. */
  77834. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77835. /**
  77836. *
  77837. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77838. * @param taskName defines the name of the new task
  77839. * @param url defines the url of the file to load
  77840. * @param size defines the size you want for the cubemap (can be null)
  77841. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77842. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77843. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77844. * @returns a new EquiRectangularCubeTextureAssetTask object
  77845. */
  77846. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77847. /**
  77848. * Remove a task from the assets manager.
  77849. * @param task the task to remove
  77850. */
  77851. removeTask(task: AbstractAssetTask): void;
  77852. private _decreaseWaitingTasksCount;
  77853. private _runTask;
  77854. /**
  77855. * Reset the AssetsManager and remove all tasks
  77856. * @return the current instance of the AssetsManager
  77857. */
  77858. reset(): AssetsManager;
  77859. /**
  77860. * Start the loading process
  77861. * @return the current instance of the AssetsManager
  77862. */
  77863. load(): AssetsManager;
  77864. /**
  77865. * Start the loading process as an async operation
  77866. * @return a promise returning the list of failed tasks
  77867. */
  77868. loadAsync(): Promise<void>;
  77869. }
  77870. }
  77871. declare module BABYLON {
  77872. /**
  77873. * Wrapper class for promise with external resolve and reject.
  77874. */
  77875. export class Deferred<T> {
  77876. /**
  77877. * The promise associated with this deferred object.
  77878. */
  77879. readonly promise: Promise<T>;
  77880. private _resolve;
  77881. private _reject;
  77882. /**
  77883. * The resolve method of the promise associated with this deferred object.
  77884. */
  77885. get resolve(): (value: T | PromiseLike<T>) => void;
  77886. /**
  77887. * The reject method of the promise associated with this deferred object.
  77888. */
  77889. get reject(): (reason?: any) => void;
  77890. /**
  77891. * Constructor for this deferred object.
  77892. */
  77893. constructor();
  77894. }
  77895. }
  77896. declare module BABYLON {
  77897. /**
  77898. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77899. */
  77900. export class MeshExploder {
  77901. private _centerMesh;
  77902. private _meshes;
  77903. private _meshesOrigins;
  77904. private _toCenterVectors;
  77905. private _scaledDirection;
  77906. private _newPosition;
  77907. private _centerPosition;
  77908. /**
  77909. * Explodes meshes from a center mesh.
  77910. * @param meshes The meshes to explode.
  77911. * @param centerMesh The mesh to be center of explosion.
  77912. */
  77913. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77914. private _setCenterMesh;
  77915. /**
  77916. * Get class name
  77917. * @returns "MeshExploder"
  77918. */
  77919. getClassName(): string;
  77920. /**
  77921. * "Exploded meshes"
  77922. * @returns Array of meshes with the centerMesh at index 0.
  77923. */
  77924. getMeshes(): Array<Mesh>;
  77925. /**
  77926. * Explodes meshes giving a specific direction
  77927. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77928. */
  77929. explode(direction?: number): void;
  77930. }
  77931. }
  77932. declare module BABYLON {
  77933. /**
  77934. * Class used to help managing file picking and drag'n'drop
  77935. */
  77936. export class FilesInput {
  77937. /**
  77938. * List of files ready to be loaded
  77939. */
  77940. static get FilesToLoad(): {
  77941. [key: string]: File;
  77942. };
  77943. /**
  77944. * Callback called when a file is processed
  77945. */
  77946. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  77947. /**
  77948. * Function used when loading the scene file
  77949. */
  77950. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  77951. private _engine;
  77952. private _currentScene;
  77953. private _sceneLoadedCallback;
  77954. private _progressCallback;
  77955. private _additionalRenderLoopLogicCallback;
  77956. private _textureLoadingCallback;
  77957. private _startingProcessingFilesCallback;
  77958. private _onReloadCallback;
  77959. private _errorCallback;
  77960. private _elementToMonitor;
  77961. private _sceneFileToLoad;
  77962. private _filesToLoad;
  77963. /**
  77964. * Creates a new FilesInput
  77965. * @param engine defines the rendering engine
  77966. * @param scene defines the hosting scene
  77967. * @param sceneLoadedCallback callback called when scene is loaded
  77968. * @param progressCallback callback called to track progress
  77969. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77970. * @param textureLoadingCallback callback called when a texture is loading
  77971. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77972. * @param onReloadCallback callback called when a reload is requested
  77973. * @param errorCallback callback call if an error occurs
  77974. */
  77975. 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>);
  77976. private _dragEnterHandler;
  77977. private _dragOverHandler;
  77978. private _dropHandler;
  77979. /**
  77980. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77981. * @param elementToMonitor defines the DOM element to track
  77982. */
  77983. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77984. /** Gets the current list of files to load */
  77985. get filesToLoad(): File[];
  77986. /**
  77987. * Release all associated resources
  77988. */
  77989. dispose(): void;
  77990. private renderFunction;
  77991. private drag;
  77992. private drop;
  77993. private _traverseFolder;
  77994. private _processFiles;
  77995. /**
  77996. * Load files from a drop event
  77997. * @param event defines the drop event to use as source
  77998. */
  77999. loadFiles(event: any): void;
  78000. private _processReload;
  78001. /**
  78002. * Reload the current scene from the loaded files
  78003. */
  78004. reload(): void;
  78005. }
  78006. }
  78007. declare module BABYLON {
  78008. /**
  78009. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78010. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78011. */
  78012. export class SceneOptimization {
  78013. /**
  78014. * Defines the priority of this optimization (0 by default which means first in the list)
  78015. */
  78016. priority: number;
  78017. /**
  78018. * Gets a string describing the action executed by the current optimization
  78019. * @returns description string
  78020. */
  78021. getDescription(): string;
  78022. /**
  78023. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78024. * @param scene defines the current scene where to apply this optimization
  78025. * @param optimizer defines the current optimizer
  78026. * @returns true if everything that can be done was applied
  78027. */
  78028. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78029. /**
  78030. * Creates the SceneOptimization object
  78031. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78032. * @param desc defines the description associated with the optimization
  78033. */
  78034. constructor(
  78035. /**
  78036. * Defines the priority of this optimization (0 by default which means first in the list)
  78037. */
  78038. priority?: number);
  78039. }
  78040. /**
  78041. * Defines an optimization used to reduce the size of render target textures
  78042. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78043. */
  78044. export class TextureOptimization extends SceneOptimization {
  78045. /**
  78046. * Defines the priority of this optimization (0 by default which means first in the list)
  78047. */
  78048. priority: number;
  78049. /**
  78050. * 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
  78051. */
  78052. maximumSize: number;
  78053. /**
  78054. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78055. */
  78056. step: number;
  78057. /**
  78058. * Gets a string describing the action executed by the current optimization
  78059. * @returns description string
  78060. */
  78061. getDescription(): string;
  78062. /**
  78063. * Creates the TextureOptimization object
  78064. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78065. * @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
  78066. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78067. */
  78068. constructor(
  78069. /**
  78070. * Defines the priority of this optimization (0 by default which means first in the list)
  78071. */
  78072. priority?: number,
  78073. /**
  78074. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  78075. */
  78076. maximumSize?: number,
  78077. /**
  78078. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78079. */
  78080. step?: number);
  78081. /**
  78082. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78083. * @param scene defines the current scene where to apply this optimization
  78084. * @param optimizer defines the current optimizer
  78085. * @returns true if everything that can be done was applied
  78086. */
  78087. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78088. }
  78089. /**
  78090. * Defines an optimization used to increase or decrease the rendering resolution
  78091. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78092. */
  78093. export class HardwareScalingOptimization extends SceneOptimization {
  78094. /**
  78095. * Defines the priority of this optimization (0 by default which means first in the list)
  78096. */
  78097. priority: number;
  78098. /**
  78099. * Defines the maximum scale to use (2 by default)
  78100. */
  78101. maximumScale: number;
  78102. /**
  78103. * Defines the step to use between two passes (0.5 by default)
  78104. */
  78105. step: number;
  78106. private _currentScale;
  78107. private _directionOffset;
  78108. /**
  78109. * Gets a string describing the action executed by the current optimization
  78110. * @return description string
  78111. */
  78112. getDescription(): string;
  78113. /**
  78114. * Creates the HardwareScalingOptimization object
  78115. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78116. * @param maximumScale defines the maximum scale to use (2 by default)
  78117. * @param step defines the step to use between two passes (0.5 by default)
  78118. */
  78119. constructor(
  78120. /**
  78121. * Defines the priority of this optimization (0 by default which means first in the list)
  78122. */
  78123. priority?: number,
  78124. /**
  78125. * Defines the maximum scale to use (2 by default)
  78126. */
  78127. maximumScale?: number,
  78128. /**
  78129. * Defines the step to use between two passes (0.5 by default)
  78130. */
  78131. step?: number);
  78132. /**
  78133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78134. * @param scene defines the current scene where to apply this optimization
  78135. * @param optimizer defines the current optimizer
  78136. * @returns true if everything that can be done was applied
  78137. */
  78138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78139. }
  78140. /**
  78141. * Defines an optimization used to remove shadows
  78142. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78143. */
  78144. export class ShadowsOptimization extends SceneOptimization {
  78145. /**
  78146. * Gets a string describing the action executed by the current optimization
  78147. * @return description string
  78148. */
  78149. getDescription(): string;
  78150. /**
  78151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78152. * @param scene defines the current scene where to apply this optimization
  78153. * @param optimizer defines the current optimizer
  78154. * @returns true if everything that can be done was applied
  78155. */
  78156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78157. }
  78158. /**
  78159. * Defines an optimization used to turn post-processes off
  78160. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78161. */
  78162. export class PostProcessesOptimization extends SceneOptimization {
  78163. /**
  78164. * Gets a string describing the action executed by the current optimization
  78165. * @return description string
  78166. */
  78167. getDescription(): string;
  78168. /**
  78169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78170. * @param scene defines the current scene where to apply this optimization
  78171. * @param optimizer defines the current optimizer
  78172. * @returns true if everything that can be done was applied
  78173. */
  78174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78175. }
  78176. /**
  78177. * Defines an optimization used to turn lens flares off
  78178. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78179. */
  78180. export class LensFlaresOptimization extends SceneOptimization {
  78181. /**
  78182. * Gets a string describing the action executed by the current optimization
  78183. * @return description string
  78184. */
  78185. getDescription(): string;
  78186. /**
  78187. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78188. * @param scene defines the current scene where to apply this optimization
  78189. * @param optimizer defines the current optimizer
  78190. * @returns true if everything that can be done was applied
  78191. */
  78192. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78193. }
  78194. /**
  78195. * Defines an optimization based on user defined callback.
  78196. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78197. */
  78198. export class CustomOptimization extends SceneOptimization {
  78199. /**
  78200. * Callback called to apply the custom optimization.
  78201. */
  78202. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78203. /**
  78204. * Callback called to get custom description
  78205. */
  78206. onGetDescription: () => string;
  78207. /**
  78208. * Gets a string describing the action executed by the current optimization
  78209. * @returns description string
  78210. */
  78211. getDescription(): string;
  78212. /**
  78213. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78214. * @param scene defines the current scene where to apply this optimization
  78215. * @param optimizer defines the current optimizer
  78216. * @returns true if everything that can be done was applied
  78217. */
  78218. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78219. }
  78220. /**
  78221. * Defines an optimization used to turn particles off
  78222. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78223. */
  78224. export class ParticlesOptimization extends SceneOptimization {
  78225. /**
  78226. * Gets a string describing the action executed by the current optimization
  78227. * @return description string
  78228. */
  78229. getDescription(): string;
  78230. /**
  78231. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78232. * @param scene defines the current scene where to apply this optimization
  78233. * @param optimizer defines the current optimizer
  78234. * @returns true if everything that can be done was applied
  78235. */
  78236. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78237. }
  78238. /**
  78239. * Defines an optimization used to turn render targets off
  78240. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78241. */
  78242. export class RenderTargetsOptimization extends SceneOptimization {
  78243. /**
  78244. * Gets a string describing the action executed by the current optimization
  78245. * @return description string
  78246. */
  78247. getDescription(): string;
  78248. /**
  78249. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78250. * @param scene defines the current scene where to apply this optimization
  78251. * @param optimizer defines the current optimizer
  78252. * @returns true if everything that can be done was applied
  78253. */
  78254. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78255. }
  78256. /**
  78257. * Defines an optimization used to merge meshes with compatible materials
  78258. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78259. */
  78260. export class MergeMeshesOptimization extends SceneOptimization {
  78261. private static _UpdateSelectionTree;
  78262. /**
  78263. * Gets or sets a boolean which defines if optimization octree has to be updated
  78264. */
  78265. static get UpdateSelectionTree(): boolean;
  78266. /**
  78267. * Gets or sets a boolean which defines if optimization octree has to be updated
  78268. */
  78269. static set UpdateSelectionTree(value: boolean);
  78270. /**
  78271. * Gets a string describing the action executed by the current optimization
  78272. * @return description string
  78273. */
  78274. getDescription(): string;
  78275. private _canBeMerged;
  78276. /**
  78277. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78278. * @param scene defines the current scene where to apply this optimization
  78279. * @param optimizer defines the current optimizer
  78280. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78281. * @returns true if everything that can be done was applied
  78282. */
  78283. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78284. }
  78285. /**
  78286. * Defines a list of options used by SceneOptimizer
  78287. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78288. */
  78289. export class SceneOptimizerOptions {
  78290. /**
  78291. * Defines the target frame rate to reach (60 by default)
  78292. */
  78293. targetFrameRate: number;
  78294. /**
  78295. * Defines the interval between two checkes (2000ms by default)
  78296. */
  78297. trackerDuration: number;
  78298. /**
  78299. * Gets the list of optimizations to apply
  78300. */
  78301. optimizations: SceneOptimization[];
  78302. /**
  78303. * Creates a new list of options used by SceneOptimizer
  78304. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78305. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78306. */
  78307. constructor(
  78308. /**
  78309. * Defines the target frame rate to reach (60 by default)
  78310. */
  78311. targetFrameRate?: number,
  78312. /**
  78313. * Defines the interval between two checkes (2000ms by default)
  78314. */
  78315. trackerDuration?: number);
  78316. /**
  78317. * Add a new optimization
  78318. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78319. * @returns the current SceneOptimizerOptions
  78320. */
  78321. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78322. /**
  78323. * Add a new custom optimization
  78324. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78325. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78326. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78327. * @returns the current SceneOptimizerOptions
  78328. */
  78329. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78330. /**
  78331. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78332. * @param targetFrameRate defines the target frame rate (60 by default)
  78333. * @returns a SceneOptimizerOptions object
  78334. */
  78335. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78336. /**
  78337. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78338. * @param targetFrameRate defines the target frame rate (60 by default)
  78339. * @returns a SceneOptimizerOptions object
  78340. */
  78341. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78342. /**
  78343. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78344. * @param targetFrameRate defines the target frame rate (60 by default)
  78345. * @returns a SceneOptimizerOptions object
  78346. */
  78347. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78348. }
  78349. /**
  78350. * Class used to run optimizations in order to reach a target frame rate
  78351. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78352. */
  78353. export class SceneOptimizer implements IDisposable {
  78354. private _isRunning;
  78355. private _options;
  78356. private _scene;
  78357. private _currentPriorityLevel;
  78358. private _targetFrameRate;
  78359. private _trackerDuration;
  78360. private _currentFrameRate;
  78361. private _sceneDisposeObserver;
  78362. private _improvementMode;
  78363. /**
  78364. * Defines an observable called when the optimizer reaches the target frame rate
  78365. */
  78366. onSuccessObservable: Observable<SceneOptimizer>;
  78367. /**
  78368. * Defines an observable called when the optimizer enables an optimization
  78369. */
  78370. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78371. /**
  78372. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78373. */
  78374. onFailureObservable: Observable<SceneOptimizer>;
  78375. /**
  78376. * Gets a boolean indicating if the optimizer is in improvement mode
  78377. */
  78378. get isInImprovementMode(): boolean;
  78379. /**
  78380. * Gets the current priority level (0 at start)
  78381. */
  78382. get currentPriorityLevel(): number;
  78383. /**
  78384. * Gets the current frame rate checked by the SceneOptimizer
  78385. */
  78386. get currentFrameRate(): number;
  78387. /**
  78388. * Gets or sets the current target frame rate (60 by default)
  78389. */
  78390. get targetFrameRate(): number;
  78391. /**
  78392. * Gets or sets the current target frame rate (60 by default)
  78393. */
  78394. set targetFrameRate(value: number);
  78395. /**
  78396. * Gets or sets the current interval between two checks (every 2000ms by default)
  78397. */
  78398. get trackerDuration(): number;
  78399. /**
  78400. * Gets or sets the current interval between two checks (every 2000ms by default)
  78401. */
  78402. set trackerDuration(value: number);
  78403. /**
  78404. * Gets the list of active optimizations
  78405. */
  78406. get optimizations(): SceneOptimization[];
  78407. /**
  78408. * Creates a new SceneOptimizer
  78409. * @param scene defines the scene to work on
  78410. * @param options defines the options to use with the SceneOptimizer
  78411. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78412. * @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)
  78413. */
  78414. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78415. /**
  78416. * Stops the current optimizer
  78417. */
  78418. stop(): void;
  78419. /**
  78420. * Reset the optimizer to initial step (current priority level = 0)
  78421. */
  78422. reset(): void;
  78423. /**
  78424. * Start the optimizer. By default it will try to reach a specific framerate
  78425. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78426. */
  78427. start(): void;
  78428. private _checkCurrentState;
  78429. /**
  78430. * Release all resources
  78431. */
  78432. dispose(): void;
  78433. /**
  78434. * Helper function to create a SceneOptimizer with one single line of code
  78435. * @param scene defines the scene to work on
  78436. * @param options defines the options to use with the SceneOptimizer
  78437. * @param onSuccess defines a callback to call on success
  78438. * @param onFailure defines a callback to call on failure
  78439. * @returns the new SceneOptimizer object
  78440. */
  78441. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78442. }
  78443. }
  78444. declare module BABYLON {
  78445. /**
  78446. * Class used to serialize a scene into a string
  78447. */
  78448. export class SceneSerializer {
  78449. /**
  78450. * Clear cache used by a previous serialization
  78451. */
  78452. static ClearCache(): void;
  78453. /**
  78454. * Serialize a scene into a JSON compatible object
  78455. * @param scene defines the scene to serialize
  78456. * @returns a JSON compatible object
  78457. */
  78458. static Serialize(scene: Scene): any;
  78459. /**
  78460. * Serialize a mesh into a JSON compatible object
  78461. * @param toSerialize defines the mesh to serialize
  78462. * @param withParents defines if parents must be serialized as well
  78463. * @param withChildren defines if children must be serialized as well
  78464. * @returns a JSON compatible object
  78465. */
  78466. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78467. }
  78468. }
  78469. declare module BABYLON {
  78470. /**
  78471. * This represents the different options available for the video capture.
  78472. */
  78473. export interface VideoRecorderOptions {
  78474. /** Defines the mime type of the video. */
  78475. mimeType: string;
  78476. /** Defines the FPS the video should be recorded at. */
  78477. fps: number;
  78478. /** Defines the chunk size for the recording data. */
  78479. recordChunckSize: number;
  78480. /** The audio tracks to attach to the recording. */
  78481. audioTracks?: MediaStreamTrack[];
  78482. }
  78483. /**
  78484. * This can help with recording videos from BabylonJS.
  78485. * This is based on the available WebRTC functionalities of the browser.
  78486. *
  78487. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78488. */
  78489. export class VideoRecorder {
  78490. private static readonly _defaultOptions;
  78491. /**
  78492. * Returns whether or not the VideoRecorder is available in your browser.
  78493. * @param engine Defines the Babylon Engine.
  78494. * @returns true if supported otherwise false.
  78495. */
  78496. static IsSupported(engine: Engine): boolean;
  78497. private readonly _options;
  78498. private _canvas;
  78499. private _mediaRecorder;
  78500. private _recordedChunks;
  78501. private _fileName;
  78502. private _resolve;
  78503. private _reject;
  78504. /**
  78505. * True when a recording is already in progress.
  78506. */
  78507. get isRecording(): boolean;
  78508. /**
  78509. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78510. * @param engine Defines the BabylonJS Engine you wish to record.
  78511. * @param options Defines options that can be used to customize the capture.
  78512. */
  78513. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78514. /**
  78515. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78516. */
  78517. stopRecording(): void;
  78518. /**
  78519. * Starts recording the canvas for a max duration specified in parameters.
  78520. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78521. * If null no automatic download will start and you can rely on the promise to get the data back.
  78522. * @param maxDuration Defines the maximum recording time in seconds.
  78523. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78524. * @return A promise callback at the end of the recording with the video data in Blob.
  78525. */
  78526. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78527. /**
  78528. * Releases internal resources used during the recording.
  78529. */
  78530. dispose(): void;
  78531. private _handleDataAvailable;
  78532. private _handleError;
  78533. private _handleStop;
  78534. }
  78535. }
  78536. declare module BABYLON {
  78537. /**
  78538. * Class containing a set of static utilities functions for screenshots
  78539. */
  78540. export class ScreenshotTools {
  78541. /**
  78542. * Captures a screenshot of the current rendering
  78543. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78544. * @param engine defines the rendering engine
  78545. * @param camera defines the source camera
  78546. * @param size This parameter can be set to a single number or to an object with the
  78547. * following (optional) properties: precision, width, height. If a single number is passed,
  78548. * it will be used for both width and height. If an object is passed, the screenshot size
  78549. * will be derived from the parameters. The precision property is a multiplier allowing
  78550. * rendering at a higher or lower resolution
  78551. * @param successCallback defines the callback receives a single parameter which contains the
  78552. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78553. * src parameter of an <img> to display it
  78554. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78555. * Check your browser for supported MIME types
  78556. * @param forceDownload force the system to download the image even if a successCallback is provided
  78557. */
  78558. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  78559. /**
  78560. * Captures a screenshot of the current rendering
  78561. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78562. * @param engine defines the rendering engine
  78563. * @param camera defines the source camera
  78564. * @param size This parameter can be set to a single number or to an object with the
  78565. * following (optional) properties: precision, width, height. If a single number is passed,
  78566. * it will be used for both width and height. If an object is passed, the screenshot size
  78567. * will be derived from the parameters. The precision property is a multiplier allowing
  78568. * rendering at a higher or lower resolution
  78569. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78570. * Check your browser for supported MIME types
  78571. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78572. * to the src parameter of an <img> to display it
  78573. */
  78574. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78575. /**
  78576. * 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)
  78577. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78578. * @param engine defines the rendering engine
  78579. * @param camera defines the source camera
  78580. * @param width defines the expected width
  78581. * @param height defines the expected height
  78582. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78583. * Check your browser for supported MIME types
  78584. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78585. * to the src parameter of an <img> to display it
  78586. */
  78587. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  78588. /**
  78589. * Generates an image screenshot from the specified camera.
  78590. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78591. * @param engine The engine to use for rendering
  78592. * @param camera The camera to use for rendering
  78593. * @param size This parameter can be set to a single number or to an object with the
  78594. * following (optional) properties: precision, width, height. If a single number is passed,
  78595. * it will be used for both width and height. If an object is passed, the screenshot size
  78596. * will be derived from the parameters. The precision property is a multiplier allowing
  78597. * rendering at a higher or lower resolution
  78598. * @param successCallback The callback receives a single parameter which contains the
  78599. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78600. * src parameter of an <img> to display it
  78601. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78602. * Check your browser for supported MIME types
  78603. * @param samples Texture samples (default: 1)
  78604. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78605. * @param fileName A name for for the downloaded file.
  78606. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78607. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78608. */
  78609. 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;
  78610. /**
  78611. * Generates an image screenshot from the specified camera.
  78612. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78613. * @param engine The engine to use for rendering
  78614. * @param camera The camera to use for rendering
  78615. * @param size This parameter can be set to a single number or to an object with the
  78616. * following (optional) properties: precision, width, height. If a single number is passed,
  78617. * it will be used for both width and height. If an object is passed, the screenshot size
  78618. * will be derived from the parameters. The precision property is a multiplier allowing
  78619. * rendering at a higher or lower resolution
  78620. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78621. * Check your browser for supported MIME types
  78622. * @param samples Texture samples (default: 1)
  78623. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78624. * @param fileName A name for for the downloaded file.
  78625. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78626. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78627. * to the src parameter of an <img> to display it
  78628. */
  78629. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78630. /**
  78631. * Gets height and width for screenshot size
  78632. * @private
  78633. */
  78634. private static _getScreenshotSize;
  78635. }
  78636. }
  78637. declare module BABYLON {
  78638. /**
  78639. * Interface for a data buffer
  78640. */
  78641. export interface IDataBuffer {
  78642. /**
  78643. * Reads bytes from the data buffer.
  78644. * @param byteOffset The byte offset to read
  78645. * @param byteLength The byte length to read
  78646. * @returns A promise that resolves when the bytes are read
  78647. */
  78648. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78649. /**
  78650. * The byte length of the buffer.
  78651. */
  78652. readonly byteLength: number;
  78653. }
  78654. /**
  78655. * Utility class for reading from a data buffer
  78656. */
  78657. export class DataReader {
  78658. /**
  78659. * The data buffer associated with this data reader.
  78660. */
  78661. readonly buffer: IDataBuffer;
  78662. /**
  78663. * The current byte offset from the beginning of the data buffer.
  78664. */
  78665. byteOffset: number;
  78666. private _dataView;
  78667. private _dataByteOffset;
  78668. /**
  78669. * Constructor
  78670. * @param buffer The buffer to read
  78671. */
  78672. constructor(buffer: IDataBuffer);
  78673. /**
  78674. * Loads the given byte length.
  78675. * @param byteLength The byte length to load
  78676. * @returns A promise that resolves when the load is complete
  78677. */
  78678. loadAsync(byteLength: number): Promise<void>;
  78679. /**
  78680. * Read a unsigned 32-bit integer from the currently loaded data range.
  78681. * @returns The 32-bit integer read
  78682. */
  78683. readUint32(): number;
  78684. /**
  78685. * Read a byte array from the currently loaded data range.
  78686. * @param byteLength The byte length to read
  78687. * @returns The byte array read
  78688. */
  78689. readUint8Array(byteLength: number): Uint8Array;
  78690. /**
  78691. * Read a string from the currently loaded data range.
  78692. * @param byteLength The byte length to read
  78693. * @returns The string read
  78694. */
  78695. readString(byteLength: number): string;
  78696. /**
  78697. * Skips the given byte length the currently loaded data range.
  78698. * @param byteLength The byte length to skip
  78699. */
  78700. skipBytes(byteLength: number): void;
  78701. }
  78702. }
  78703. declare module BABYLON {
  78704. /**
  78705. * Class for storing data to local storage if available or in-memory storage otherwise
  78706. */
  78707. export class DataStorage {
  78708. private static _Storage;
  78709. private static _GetStorage;
  78710. /**
  78711. * Reads a string from the data storage
  78712. * @param key The key to read
  78713. * @param defaultValue The value if the key doesn't exist
  78714. * @returns The string value
  78715. */
  78716. static ReadString(key: string, defaultValue: string): string;
  78717. /**
  78718. * Writes a string to the data storage
  78719. * @param key The key to write
  78720. * @param value The value to write
  78721. */
  78722. static WriteString(key: string, value: string): void;
  78723. /**
  78724. * Reads a boolean from the data storage
  78725. * @param key The key to read
  78726. * @param defaultValue The value if the key doesn't exist
  78727. * @returns The boolean value
  78728. */
  78729. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78730. /**
  78731. * Writes a boolean to the data storage
  78732. * @param key The key to write
  78733. * @param value The value to write
  78734. */
  78735. static WriteBoolean(key: string, value: boolean): void;
  78736. /**
  78737. * Reads a number from the data storage
  78738. * @param key The key to read
  78739. * @param defaultValue The value if the key doesn't exist
  78740. * @returns The number value
  78741. */
  78742. static ReadNumber(key: string, defaultValue: number): number;
  78743. /**
  78744. * Writes a number to the data storage
  78745. * @param key The key to write
  78746. * @param value The value to write
  78747. */
  78748. static WriteNumber(key: string, value: number): void;
  78749. }
  78750. }
  78751. declare module BABYLON {
  78752. /**
  78753. * Class used to record delta files between 2 scene states
  78754. */
  78755. export class SceneRecorder {
  78756. private _trackedScene;
  78757. private _savedJSON;
  78758. /**
  78759. * Track a given scene. This means the current scene state will be considered the original state
  78760. * @param scene defines the scene to track
  78761. */
  78762. track(scene: Scene): void;
  78763. /**
  78764. * Get the delta between current state and original state
  78765. * @returns a string containing the delta
  78766. */
  78767. getDelta(): any;
  78768. private _compareArray;
  78769. private _compareObjects;
  78770. private _compareCollections;
  78771. private static GetShadowGeneratorById;
  78772. /**
  78773. * Apply a given delta to a given scene
  78774. * @param deltaJSON defines the JSON containing the delta
  78775. * @param scene defines the scene to apply the delta to
  78776. */
  78777. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78778. private static _ApplyPropertiesToEntity;
  78779. private static _ApplyDeltaForEntity;
  78780. }
  78781. }
  78782. declare module BABYLON {
  78783. /**
  78784. * A 3D trajectory consisting of an order list of vectors describing a
  78785. * path of motion through 3D space.
  78786. */
  78787. export class Trajectory {
  78788. private _points;
  78789. private readonly _segmentLength;
  78790. /**
  78791. * Serialize to JSON.
  78792. * @returns serialized JSON string
  78793. */
  78794. serialize(): string;
  78795. /**
  78796. * Deserialize from JSON.
  78797. * @param json serialized JSON string
  78798. * @returns deserialized Trajectory
  78799. */
  78800. static Deserialize(json: string): Trajectory;
  78801. /**
  78802. * Create a new empty Trajectory.
  78803. * @param segmentLength radius of discretization for Trajectory points
  78804. */
  78805. constructor(segmentLength?: number);
  78806. /**
  78807. * Get the length of the Trajectory.
  78808. * @returns length of the Trajectory
  78809. */
  78810. getLength(): number;
  78811. /**
  78812. * Append a new point to the Trajectory.
  78813. * NOTE: This implementation has many allocations.
  78814. * @param point point to append to the Trajectory
  78815. */
  78816. add(point: DeepImmutable<Vector3>): void;
  78817. /**
  78818. * Create a new Trajectory with a segment length chosen to make it
  78819. * probable that the new Trajectory will have a specified number of
  78820. * segments. This operation is imprecise.
  78821. * @param targetResolution number of segments desired
  78822. * @returns new Trajectory with approximately the requested number of segments
  78823. */
  78824. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78825. /**
  78826. * Convert Trajectory segments into tokenized representation. This
  78827. * representation is an array of numbers where each nth number is the
  78828. * index of the token which is most similar to the nth segment of the
  78829. * Trajectory.
  78830. * @param tokens list of vectors which serve as discrete tokens
  78831. * @returns list of indices of most similar token per segment
  78832. */
  78833. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78834. private static _forwardDir;
  78835. private static _inverseFromVec;
  78836. private static _upDir;
  78837. private static _fromToVec;
  78838. private static _lookMatrix;
  78839. /**
  78840. * Transform the rotation (i.e., direction) of a segment to isolate
  78841. * the relative transformation represented by the segment. This operation
  78842. * may or may not succeed due to singularities in the equations that define
  78843. * motion relativity in this context.
  78844. * @param priorVec the origin of the prior segment
  78845. * @param fromVec the origin of the current segment
  78846. * @param toVec the destination of the current segment
  78847. * @param result reference to output variable
  78848. * @returns whether or not transformation was successful
  78849. */
  78850. private static _transformSegmentDirToRef;
  78851. private static _bestMatch;
  78852. private static _score;
  78853. private static _bestScore;
  78854. /**
  78855. * Determine which token vector is most similar to the
  78856. * segment vector.
  78857. * @param segment segment vector
  78858. * @param tokens token vector list
  78859. * @returns index of the most similar token to the segment
  78860. */
  78861. private static _tokenizeSegment;
  78862. }
  78863. /**
  78864. * Class representing a set of known, named trajectories to which Trajectories can be
  78865. * added and using which Trajectories can be recognized.
  78866. */
  78867. export class TrajectoryClassifier {
  78868. private _maximumAllowableMatchCost;
  78869. private _vector3Alphabet;
  78870. private _levenshteinAlphabet;
  78871. private _nameToDescribedTrajectory;
  78872. /**
  78873. * Serialize to JSON.
  78874. * @returns JSON serialization
  78875. */
  78876. serialize(): string;
  78877. /**
  78878. * Deserialize from JSON.
  78879. * @param json JSON serialization
  78880. * @returns deserialized TrajectorySet
  78881. */
  78882. static Deserialize(json: string): TrajectoryClassifier;
  78883. /**
  78884. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78885. * VERY naive, need to be generating these things from known
  78886. * sets. Better version later, probably eliminating this one.
  78887. * @returns auto-generated TrajectorySet
  78888. */
  78889. static Generate(): TrajectoryClassifier;
  78890. private constructor();
  78891. /**
  78892. * Add a new Trajectory to the set with a given name.
  78893. * @param trajectory new Trajectory to be added
  78894. * @param classification name to which to add the Trajectory
  78895. */
  78896. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78897. /**
  78898. * Remove a known named trajectory and all Trajectories associated with it.
  78899. * @param classification name to remove
  78900. * @returns whether anything was removed
  78901. */
  78902. deleteClassification(classification: string): boolean;
  78903. /**
  78904. * Attempt to recognize a Trajectory from among all the classifications
  78905. * already known to the classifier.
  78906. * @param trajectory Trajectory to be recognized
  78907. * @returns classification of Trajectory if recognized, null otherwise
  78908. */
  78909. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78910. }
  78911. }
  78912. declare module BABYLON {
  78913. /**
  78914. * An interface for all Hit test features
  78915. */
  78916. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78917. /**
  78918. * Triggered when new babylon (transformed) hit test results are available
  78919. */
  78920. onHitTestResultObservable: Observable<T[]>;
  78921. }
  78922. /**
  78923. * Options used for hit testing
  78924. */
  78925. export interface IWebXRLegacyHitTestOptions {
  78926. /**
  78927. * Only test when user interacted with the scene. Default - hit test every frame
  78928. */
  78929. testOnPointerDownOnly?: boolean;
  78930. /**
  78931. * The node to use to transform the local results to world coordinates
  78932. */
  78933. worldParentNode?: TransformNode;
  78934. }
  78935. /**
  78936. * Interface defining the babylon result of raycasting/hit-test
  78937. */
  78938. export interface IWebXRLegacyHitResult {
  78939. /**
  78940. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78941. */
  78942. transformationMatrix: Matrix;
  78943. /**
  78944. * The native hit test result
  78945. */
  78946. xrHitResult: XRHitResult | XRHitTestResult;
  78947. }
  78948. /**
  78949. * The currently-working hit-test module.
  78950. * Hit test (or Ray-casting) is used to interact with the real world.
  78951. * For further information read here - https://github.com/immersive-web/hit-test
  78952. */
  78953. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78954. /**
  78955. * options to use when constructing this feature
  78956. */
  78957. readonly options: IWebXRLegacyHitTestOptions;
  78958. private _direction;
  78959. private _mat;
  78960. private _onSelectEnabled;
  78961. private _origin;
  78962. /**
  78963. * The module's name
  78964. */
  78965. static readonly Name: string;
  78966. /**
  78967. * The (Babylon) version of this module.
  78968. * This is an integer representing the implementation version.
  78969. * This number does not correspond to the WebXR specs version
  78970. */
  78971. static readonly Version: number;
  78972. /**
  78973. * Populated with the last native XR Hit Results
  78974. */
  78975. lastNativeXRHitResults: XRHitResult[];
  78976. /**
  78977. * Triggered when new babylon (transformed) hit test results are available
  78978. */
  78979. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78980. /**
  78981. * Creates a new instance of the (legacy version) hit test feature
  78982. * @param _xrSessionManager an instance of WebXRSessionManager
  78983. * @param options options to use when constructing this feature
  78984. */
  78985. constructor(_xrSessionManager: WebXRSessionManager,
  78986. /**
  78987. * options to use when constructing this feature
  78988. */
  78989. options?: IWebXRLegacyHitTestOptions);
  78990. /**
  78991. * execute a hit test with an XR Ray
  78992. *
  78993. * @param xrSession a native xrSession that will execute this hit test
  78994. * @param xrRay the ray (position and direction) to use for ray-casting
  78995. * @param referenceSpace native XR reference space to use for the hit-test
  78996. * @param filter filter function that will filter the results
  78997. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78998. */
  78999. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79000. /**
  79001. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79002. * @param event the (select) event to use to select with
  79003. * @param referenceSpace the reference space to use for this hit test
  79004. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79005. */
  79006. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79007. /**
  79008. * attach this feature
  79009. * Will usually be called by the features manager
  79010. *
  79011. * @returns true if successful.
  79012. */
  79013. attach(): boolean;
  79014. /**
  79015. * detach this feature.
  79016. * Will usually be called by the features manager
  79017. *
  79018. * @returns true if successful.
  79019. */
  79020. detach(): boolean;
  79021. /**
  79022. * Dispose this feature and all of the resources attached
  79023. */
  79024. dispose(): void;
  79025. protected _onXRFrame(frame: XRFrame): void;
  79026. private _onHitTestResults;
  79027. private _onSelect;
  79028. }
  79029. }
  79030. declare module BABYLON {
  79031. /**
  79032. * Options used for hit testing (version 2)
  79033. */
  79034. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79035. /**
  79036. * Do not create a permanent hit test. Will usually be used when only
  79037. * transient inputs are needed.
  79038. */
  79039. disablePermanentHitTest?: boolean;
  79040. /**
  79041. * Enable transient (for example touch-based) hit test inspections
  79042. */
  79043. enableTransientHitTest?: boolean;
  79044. /**
  79045. * Offset ray for the permanent hit test
  79046. */
  79047. offsetRay?: Vector3;
  79048. /**
  79049. * Offset ray for the transient hit test
  79050. */
  79051. transientOffsetRay?: Vector3;
  79052. /**
  79053. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79054. */
  79055. useReferenceSpace?: boolean;
  79056. /**
  79057. * Override the default entity type(s) of the hit-test result
  79058. */
  79059. entityTypes?: XRHitTestTrackableType[];
  79060. }
  79061. /**
  79062. * Interface defining the babylon result of hit-test
  79063. */
  79064. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79065. /**
  79066. * The input source that generated this hit test (if transient)
  79067. */
  79068. inputSource?: XRInputSource;
  79069. /**
  79070. * Is this a transient hit test
  79071. */
  79072. isTransient?: boolean;
  79073. /**
  79074. * Position of the hit test result
  79075. */
  79076. position: Vector3;
  79077. /**
  79078. * Rotation of the hit test result
  79079. */
  79080. rotationQuaternion: Quaternion;
  79081. /**
  79082. * The native hit test result
  79083. */
  79084. xrHitResult: XRHitTestResult;
  79085. }
  79086. /**
  79087. * The currently-working hit-test module.
  79088. * Hit test (or Ray-casting) is used to interact with the real world.
  79089. * For further information read here - https://github.com/immersive-web/hit-test
  79090. *
  79091. * Tested on chrome (mobile) 80.
  79092. */
  79093. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79094. /**
  79095. * options to use when constructing this feature
  79096. */
  79097. readonly options: IWebXRHitTestOptions;
  79098. private _tmpMat;
  79099. private _tmpPos;
  79100. private _tmpQuat;
  79101. private _transientXrHitTestSource;
  79102. private _xrHitTestSource;
  79103. private initHitTestSource;
  79104. /**
  79105. * The module's name
  79106. */
  79107. static readonly Name: string;
  79108. /**
  79109. * The (Babylon) version of this module.
  79110. * This is an integer representing the implementation version.
  79111. * This number does not correspond to the WebXR specs version
  79112. */
  79113. static readonly Version: number;
  79114. /**
  79115. * When set to true, each hit test will have its own position/rotation objects
  79116. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79117. * the developers will clone them or copy them as they see fit.
  79118. */
  79119. autoCloneTransformation: boolean;
  79120. /**
  79121. * Triggered when new babylon (transformed) hit test results are available
  79122. * Note - this will be called when results come back from the device. It can be an empty array!!
  79123. */
  79124. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79125. /**
  79126. * Use this to temporarily pause hit test checks.
  79127. */
  79128. paused: boolean;
  79129. /**
  79130. * Creates a new instance of the hit test feature
  79131. * @param _xrSessionManager an instance of WebXRSessionManager
  79132. * @param options options to use when constructing this feature
  79133. */
  79134. constructor(_xrSessionManager: WebXRSessionManager,
  79135. /**
  79136. * options to use when constructing this feature
  79137. */
  79138. options?: IWebXRHitTestOptions);
  79139. /**
  79140. * attach this feature
  79141. * Will usually be called by the features manager
  79142. *
  79143. * @returns true if successful.
  79144. */
  79145. attach(): boolean;
  79146. /**
  79147. * detach this feature.
  79148. * Will usually be called by the features manager
  79149. *
  79150. * @returns true if successful.
  79151. */
  79152. detach(): boolean;
  79153. /**
  79154. * Dispose this feature and all of the resources attached
  79155. */
  79156. dispose(): void;
  79157. protected _onXRFrame(frame: XRFrame): void;
  79158. private _processWebXRHitTestResult;
  79159. }
  79160. }
  79161. declare module BABYLON {
  79162. /**
  79163. * Configuration options of the anchor system
  79164. */
  79165. export interface IWebXRAnchorSystemOptions {
  79166. /**
  79167. * a node that will be used to convert local to world coordinates
  79168. */
  79169. worldParentNode?: TransformNode;
  79170. /**
  79171. * If set to true a reference of the created anchors will be kept until the next session starts
  79172. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79173. */
  79174. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79175. }
  79176. /**
  79177. * A babylon container for an XR Anchor
  79178. */
  79179. export interface IWebXRAnchor {
  79180. /**
  79181. * A babylon-assigned ID for this anchor
  79182. */
  79183. id: number;
  79184. /**
  79185. * Transformation matrix to apply to an object attached to this anchor
  79186. */
  79187. transformationMatrix: Matrix;
  79188. /**
  79189. * The native anchor object
  79190. */
  79191. xrAnchor: XRAnchor;
  79192. /**
  79193. * if defined, this object will be constantly updated by the anchor's position and rotation
  79194. */
  79195. attachedNode?: TransformNode;
  79196. /**
  79197. * Remove this anchor from the scene
  79198. */
  79199. remove(): void;
  79200. }
  79201. /**
  79202. * An implementation of the anchor system for WebXR.
  79203. * For further information see https://github.com/immersive-web/anchors/
  79204. */
  79205. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79206. private _options;
  79207. private _lastFrameDetected;
  79208. private _trackedAnchors;
  79209. private _referenceSpaceForFrameAnchors;
  79210. private _futureAnchors;
  79211. /**
  79212. * The module's name
  79213. */
  79214. static readonly Name: string;
  79215. /**
  79216. * The (Babylon) version of this module.
  79217. * This is an integer representing the implementation version.
  79218. * This number does not correspond to the WebXR specs version
  79219. */
  79220. static readonly Version: number;
  79221. /**
  79222. * Observers registered here will be executed when a new anchor was added to the session
  79223. */
  79224. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79225. /**
  79226. * Observers registered here will be executed when an anchor was removed from the session
  79227. */
  79228. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79229. /**
  79230. * Observers registered here will be executed when an existing anchor updates
  79231. * This can execute N times every frame
  79232. */
  79233. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79234. /**
  79235. * Set the reference space to use for anchor creation, when not using a hit test.
  79236. * Will default to the session's reference space if not defined
  79237. */
  79238. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79239. /**
  79240. * constructs a new anchor system
  79241. * @param _xrSessionManager an instance of WebXRSessionManager
  79242. * @param _options configuration object for this feature
  79243. */
  79244. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79245. private _tmpVector;
  79246. private _tmpQuaternion;
  79247. private _populateTmpTransformation;
  79248. /**
  79249. * Create a new anchor point using a hit test result at a specific point in the scene
  79250. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79251. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79252. *
  79253. * @param hitTestResult The hit test result to use for this anchor creation
  79254. * @param position an optional position offset for this anchor
  79255. * @param rotationQuaternion an optional rotation offset for this anchor
  79256. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79257. */
  79258. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79259. /**
  79260. * Add a new anchor at a specific position and rotation
  79261. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79262. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79263. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79264. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79265. *
  79266. * @param position the position in which to add an anchor
  79267. * @param rotationQuaternion an optional rotation for the anchor transformation
  79268. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79269. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79270. */
  79271. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79272. /**
  79273. * Get the list of anchors currently being tracked by the system
  79274. */
  79275. get anchors(): IWebXRAnchor[];
  79276. /**
  79277. * detach this feature.
  79278. * Will usually be called by the features manager
  79279. *
  79280. * @returns true if successful.
  79281. */
  79282. detach(): boolean;
  79283. /**
  79284. * Dispose this feature and all of the resources attached
  79285. */
  79286. dispose(): void;
  79287. protected _onXRFrame(frame: XRFrame): void;
  79288. /**
  79289. * avoiding using Array.find for global support.
  79290. * @param xrAnchor the plane to find in the array
  79291. */
  79292. private _findIndexInAnchorArray;
  79293. private _updateAnchorWithXRFrame;
  79294. private _createAnchorAtTransformation;
  79295. }
  79296. }
  79297. declare module BABYLON {
  79298. /**
  79299. * Options used in the plane detector module
  79300. */
  79301. export interface IWebXRPlaneDetectorOptions {
  79302. /**
  79303. * The node to use to transform the local results to world coordinates
  79304. */
  79305. worldParentNode?: TransformNode;
  79306. /**
  79307. * If set to true a reference of the created planes will be kept until the next session starts
  79308. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79309. */
  79310. doNotRemovePlanesOnSessionEnded?: boolean;
  79311. /**
  79312. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79313. */
  79314. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79315. }
  79316. /**
  79317. * A babylon interface for a WebXR plane.
  79318. * A Plane is actually a polygon, built from N points in space
  79319. *
  79320. * Supported in chrome 79, not supported in canary 81 ATM
  79321. */
  79322. export interface IWebXRPlane {
  79323. /**
  79324. * a babylon-assigned ID for this polygon
  79325. */
  79326. id: number;
  79327. /**
  79328. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79329. */
  79330. polygonDefinition: Array<Vector3>;
  79331. /**
  79332. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79333. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79334. */
  79335. transformationMatrix: Matrix;
  79336. /**
  79337. * the native xr-plane object
  79338. */
  79339. xrPlane: XRPlane;
  79340. }
  79341. /**
  79342. * The plane detector is used to detect planes in the real world when in AR
  79343. * For more information see https://github.com/immersive-web/real-world-geometry/
  79344. */
  79345. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79346. private _options;
  79347. private _detectedPlanes;
  79348. private _enabled;
  79349. private _lastFrameDetected;
  79350. /**
  79351. * The module's name
  79352. */
  79353. static readonly Name: string;
  79354. /**
  79355. * The (Babylon) version of this module.
  79356. * This is an integer representing the implementation version.
  79357. * This number does not correspond to the WebXR specs version
  79358. */
  79359. static readonly Version: number;
  79360. /**
  79361. * Observers registered here will be executed when a new plane was added to the session
  79362. */
  79363. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79364. /**
  79365. * Observers registered here will be executed when a plane is no longer detected in the session
  79366. */
  79367. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79368. /**
  79369. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79370. * This can execute N times every frame
  79371. */
  79372. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79373. /**
  79374. * construct a new Plane Detector
  79375. * @param _xrSessionManager an instance of xr Session manager
  79376. * @param _options configuration to use when constructing this feature
  79377. */
  79378. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79379. /**
  79380. * detach this feature.
  79381. * Will usually be called by the features manager
  79382. *
  79383. * @returns true if successful.
  79384. */
  79385. detach(): boolean;
  79386. /**
  79387. * Dispose this feature and all of the resources attached
  79388. */
  79389. dispose(): void;
  79390. /**
  79391. * Check if the needed objects are defined.
  79392. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79393. */
  79394. isCompatible(): boolean;
  79395. protected _onXRFrame(frame: XRFrame): void;
  79396. private _init;
  79397. private _updatePlaneWithXRPlane;
  79398. /**
  79399. * avoiding using Array.find for global support.
  79400. * @param xrPlane the plane to find in the array
  79401. */
  79402. private _findIndexInPlaneArray;
  79403. }
  79404. }
  79405. declare module BABYLON {
  79406. /**
  79407. * Options interface for the background remover plugin
  79408. */
  79409. export interface IWebXRBackgroundRemoverOptions {
  79410. /**
  79411. * Further background meshes to disable when entering AR
  79412. */
  79413. backgroundMeshes?: AbstractMesh[];
  79414. /**
  79415. * flags to configure the removal of the environment helper.
  79416. * If not set, the entire background will be removed. If set, flags should be set as well.
  79417. */
  79418. environmentHelperRemovalFlags?: {
  79419. /**
  79420. * Should the skybox be removed (default false)
  79421. */
  79422. skyBox?: boolean;
  79423. /**
  79424. * Should the ground be removed (default false)
  79425. */
  79426. ground?: boolean;
  79427. };
  79428. /**
  79429. * don't disable the environment helper
  79430. */
  79431. ignoreEnvironmentHelper?: boolean;
  79432. }
  79433. /**
  79434. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79435. */
  79436. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79437. /**
  79438. * read-only options to be used in this module
  79439. */
  79440. readonly options: IWebXRBackgroundRemoverOptions;
  79441. /**
  79442. * The module's name
  79443. */
  79444. static readonly Name: string;
  79445. /**
  79446. * The (Babylon) version of this module.
  79447. * This is an integer representing the implementation version.
  79448. * This number does not correspond to the WebXR specs version
  79449. */
  79450. static readonly Version: number;
  79451. /**
  79452. * registered observers will be triggered when the background state changes
  79453. */
  79454. onBackgroundStateChangedObservable: Observable<boolean>;
  79455. /**
  79456. * constructs a new background remover module
  79457. * @param _xrSessionManager the session manager for this module
  79458. * @param options read-only options to be used in this module
  79459. */
  79460. constructor(_xrSessionManager: WebXRSessionManager,
  79461. /**
  79462. * read-only options to be used in this module
  79463. */
  79464. options?: IWebXRBackgroundRemoverOptions);
  79465. /**
  79466. * attach this feature
  79467. * Will usually be called by the features manager
  79468. *
  79469. * @returns true if successful.
  79470. */
  79471. attach(): boolean;
  79472. /**
  79473. * detach this feature.
  79474. * Will usually be called by the features manager
  79475. *
  79476. * @returns true if successful.
  79477. */
  79478. detach(): boolean;
  79479. /**
  79480. * Dispose this feature and all of the resources attached
  79481. */
  79482. dispose(): void;
  79483. protected _onXRFrame(_xrFrame: XRFrame): void;
  79484. private _setBackgroundState;
  79485. }
  79486. }
  79487. declare module BABYLON {
  79488. /**
  79489. * Options for the controller physics feature
  79490. */
  79491. export class IWebXRControllerPhysicsOptions {
  79492. /**
  79493. * Should the headset get its own impostor
  79494. */
  79495. enableHeadsetImpostor?: boolean;
  79496. /**
  79497. * Optional parameters for the headset impostor
  79498. */
  79499. headsetImpostorParams?: {
  79500. /**
  79501. * The type of impostor to create. Default is sphere
  79502. */
  79503. impostorType: number;
  79504. /**
  79505. * the size of the impostor. Defaults to 10cm
  79506. */
  79507. impostorSize?: number | {
  79508. width: number;
  79509. height: number;
  79510. depth: number;
  79511. };
  79512. /**
  79513. * Friction definitions
  79514. */
  79515. friction?: number;
  79516. /**
  79517. * Restitution
  79518. */
  79519. restitution?: number;
  79520. };
  79521. /**
  79522. * The physics properties of the future impostors
  79523. */
  79524. physicsProperties?: {
  79525. /**
  79526. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79527. * Note that this requires a physics engine that supports mesh impostors!
  79528. */
  79529. useControllerMesh?: boolean;
  79530. /**
  79531. * The type of impostor to create. Default is sphere
  79532. */
  79533. impostorType?: number;
  79534. /**
  79535. * the size of the impostor. Defaults to 10cm
  79536. */
  79537. impostorSize?: number | {
  79538. width: number;
  79539. height: number;
  79540. depth: number;
  79541. };
  79542. /**
  79543. * Friction definitions
  79544. */
  79545. friction?: number;
  79546. /**
  79547. * Restitution
  79548. */
  79549. restitution?: number;
  79550. };
  79551. /**
  79552. * the xr input to use with this pointer selection
  79553. */
  79554. xrInput: WebXRInput;
  79555. }
  79556. /**
  79557. * Add physics impostor to your webxr controllers,
  79558. * including naive calculation of their linear and angular velocity
  79559. */
  79560. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79561. private readonly _options;
  79562. private _attachController;
  79563. private _controllers;
  79564. private _debugMode;
  79565. private _delta;
  79566. private _headsetImpostor?;
  79567. private _headsetMesh?;
  79568. private _lastTimestamp;
  79569. private _tmpQuaternion;
  79570. private _tmpVector;
  79571. /**
  79572. * The module's name
  79573. */
  79574. static readonly Name: string;
  79575. /**
  79576. * The (Babylon) version of this module.
  79577. * This is an integer representing the implementation version.
  79578. * This number does not correspond to the webxr specs version
  79579. */
  79580. static readonly Version: number;
  79581. /**
  79582. * Construct a new Controller Physics Feature
  79583. * @param _xrSessionManager the corresponding xr session manager
  79584. * @param _options options to create this feature with
  79585. */
  79586. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79587. /**
  79588. * @hidden
  79589. * enable debugging - will show console outputs and the impostor mesh
  79590. */
  79591. _enablePhysicsDebug(): void;
  79592. /**
  79593. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79594. * @param xrController the controller to add
  79595. */
  79596. addController(xrController: WebXRInputSource): void;
  79597. /**
  79598. * attach this feature
  79599. * Will usually be called by the features manager
  79600. *
  79601. * @returns true if successful.
  79602. */
  79603. attach(): boolean;
  79604. /**
  79605. * detach this feature.
  79606. * Will usually be called by the features manager
  79607. *
  79608. * @returns true if successful.
  79609. */
  79610. detach(): boolean;
  79611. /**
  79612. * Get the headset impostor, if enabled
  79613. * @returns the impostor
  79614. */
  79615. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79616. /**
  79617. * Get the physics impostor of a specific controller.
  79618. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79619. * @param controller the controller or the controller id of which to get the impostor
  79620. * @returns the impostor or null
  79621. */
  79622. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79623. /**
  79624. * Update the physics properties provided in the constructor
  79625. * @param newProperties the new properties object
  79626. */
  79627. setPhysicsProperties(newProperties: {
  79628. impostorType?: number;
  79629. impostorSize?: number | {
  79630. width: number;
  79631. height: number;
  79632. depth: number;
  79633. };
  79634. friction?: number;
  79635. restitution?: number;
  79636. }): void;
  79637. protected _onXRFrame(_xrFrame: any): void;
  79638. private _detachController;
  79639. }
  79640. }
  79641. declare module BABYLON {
  79642. /**
  79643. * A babylon interface for a "WebXR" feature point.
  79644. * Represents the position and confidence value of a given feature point.
  79645. */
  79646. export interface IWebXRFeaturePoint {
  79647. /**
  79648. * Represents the position of the feature point in world space.
  79649. */
  79650. position: Vector3;
  79651. /**
  79652. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79653. */
  79654. confidenceValue: number;
  79655. }
  79656. /**
  79657. * The feature point system is used to detect feature points from real world geometry.
  79658. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79659. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79660. */
  79661. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79662. private _enabled;
  79663. private _featurePointCloud;
  79664. /**
  79665. * The module's name
  79666. */
  79667. static readonly Name: string;
  79668. /**
  79669. * The (Babylon) version of this module.
  79670. * This is an integer representing the implementation version.
  79671. * This number does not correspond to the WebXR specs version
  79672. */
  79673. static readonly Version: number;
  79674. /**
  79675. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79676. * Will notify the observers about which feature points have been added.
  79677. */
  79678. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79679. /**
  79680. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79681. * Will notify the observers about which feature points have been updated.
  79682. */
  79683. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79684. /**
  79685. * The current feature point cloud maintained across frames.
  79686. */
  79687. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79688. /**
  79689. * construct the feature point system
  79690. * @param _xrSessionManager an instance of xr Session manager
  79691. */
  79692. constructor(_xrSessionManager: WebXRSessionManager);
  79693. /**
  79694. * Detach this feature.
  79695. * Will usually be called by the features manager
  79696. *
  79697. * @returns true if successful.
  79698. */
  79699. detach(): boolean;
  79700. /**
  79701. * Dispose this feature and all of the resources attached
  79702. */
  79703. dispose(): void;
  79704. /**
  79705. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79706. */
  79707. protected _onXRFrame(frame: XRFrame): void;
  79708. /**
  79709. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79710. */
  79711. private _init;
  79712. }
  79713. }
  79714. declare module BABYLON {
  79715. /**
  79716. * Configuration interface for the hand tracking feature
  79717. */
  79718. export interface IWebXRHandTrackingOptions {
  79719. /**
  79720. * The xrInput that will be used as source for new hands
  79721. */
  79722. xrInput: WebXRInput;
  79723. /**
  79724. * Configuration object for the joint meshes
  79725. */
  79726. jointMeshes?: {
  79727. /**
  79728. * Should the meshes created be invisible (defaults to false)
  79729. */
  79730. invisible?: boolean;
  79731. /**
  79732. * A source mesh to be used to create instances. Defaults to a sphere.
  79733. * This mesh will be the source for all other (25) meshes.
  79734. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79735. */
  79736. sourceMesh?: Mesh;
  79737. /**
  79738. * This function will be called after a mesh was created for a specific joint.
  79739. * Using this function you can either manipulate the instance or return a new mesh.
  79740. * When returning a new mesh the instance created before will be disposed
  79741. */
  79742. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  79743. /**
  79744. * Should the source mesh stay visible. Defaults to false
  79745. */
  79746. keepOriginalVisible?: boolean;
  79747. /**
  79748. * Scale factor for all instances (defaults to 2)
  79749. */
  79750. scaleFactor?: number;
  79751. /**
  79752. * Should each instance have its own physics impostor
  79753. */
  79754. enablePhysics?: boolean;
  79755. /**
  79756. * If enabled, override default physics properties
  79757. */
  79758. physicsProps?: {
  79759. friction?: number;
  79760. restitution?: number;
  79761. impostorType?: number;
  79762. };
  79763. /**
  79764. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  79765. */
  79766. disableDefaultHandMesh?: boolean;
  79767. /**
  79768. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  79769. */
  79770. handMeshes?: {
  79771. right: AbstractMesh;
  79772. left: AbstractMesh;
  79773. };
  79774. /**
  79775. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  79776. */
  79777. rigMapping?: {
  79778. right: string[];
  79779. left: string[];
  79780. };
  79781. };
  79782. }
  79783. /**
  79784. * Parts of the hands divided to writs and finger names
  79785. */
  79786. export const enum HandPart {
  79787. /**
  79788. * HandPart - Wrist
  79789. */
  79790. WRIST = "wrist",
  79791. /**
  79792. * HandPart - The THumb
  79793. */
  79794. THUMB = "thumb",
  79795. /**
  79796. * HandPart - Index finger
  79797. */
  79798. INDEX = "index",
  79799. /**
  79800. * HandPart - Middle finger
  79801. */
  79802. MIDDLE = "middle",
  79803. /**
  79804. * HandPart - Ring finger
  79805. */
  79806. RING = "ring",
  79807. /**
  79808. * HandPart - Little finger
  79809. */
  79810. LITTLE = "little"
  79811. }
  79812. /**
  79813. * Representing a single hand (with its corresponding native XRHand object)
  79814. */
  79815. export class WebXRHand implements IDisposable {
  79816. /** the controller to which the hand correlates */
  79817. readonly xrController: WebXRInputSource;
  79818. /** the meshes to be used to track the hand joints */
  79819. readonly trackedMeshes: AbstractMesh[];
  79820. private _handMesh?;
  79821. private _rigMapping?;
  79822. private _scene;
  79823. private _defaultHandMesh;
  79824. private _transformNodeMapping;
  79825. /**
  79826. * Hand-parts definition (key is HandPart)
  79827. */
  79828. handPartsDefinition: {
  79829. [key: string]: number[];
  79830. };
  79831. /**
  79832. * Observers will be triggered when the mesh for this hand was initialized.
  79833. */
  79834. onHandMeshReadyObservable: Observable<WebXRHand>;
  79835. /**
  79836. * Populate the HandPartsDefinition object.
  79837. * This is called as a side effect since certain browsers don't have XRHand defined.
  79838. */
  79839. private generateHandPartsDefinition;
  79840. /**
  79841. * Construct a new hand object
  79842. * @param xrController the controller to which the hand correlates
  79843. * @param trackedMeshes the meshes to be used to track the hand joints
  79844. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  79845. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  79846. * @param disableDefaultHandMesh should the default mesh creation be disabled
  79847. */
  79848. constructor(
  79849. /** the controller to which the hand correlates */
  79850. xrController: WebXRInputSource,
  79851. /** the meshes to be used to track the hand joints */
  79852. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  79853. /**
  79854. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  79855. */
  79856. get handMesh(): AbstractMesh | undefined;
  79857. /**
  79858. * Update this hand from the latest xr frame
  79859. * @param xrFrame xrFrame to update from
  79860. * @param referenceSpace The current viewer reference space
  79861. * @param scaleFactor optional scale factor for the meshes
  79862. */
  79863. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79864. /**
  79865. * Get meshes of part of the hand
  79866. * @param part the part of hand to get
  79867. * @returns An array of meshes that correlate to the hand part requested
  79868. */
  79869. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79870. /**
  79871. * Dispose this Hand object
  79872. */
  79873. dispose(): void;
  79874. private _generateDefaultHandMesh;
  79875. }
  79876. /**
  79877. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79878. */
  79879. export class WebXRHandTracking extends WebXRAbstractFeature {
  79880. /**
  79881. * options to use when constructing this feature
  79882. */
  79883. readonly options: IWebXRHandTrackingOptions;
  79884. private static _idCounter;
  79885. /**
  79886. * The module's name
  79887. */
  79888. static readonly Name: string;
  79889. /**
  79890. * The (Babylon) version of this module.
  79891. * This is an integer representing the implementation version.
  79892. * This number does not correspond to the WebXR specs version
  79893. */
  79894. static readonly Version: number;
  79895. /**
  79896. * This observable will notify registered observers when a new hand object was added and initialized
  79897. */
  79898. onHandAddedObservable: Observable<WebXRHand>;
  79899. /**
  79900. * This observable will notify its observers right before the hand object is disposed
  79901. */
  79902. onHandRemovedObservable: Observable<WebXRHand>;
  79903. private _hands;
  79904. /**
  79905. * Creates a new instance of the hit test feature
  79906. * @param _xrSessionManager an instance of WebXRSessionManager
  79907. * @param options options to use when constructing this feature
  79908. */
  79909. constructor(_xrSessionManager: WebXRSessionManager,
  79910. /**
  79911. * options to use when constructing this feature
  79912. */
  79913. options: IWebXRHandTrackingOptions);
  79914. /**
  79915. * Check if the needed objects are defined.
  79916. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79917. */
  79918. isCompatible(): boolean;
  79919. /**
  79920. * attach this feature
  79921. * Will usually be called by the features manager
  79922. *
  79923. * @returns true if successful.
  79924. */
  79925. attach(): boolean;
  79926. /**
  79927. * detach this feature.
  79928. * Will usually be called by the features manager
  79929. *
  79930. * @returns true if successful.
  79931. */
  79932. detach(): boolean;
  79933. /**
  79934. * Dispose this feature and all of the resources attached
  79935. */
  79936. dispose(): void;
  79937. /**
  79938. * Get the hand object according to the controller id
  79939. * @param controllerId the controller id to which we want to get the hand
  79940. * @returns null if not found or the WebXRHand object if found
  79941. */
  79942. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79943. /**
  79944. * Get a hand object according to the requested handedness
  79945. * @param handedness the handedness to request
  79946. * @returns null if not found or the WebXRHand object if found
  79947. */
  79948. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79949. protected _onXRFrame(_xrFrame: XRFrame): void;
  79950. private _attachHand;
  79951. private _detachHand;
  79952. }
  79953. }
  79954. declare module BABYLON {
  79955. /**
  79956. * Options used in the mesh detector module
  79957. */
  79958. export interface IWebXRMeshDetectorOptions {
  79959. /**
  79960. * The node to use to transform the local results to world coordinates
  79961. */
  79962. worldParentNode?: TransformNode;
  79963. /**
  79964. * If set to true a reference of the created meshes will be kept until the next session starts
  79965. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  79966. */
  79967. doNotRemoveMeshesOnSessionEnded?: boolean;
  79968. /**
  79969. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79970. */
  79971. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79972. /**
  79973. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  79974. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  79975. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  79976. */
  79977. convertCoordinateSystems?: boolean;
  79978. }
  79979. /**
  79980. * A babylon interface for a XR mesh's vertex data.
  79981. *
  79982. * Currently not supported by WebXR, available only with BabylonNative
  79983. */
  79984. export interface IWebXRVertexData {
  79985. /**
  79986. * A babylon-assigned ID for this mesh
  79987. */
  79988. id: number;
  79989. /**
  79990. * Data required for constructing a mesh in Babylon.js.
  79991. */
  79992. xrMesh: XRMesh;
  79993. /**
  79994. * The node to use to transform the local results to world coordinates.
  79995. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  79996. */
  79997. worldParentNode?: TransformNode;
  79998. /**
  79999. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80000. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80001. */
  80002. positions?: Float32Array;
  80003. /**
  80004. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  80005. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80006. */
  80007. indices?: Uint32Array;
  80008. /**
  80009. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  80010. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  80011. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  80012. */
  80013. normals?: Float32Array;
  80014. /**
  80015. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80016. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80017. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80018. */
  80019. transformationMatrix?: Matrix;
  80020. }
  80021. /**
  80022. * The mesh detector is used to detect meshes in the real world when in AR
  80023. */
  80024. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80025. private _options;
  80026. private _detectedMeshes;
  80027. /**
  80028. * The module's name
  80029. */
  80030. static readonly Name: string;
  80031. /**
  80032. * The (Babylon) version of this module.
  80033. * This is an integer representing the implementation version.
  80034. * This number does not correspond to the WebXR specs version
  80035. */
  80036. static readonly Version: number;
  80037. /**
  80038. * Observers registered here will be executed when a new mesh was added to the session
  80039. */
  80040. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80041. /**
  80042. * Observers registered here will be executed when a mesh is no longer detected in the session
  80043. */
  80044. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80045. /**
  80046. * Observers registered here will be executed when an existing mesh updates
  80047. */
  80048. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80049. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80050. detach(): boolean;
  80051. dispose(): void;
  80052. protected _onXRFrame(frame: XRFrame): void;
  80053. private _init;
  80054. private _updateVertexDataWithXRMesh;
  80055. }
  80056. }
  80057. declare module BABYLON {
  80058. /**
  80059. * Options interface for the background remover plugin
  80060. */
  80061. export interface IWebXRImageTrackingOptions {
  80062. /**
  80063. * A required array with images to track
  80064. */
  80065. images: {
  80066. /**
  80067. * The source of the image. can be a URL or an image bitmap
  80068. */
  80069. src: string | ImageBitmap;
  80070. /**
  80071. * The estimated width in the real world (in meters)
  80072. */
  80073. estimatedRealWorldWidth: number;
  80074. }[];
  80075. }
  80076. /**
  80077. * An object representing an image tracked by the system
  80078. */
  80079. export interface IWebXRTrackedImage {
  80080. /**
  80081. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80082. */
  80083. id: number;
  80084. /**
  80085. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80086. */
  80087. emulated?: boolean;
  80088. /**
  80089. * Just in case it is needed - the image bitmap that is being tracked
  80090. */
  80091. originalBitmap: ImageBitmap;
  80092. /**
  80093. * The native XR result image tracking result, untouched
  80094. */
  80095. xrTrackingResult?: XRImageTrackingResult;
  80096. /**
  80097. * Width in real world (meters)
  80098. */
  80099. realWorldWidth?: number;
  80100. /**
  80101. * A transformation matrix of this current image in the current reference space.
  80102. */
  80103. transformationMatrix: Matrix;
  80104. /**
  80105. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80106. */
  80107. ratio?: number;
  80108. }
  80109. /**
  80110. * Image tracking for immersive AR sessions.
  80111. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80112. */
  80113. export class WebXRImageTracking extends WebXRAbstractFeature {
  80114. /**
  80115. * read-only options to be used in this module
  80116. */
  80117. readonly options: IWebXRImageTrackingOptions;
  80118. /**
  80119. * The module's name
  80120. */
  80121. static readonly Name: string;
  80122. /**
  80123. * The (Babylon) version of this module.
  80124. * This is an integer representing the implementation version.
  80125. * This number does not correspond to the WebXR specs version
  80126. */
  80127. static readonly Version: number;
  80128. /**
  80129. * This will be triggered if the underlying system deems an image untrackable.
  80130. * The index is the index of the image from the array used to initialize the feature.
  80131. */
  80132. onUntrackableImageFoundObservable: Observable<number>;
  80133. /**
  80134. * An image was deemed trackable, and the system will start tracking it.
  80135. */
  80136. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80137. /**
  80138. * The image was found and its state was updated.
  80139. */
  80140. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80141. private _trackedImages;
  80142. private _originalTrackingRequest;
  80143. /**
  80144. * constructs the image tracking feature
  80145. * @param _xrSessionManager the session manager for this module
  80146. * @param options read-only options to be used in this module
  80147. */
  80148. constructor(_xrSessionManager: WebXRSessionManager,
  80149. /**
  80150. * read-only options to be used in this module
  80151. */
  80152. options: IWebXRImageTrackingOptions);
  80153. /**
  80154. * attach this feature
  80155. * Will usually be called by the features manager
  80156. *
  80157. * @returns true if successful.
  80158. */
  80159. attach(): boolean;
  80160. /**
  80161. * detach this feature.
  80162. * Will usually be called by the features manager
  80163. *
  80164. * @returns true if successful.
  80165. */
  80166. detach(): boolean;
  80167. /**
  80168. * Check if the needed objects are defined.
  80169. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80170. */
  80171. isCompatible(): boolean;
  80172. /**
  80173. * Get a tracked image by its ID.
  80174. *
  80175. * @param id the id of the image to load (position in the init array)
  80176. * @returns a trackable image, if exists in this location
  80177. */
  80178. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80179. /**
  80180. * Dispose this feature and all of the resources attached
  80181. */
  80182. dispose(): void;
  80183. /**
  80184. * Extends the session init object if needed
  80185. * @returns augmentation object fo the xr session init object.
  80186. */
  80187. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80188. protected _onXRFrame(_xrFrame: XRFrame): void;
  80189. private _init;
  80190. }
  80191. }
  80192. declare module BABYLON {
  80193. /**
  80194. * The motion controller class for all microsoft mixed reality controllers
  80195. */
  80196. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80197. protected readonly _mapping: {
  80198. defaultButton: {
  80199. valueNodeName: string;
  80200. unpressedNodeName: string;
  80201. pressedNodeName: string;
  80202. };
  80203. defaultAxis: {
  80204. valueNodeName: string;
  80205. minNodeName: string;
  80206. maxNodeName: string;
  80207. };
  80208. buttons: {
  80209. "xr-standard-trigger": {
  80210. rootNodeName: string;
  80211. componentProperty: string;
  80212. states: string[];
  80213. };
  80214. "xr-standard-squeeze": {
  80215. rootNodeName: string;
  80216. componentProperty: string;
  80217. states: string[];
  80218. };
  80219. "xr-standard-touchpad": {
  80220. rootNodeName: string;
  80221. labelAnchorNodeName: string;
  80222. touchPointNodeName: string;
  80223. };
  80224. "xr-standard-thumbstick": {
  80225. rootNodeName: string;
  80226. componentProperty: string;
  80227. states: string[];
  80228. };
  80229. };
  80230. axes: {
  80231. "xr-standard-touchpad": {
  80232. "x-axis": {
  80233. rootNodeName: string;
  80234. };
  80235. "y-axis": {
  80236. rootNodeName: string;
  80237. };
  80238. };
  80239. "xr-standard-thumbstick": {
  80240. "x-axis": {
  80241. rootNodeName: string;
  80242. };
  80243. "y-axis": {
  80244. rootNodeName: string;
  80245. };
  80246. };
  80247. };
  80248. };
  80249. /**
  80250. * The base url used to load the left and right controller models
  80251. */
  80252. static MODEL_BASE_URL: string;
  80253. /**
  80254. * The name of the left controller model file
  80255. */
  80256. static MODEL_LEFT_FILENAME: string;
  80257. /**
  80258. * The name of the right controller model file
  80259. */
  80260. static MODEL_RIGHT_FILENAME: string;
  80261. profileId: string;
  80262. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80263. protected _getFilenameAndPath(): {
  80264. filename: string;
  80265. path: string;
  80266. };
  80267. protected _getModelLoadingConstraints(): boolean;
  80268. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80269. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80270. protected _updateModel(): void;
  80271. }
  80272. }
  80273. declare module BABYLON {
  80274. /**
  80275. * The motion controller class for oculus touch (quest, rift).
  80276. * This class supports legacy mapping as well the standard xr mapping
  80277. */
  80278. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80279. private _forceLegacyControllers;
  80280. private _modelRootNode;
  80281. /**
  80282. * The base url used to load the left and right controller models
  80283. */
  80284. static MODEL_BASE_URL: string;
  80285. /**
  80286. * The name of the left controller model file
  80287. */
  80288. static MODEL_LEFT_FILENAME: string;
  80289. /**
  80290. * The name of the right controller model file
  80291. */
  80292. static MODEL_RIGHT_FILENAME: string;
  80293. /**
  80294. * Base Url for the Quest controller model.
  80295. */
  80296. static QUEST_MODEL_BASE_URL: string;
  80297. profileId: string;
  80298. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80299. protected _getFilenameAndPath(): {
  80300. filename: string;
  80301. path: string;
  80302. };
  80303. protected _getModelLoadingConstraints(): boolean;
  80304. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80305. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80306. protected _updateModel(): void;
  80307. /**
  80308. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80309. * between the touch and touch 2.
  80310. */
  80311. private _isQuest;
  80312. }
  80313. }
  80314. declare module BABYLON {
  80315. /**
  80316. * The motion controller class for the standard HTC-Vive controllers
  80317. */
  80318. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80319. private _modelRootNode;
  80320. /**
  80321. * The base url used to load the left and right controller models
  80322. */
  80323. static MODEL_BASE_URL: string;
  80324. /**
  80325. * File name for the controller model.
  80326. */
  80327. static MODEL_FILENAME: string;
  80328. profileId: string;
  80329. /**
  80330. * Create a new Vive motion controller object
  80331. * @param scene the scene to use to create this controller
  80332. * @param gamepadObject the corresponding gamepad object
  80333. * @param handedness the handedness of the controller
  80334. */
  80335. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80336. protected _getFilenameAndPath(): {
  80337. filename: string;
  80338. path: string;
  80339. };
  80340. protected _getModelLoadingConstraints(): boolean;
  80341. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80342. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80343. protected _updateModel(): void;
  80344. }
  80345. }
  80346. declare module BABYLON {
  80347. /**
  80348. * A cursor which tracks a point on a path
  80349. */
  80350. export class PathCursor {
  80351. private path;
  80352. /**
  80353. * Stores path cursor callbacks for when an onchange event is triggered
  80354. */
  80355. private _onchange;
  80356. /**
  80357. * The value of the path cursor
  80358. */
  80359. value: number;
  80360. /**
  80361. * The animation array of the path cursor
  80362. */
  80363. animations: Animation[];
  80364. /**
  80365. * Initializes the path cursor
  80366. * @param path The path to track
  80367. */
  80368. constructor(path: Path2);
  80369. /**
  80370. * Gets the cursor point on the path
  80371. * @returns A point on the path cursor at the cursor location
  80372. */
  80373. getPoint(): Vector3;
  80374. /**
  80375. * Moves the cursor ahead by the step amount
  80376. * @param step The amount to move the cursor forward
  80377. * @returns This path cursor
  80378. */
  80379. moveAhead(step?: number): PathCursor;
  80380. /**
  80381. * Moves the cursor behind by the step amount
  80382. * @param step The amount to move the cursor back
  80383. * @returns This path cursor
  80384. */
  80385. moveBack(step?: number): PathCursor;
  80386. /**
  80387. * Moves the cursor by the step amount
  80388. * If the step amount is greater than one, an exception is thrown
  80389. * @param step The amount to move the cursor
  80390. * @returns This path cursor
  80391. */
  80392. move(step: number): PathCursor;
  80393. /**
  80394. * Ensures that the value is limited between zero and one
  80395. * @returns This path cursor
  80396. */
  80397. private ensureLimits;
  80398. /**
  80399. * Runs onchange callbacks on change (used by the animation engine)
  80400. * @returns This path cursor
  80401. */
  80402. private raiseOnChange;
  80403. /**
  80404. * Executes a function on change
  80405. * @param f A path cursor onchange callback
  80406. * @returns This path cursor
  80407. */
  80408. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80409. }
  80410. }
  80411. declare module BABYLON {
  80412. /** @hidden */
  80413. export var blurPixelShader: {
  80414. name: string;
  80415. shader: string;
  80416. };
  80417. }
  80418. declare module BABYLON {
  80419. /** @hidden */
  80420. export var pointCloudVertexDeclaration: {
  80421. name: string;
  80422. shader: string;
  80423. };
  80424. }
  80425. // Mixins
  80426. interface Window {
  80427. mozIndexedDB: IDBFactory;
  80428. webkitIndexedDB: IDBFactory;
  80429. msIndexedDB: IDBFactory;
  80430. webkitURL: typeof URL;
  80431. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80432. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80433. WebGLRenderingContext: WebGLRenderingContext;
  80434. MSGesture: MSGesture;
  80435. CANNON: any;
  80436. AudioContext: AudioContext;
  80437. webkitAudioContext: AudioContext;
  80438. PointerEvent: any;
  80439. Math: Math;
  80440. Uint8Array: Uint8ArrayConstructor;
  80441. Float32Array: Float32ArrayConstructor;
  80442. mozURL: typeof URL;
  80443. msURL: typeof URL;
  80444. VRFrameData: any; // WebVR, from specs 1.1
  80445. DracoDecoderModule: any;
  80446. setImmediate(handler: (...args: any[]) => void): number;
  80447. }
  80448. interface HTMLCanvasElement {
  80449. requestPointerLock(): void;
  80450. msRequestPointerLock?(): void;
  80451. mozRequestPointerLock?(): void;
  80452. webkitRequestPointerLock?(): void;
  80453. /** Track wether a record is in progress */
  80454. isRecording: boolean;
  80455. /** Capture Stream method defined by some browsers */
  80456. captureStream(fps?: number): MediaStream;
  80457. }
  80458. interface CanvasRenderingContext2D {
  80459. msImageSmoothingEnabled: boolean;
  80460. }
  80461. interface MouseEvent {
  80462. mozMovementX: number;
  80463. mozMovementY: number;
  80464. webkitMovementX: number;
  80465. webkitMovementY: number;
  80466. msMovementX: number;
  80467. msMovementY: number;
  80468. }
  80469. interface Navigator {
  80470. mozGetVRDevices: (any: any) => any;
  80471. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80472. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80473. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80474. webkitGetGamepads(): Gamepad[];
  80475. msGetGamepads(): Gamepad[];
  80476. webkitGamepads(): Gamepad[];
  80477. }
  80478. interface HTMLVideoElement {
  80479. mozSrcObject: any;
  80480. }
  80481. interface Math {
  80482. fround(x: number): number;
  80483. imul(a: number, b: number): number;
  80484. log2(x: number): number;
  80485. }
  80486. interface WebGLRenderingContext {
  80487. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80488. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80489. vertexAttribDivisor(index: number, divisor: number): void;
  80490. createVertexArray(): any;
  80491. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80492. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80493. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80494. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80495. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80496. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80497. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80498. // Queries
  80499. createQuery(): WebGLQuery;
  80500. deleteQuery(query: WebGLQuery): void;
  80501. beginQuery(target: number, query: WebGLQuery): void;
  80502. endQuery(target: number): void;
  80503. getQueryParameter(query: WebGLQuery, pname: number): any;
  80504. getQuery(target: number, pname: number): any;
  80505. MAX_SAMPLES: number;
  80506. RGBA8: number;
  80507. READ_FRAMEBUFFER: number;
  80508. DRAW_FRAMEBUFFER: number;
  80509. UNIFORM_BUFFER: number;
  80510. HALF_FLOAT_OES: number;
  80511. RGBA16F: number;
  80512. RGBA32F: number;
  80513. R32F: number;
  80514. RG32F: number;
  80515. RGB32F: number;
  80516. R16F: number;
  80517. RG16F: number;
  80518. RGB16F: number;
  80519. RED: number;
  80520. RG: number;
  80521. R8: number;
  80522. RG8: number;
  80523. UNSIGNED_INT_24_8: number;
  80524. DEPTH24_STENCIL8: number;
  80525. MIN: number;
  80526. MAX: number;
  80527. /* Multiple Render Targets */
  80528. drawBuffers(buffers: number[]): void;
  80529. readBuffer(src: number): void;
  80530. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80531. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80532. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80533. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80534. // Occlusion Query
  80535. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80536. ANY_SAMPLES_PASSED: number;
  80537. QUERY_RESULT_AVAILABLE: number;
  80538. QUERY_RESULT: number;
  80539. }
  80540. interface WebGLProgram {
  80541. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80542. }
  80543. interface EXT_disjoint_timer_query {
  80544. QUERY_COUNTER_BITS_EXT: number;
  80545. TIME_ELAPSED_EXT: number;
  80546. TIMESTAMP_EXT: number;
  80547. GPU_DISJOINT_EXT: number;
  80548. QUERY_RESULT_EXT: number;
  80549. QUERY_RESULT_AVAILABLE_EXT: number;
  80550. queryCounterEXT(query: WebGLQuery, target: number): void;
  80551. createQueryEXT(): WebGLQuery;
  80552. beginQueryEXT(target: number, query: WebGLQuery): void;
  80553. endQueryEXT(target: number): void;
  80554. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80555. deleteQueryEXT(query: WebGLQuery): void;
  80556. }
  80557. interface WebGLUniformLocation {
  80558. _currentState: any;
  80559. }
  80560. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80561. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80562. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80563. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80564. interface WebGLRenderingContext {
  80565. readonly RASTERIZER_DISCARD: number;
  80566. readonly DEPTH_COMPONENT24: number;
  80567. readonly TEXTURE_3D: number;
  80568. readonly TEXTURE_2D_ARRAY: number;
  80569. readonly TEXTURE_COMPARE_FUNC: number;
  80570. readonly TEXTURE_COMPARE_MODE: number;
  80571. readonly COMPARE_REF_TO_TEXTURE: number;
  80572. readonly TEXTURE_WRAP_R: number;
  80573. readonly HALF_FLOAT: number;
  80574. readonly RGB8: number;
  80575. readonly RED_INTEGER: number;
  80576. readonly RG_INTEGER: number;
  80577. readonly RGB_INTEGER: number;
  80578. readonly RGBA_INTEGER: number;
  80579. readonly R8_SNORM: number;
  80580. readonly RG8_SNORM: number;
  80581. readonly RGB8_SNORM: number;
  80582. readonly RGBA8_SNORM: number;
  80583. readonly R8I: number;
  80584. readonly RG8I: number;
  80585. readonly RGB8I: number;
  80586. readonly RGBA8I: number;
  80587. readonly R8UI: number;
  80588. readonly RG8UI: number;
  80589. readonly RGB8UI: number;
  80590. readonly RGBA8UI: number;
  80591. readonly R16I: number;
  80592. readonly RG16I: number;
  80593. readonly RGB16I: number;
  80594. readonly RGBA16I: number;
  80595. readonly R16UI: number;
  80596. readonly RG16UI: number;
  80597. readonly RGB16UI: number;
  80598. readonly RGBA16UI: number;
  80599. readonly R32I: number;
  80600. readonly RG32I: number;
  80601. readonly RGB32I: number;
  80602. readonly RGBA32I: number;
  80603. readonly R32UI: number;
  80604. readonly RG32UI: number;
  80605. readonly RGB32UI: number;
  80606. readonly RGBA32UI: number;
  80607. readonly RGB10_A2UI: number;
  80608. readonly R11F_G11F_B10F: number;
  80609. readonly RGB9_E5: number;
  80610. readonly RGB10_A2: number;
  80611. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80612. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80613. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80614. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80615. readonly DEPTH_COMPONENT32F: number;
  80616. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80617. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80618. 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;
  80619. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80620. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80621. readonly TRANSFORM_FEEDBACK: number;
  80622. readonly INTERLEAVED_ATTRIBS: number;
  80623. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80624. createTransformFeedback(): WebGLTransformFeedback;
  80625. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80626. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80627. beginTransformFeedback(primitiveMode: number): void;
  80628. endTransformFeedback(): void;
  80629. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80630. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80631. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80632. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80633. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80634. }
  80635. interface ImageBitmap {
  80636. readonly width: number;
  80637. readonly height: number;
  80638. close(): void;
  80639. }
  80640. interface WebGLQuery extends WebGLObject {
  80641. }
  80642. declare var WebGLQuery: {
  80643. prototype: WebGLQuery;
  80644. new(): WebGLQuery;
  80645. };
  80646. interface WebGLSampler extends WebGLObject {
  80647. }
  80648. declare var WebGLSampler: {
  80649. prototype: WebGLSampler;
  80650. new(): WebGLSampler;
  80651. };
  80652. interface WebGLSync extends WebGLObject {
  80653. }
  80654. declare var WebGLSync: {
  80655. prototype: WebGLSync;
  80656. new(): WebGLSync;
  80657. };
  80658. interface WebGLTransformFeedback extends WebGLObject {
  80659. }
  80660. declare var WebGLTransformFeedback: {
  80661. prototype: WebGLTransformFeedback;
  80662. new(): WebGLTransformFeedback;
  80663. };
  80664. interface WebGLVertexArrayObject extends WebGLObject {
  80665. }
  80666. declare var WebGLVertexArrayObject: {
  80667. prototype: WebGLVertexArrayObject;
  80668. new(): WebGLVertexArrayObject;
  80669. };
  80670. interface Navigator {
  80671. readonly gpu: GPU | undefined;
  80672. }
  80673. interface GPUColorDict {
  80674. a: number;
  80675. b: number;
  80676. g: number;
  80677. r: number;
  80678. }
  80679. type GPUColor = [number, number, number, number] | GPUColorDict;
  80680. interface GPUOrigin2DDict {
  80681. x?: number;
  80682. y?: number;
  80683. }
  80684. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80685. interface GPUOrigin3DDict {
  80686. x?: number;
  80687. y?: number;
  80688. z?: number;
  80689. }
  80690. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80691. interface GPUExtent3DDict {
  80692. width: number;
  80693. height: number;
  80694. depth: number;
  80695. }
  80696. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80697. type GPUBindingResource =
  80698. | GPUSampler
  80699. | GPUTextureView
  80700. | GPUBufferBinding;
  80701. type GPUExtensionName =
  80702. | "texture-compression-bc"
  80703. | "timestamp-query"
  80704. | "pipeline-statistics-query"
  80705. | "depth-clamping"
  80706. | "depth24unorm-stencil8"
  80707. | "depth32float-stencil8";
  80708. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  80709. type GPUBindingType =
  80710. | "uniform-buffer"
  80711. | "storage-buffer"
  80712. | "readonly-storage-buffer"
  80713. | "sampler"
  80714. | "comparison-sampler"
  80715. | "sampled-texture"
  80716. | "readonly-storage-texture"
  80717. | "writeonly-storage-texture";
  80718. type GPUBlendFactor =
  80719. | "zero"
  80720. | "one"
  80721. | "src-color"
  80722. | "one-minus-src-color"
  80723. | "src-alpha"
  80724. | "one-minus-src-alpha"
  80725. | "dst-color"
  80726. | "one-minus-dst-color"
  80727. | "dst-alpha"
  80728. | "one-minus-dst-alpha"
  80729. | "src-alpha-saturated"
  80730. | "blend-color"
  80731. | "one-minus-blend-color";
  80732. type GPUBlendOperation =
  80733. | "add"
  80734. | "subtract"
  80735. | "reverse-subtract"
  80736. | "min"
  80737. | "max";
  80738. type GPUCompareFunction =
  80739. | "never"
  80740. | "less"
  80741. | "equal"
  80742. | "less-equal"
  80743. | "greater"
  80744. | "not-equal"
  80745. | "greater-equal"
  80746. | "always";
  80747. type GPUCullMode = "none" | "front" | "back";
  80748. type GPUFilterMode = "nearest" | "linear";
  80749. type GPUFrontFace = "ccw" | "cw";
  80750. type GPUIndexFormat = "uint16" | "uint32";
  80751. type GPUInputStepMode = "vertex" | "instance";
  80752. type GPULoadOp = "load";
  80753. type GPUPrimitiveTopology =
  80754. | "point-list"
  80755. | "line-list"
  80756. | "line-strip"
  80757. | "triangle-list"
  80758. | "triangle-strip";
  80759. type GPUStencilOperation =
  80760. | "keep"
  80761. | "zero"
  80762. | "replace"
  80763. | "invert"
  80764. | "increment-clamp"
  80765. | "decrement-clamp"
  80766. | "increment-wrap"
  80767. | "decrement-wrap";
  80768. type GPUStoreOp = "store" | "clear";
  80769. type GPUTextureDimension = "1d" | "2d" | "3d";
  80770. type GPUTextureFormat =
  80771. | "r8unorm"
  80772. | "r8snorm"
  80773. | "r8uint"
  80774. | "r8sint"
  80775. | "r16uint"
  80776. | "r16sint"
  80777. | "r16float"
  80778. | "rg8unorm"
  80779. | "rg8snorm"
  80780. | "rg8uint"
  80781. | "rg8sint"
  80782. | "r32uint"
  80783. | "r32sint"
  80784. | "r32float"
  80785. | "rg16uint"
  80786. | "rg16sint"
  80787. | "rg16float"
  80788. | "rgba8unorm"
  80789. | "rgba8unorm-srgb"
  80790. | "rgba8snorm"
  80791. | "rgba8uint"
  80792. | "rgba8sint"
  80793. | "bgra8unorm"
  80794. | "bgra8unorm-srgb"
  80795. | "rgb9e5ufloat"
  80796. | "rgb10a2unorm"
  80797. | "rg11b10ufloat"
  80798. | "rg32uint"
  80799. | "rg32sint"
  80800. | "rg32float"
  80801. | "rgba16uint"
  80802. | "rgba16sint"
  80803. | "rgba16float"
  80804. | "rgba32uint"
  80805. | "rgba32sint"
  80806. | "rgba32float"
  80807. | "stencil8"
  80808. | "depth16unorm"
  80809. | "depth24plus"
  80810. | "depth24plus-stencil8"
  80811. | "depth32float"
  80812. | "bc1-rgba-unorm"
  80813. | "bc1-rgba-unorm-srgb"
  80814. | "bc2-rgba-unorm"
  80815. | "bc2-rgba-unorm-srgb"
  80816. | "bc3-rgba-unorm"
  80817. | "bc3-rgba-unorm-srgb"
  80818. | "bc4-r-unorm"
  80819. | "bc4-r-snorm"
  80820. | "bc5-rg-unorm"
  80821. | "bc5-rg-snorm"
  80822. | "bc6h-rgb-ufloat"
  80823. | "bc6h-rgb-float"
  80824. | "bc7-rgba-unorm"
  80825. | "bc7-rgba-unorm-srgb"
  80826. | "depth24unorm-stencil8"
  80827. | "depth32float-stencil8";
  80828. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  80829. type GPUTextureViewDimension =
  80830. | "1d"
  80831. | "2d"
  80832. | "2d-array"
  80833. | "cube"
  80834. | "cube-array"
  80835. | "3d";
  80836. type GPUVertexFormat =
  80837. | "uchar2"
  80838. | "uchar4"
  80839. | "char2"
  80840. | "char4"
  80841. | "uchar2norm"
  80842. | "uchar4norm"
  80843. | "char2norm"
  80844. | "char4norm"
  80845. | "ushort2"
  80846. | "ushort4"
  80847. | "short2"
  80848. | "short4"
  80849. | "ushort2norm"
  80850. | "ushort4norm"
  80851. | "short2norm"
  80852. | "short4norm"
  80853. | "half2"
  80854. | "half4"
  80855. | "float"
  80856. | "float2"
  80857. | "float3"
  80858. | "float4"
  80859. | "uint"
  80860. | "uint2"
  80861. | "uint3"
  80862. | "uint4"
  80863. | "int"
  80864. | "int2"
  80865. | "int3"
  80866. | "int4";
  80867. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  80868. type GPUBufferUsageFlags = number;
  80869. type GPUColorWriteFlags = number;
  80870. type GPUShaderStageFlags = number;
  80871. type GPUTextureUsageFlags = number;
  80872. type GPUMapModeFlags = number;
  80873. interface GPUBindGroupEntry {
  80874. binding: number;
  80875. resource: GPUBindingResource;
  80876. }
  80877. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  80878. layout: GPUBindGroupLayout;
  80879. entries: Iterable<GPUBindGroupEntry>;
  80880. }
  80881. interface GPUBindGroupLayoutEntry {
  80882. binding: number;
  80883. visibility: GPUShaderStageFlags;
  80884. type: GPUBindingType;
  80885. hasDynamicOffset?: boolean;
  80886. minBufferBindingSize?: number;
  80887. viewDimension?: GPUTextureViewDimension;
  80888. textureComponentType?: GPUTextureComponentType;
  80889. storageTextureFormat?: GPUTextureFormat;
  80890. }
  80891. interface GPUBindGroupLayoutDescriptor
  80892. extends GPUObjectDescriptorBase {
  80893. entries: Iterable<GPUBindGroupLayoutEntry>;
  80894. }
  80895. interface GPUBlendDescriptor {
  80896. dstFactor?: GPUBlendFactor;
  80897. operation?: GPUBlendOperation;
  80898. srcFactor?: GPUBlendFactor;
  80899. }
  80900. interface GPUColorStateDescriptor {
  80901. format: GPUTextureFormat;
  80902. alphaBlend?: GPUBlendDescriptor;
  80903. colorBlend?: GPUBlendDescriptor;
  80904. writeMask?: GPUColorWriteFlags;
  80905. }
  80906. interface GPUBufferBinding {
  80907. buffer: GPUBuffer;
  80908. offset?: number;
  80909. size?: number;
  80910. }
  80911. interface GPUTextureDataLayout {
  80912. offset?: number;
  80913. bytesPerRow: number;
  80914. rowsPerImage?: number;
  80915. }
  80916. interface GPUBufferCopyView extends GPUTextureDataLayout {
  80917. buffer: GPUBuffer;
  80918. }
  80919. interface GPUTextureCopyView {
  80920. texture: GPUTexture;
  80921. mipLevel?: number;
  80922. origin?: GPUOrigin3D;
  80923. }
  80924. interface GPUImageBitmapCopyView {
  80925. imageBitmap: ImageBitmap;
  80926. origin?: GPUOrigin2D;
  80927. }
  80928. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  80929. size: number;
  80930. usage: GPUBufferUsageFlags;
  80931. mappedAtCreation?: boolean;
  80932. }
  80933. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  80934. label?: string;
  80935. measureExecutionTime?: boolean;
  80936. }
  80937. interface GPUComputePipelineDescriptor
  80938. extends GPUPipelineDescriptorBase {
  80939. computeStage: GPUProgrammableStageDescriptor;
  80940. }
  80941. interface GPUDepthStencilStateDescriptor {
  80942. format: GPUTextureFormat;
  80943. depthWriteEnabled?: boolean;
  80944. depthCompare?: GPUCompareFunction;
  80945. stencilFront?: GPUStencilStateFaceDescriptor;
  80946. stencilBack?: GPUStencilStateFaceDescriptor;
  80947. stencilReadMask?: number;
  80948. stencilWriteMask?: number;
  80949. }
  80950. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  80951. extensions?: Iterable<GPUExtensionName>;
  80952. limits?: GPULimits;
  80953. }
  80954. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  80955. initialValue?: number;
  80956. label?: string;
  80957. signalQueue?: GPUQueue;
  80958. }
  80959. interface GPUVertexAttributeDescriptor {
  80960. format: GPUVertexFormat;
  80961. offset: number;
  80962. shaderLocation: number;
  80963. }
  80964. interface GPUVertexBufferLayoutDescriptor {
  80965. arrayStride: number;
  80966. stepMode?: GPUInputStepMode;
  80967. attributes: Iterable<GPUVertexAttributeDescriptor>;
  80968. }
  80969. interface GPUVertexStateDescriptor {
  80970. indexFormat?: GPUIndexFormat;
  80971. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  80972. }
  80973. interface GPULimits {
  80974. maxBindGroups?: number;
  80975. maxDynamicUniformBuffersPerPipelineLayout?: number;
  80976. maxDynamicStorageBuffersPerPipelineLayout?: number;
  80977. maxSampledTexturesPerShaderStage?: number;
  80978. maxSamplersPerShaderStage?: number;
  80979. maxStorageBuffersPerShaderStage?: number;
  80980. maxStorageTexturesPerShaderStage?: number;
  80981. maxUniformBuffersPerShaderStage?: number;
  80982. maxUniformBufferBindingSize?: number;
  80983. }
  80984. interface GPUPipelineDescriptorBase {
  80985. label?: string;
  80986. layout?: GPUPipelineLayout;
  80987. }
  80988. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  80989. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  80990. }
  80991. interface GPUProgrammableStageDescriptor {
  80992. module: GPUShaderModule;
  80993. entryPoint: string;
  80994. }
  80995. interface GPURasterizationStateDescriptor {
  80996. frontFace?: GPUFrontFace;
  80997. cullMode?: GPUCullMode;
  80998. clampDepth?: boolean;
  80999. depthBias?: number;
  81000. depthBiasSlopeScale?: number;
  81001. depthBiasClamp?: number;
  81002. }
  81003. interface GPURenderPassColorAttachmentDescriptor {
  81004. attachment: GPUTextureView;
  81005. resolveTarget?: GPUTextureView;
  81006. loadValue: GPULoadOp | GPUColor;
  81007. storeOp?: GPUStoreOp;
  81008. }
  81009. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81010. attachment: GPUTextureView;
  81011. depthLoadValue: GPULoadOp | number;
  81012. depthStoreOp: GPUStoreOp;
  81013. depthReadOnly?: boolean;
  81014. stencilLoadValue: GPULoadOp | number;
  81015. stencilStoreOp: GPUStoreOp;
  81016. stencilReadOnly?: boolean;
  81017. }
  81018. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81019. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81020. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81021. }
  81022. interface GPURenderPipelineDescriptor
  81023. extends GPUPipelineDescriptorBase {
  81024. vertexStage: GPUProgrammableStageDescriptor;
  81025. fragmentStage?: GPUProgrammableStageDescriptor;
  81026. primitiveTopology: GPUPrimitiveTopology;
  81027. rasterizationState?: GPURasterizationStateDescriptor;
  81028. colorStates: Iterable<GPUColorStateDescriptor>;
  81029. depthStencilState?: GPUDepthStencilStateDescriptor;
  81030. vertexState?: GPUVertexStateDescriptor;
  81031. sampleCount?: number;
  81032. sampleMask?: number;
  81033. alphaToCoverageEnabled?: boolean;
  81034. }
  81035. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81036. addressModeU?: GPUAddressMode;
  81037. addressModeV?: GPUAddressMode;
  81038. addressModeW?: GPUAddressMode;
  81039. magFilter?: GPUFilterMode;
  81040. minFilter?: GPUFilterMode;
  81041. mipmapFilter?: GPUFilterMode;
  81042. lodMinClamp?: number;
  81043. lodMaxClamp?: number;
  81044. compare?: GPUCompareFunction;
  81045. maxAnisotropy?: number;
  81046. }
  81047. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81048. code: Uint32Array | string;
  81049. label?: string;
  81050. sourceMap?: object;
  81051. }
  81052. interface GPUStencilStateFaceDescriptor {
  81053. compare?: GPUCompareFunction;
  81054. depthFailOp?: GPUStencilOperation;
  81055. passOp?: GPUStencilOperation;
  81056. failOp?: GPUStencilOperation;
  81057. }
  81058. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81059. device: GPUDevice;
  81060. format: GPUTextureFormat;
  81061. usage?: GPUTextureUsageFlags;
  81062. }
  81063. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81064. size: GPUExtent3D;
  81065. mipLevelCount?: number;
  81066. sampleCount?: number;
  81067. dimension?: GPUTextureDimension;
  81068. format: GPUTextureFormat;
  81069. usage: GPUTextureUsageFlags;
  81070. }
  81071. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81072. format?: GPUTextureFormat;
  81073. dimension?: GPUTextureViewDimension;
  81074. aspect?: GPUTextureAspect;
  81075. baseArrayLayer?: number;
  81076. baseMipLevel?: number;
  81077. arrayLayerCount?: number;
  81078. mipLevelCount?: number;
  81079. }
  81080. declare class GPUAdapter {
  81081. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81082. private __brand: void;
  81083. readonly name: string;
  81084. readonly extensions: GPUExtensionName[];
  81085. readonly limits: Required<GPULimits>;
  81086. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81087. }
  81088. declare class GPUBindGroup implements GPUObjectBase {
  81089. private __brand: void;
  81090. label: string | undefined;
  81091. }
  81092. declare class GPUBindGroupLayout implements GPUObjectBase {
  81093. private __brand: void;
  81094. label: string | undefined;
  81095. }
  81096. declare class GPUBuffer implements GPUObjectBase {
  81097. private __brand: void;
  81098. label: string | undefined;
  81099. destroy(): void;
  81100. unmap(): void;
  81101. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81102. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81103. }
  81104. declare class GPUCommandBuffer implements GPUObjectBase {
  81105. private __brand: void;
  81106. label: string | undefined;
  81107. readonly executionTime: Promise<number>;
  81108. }
  81109. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81110. declare class GPUCommandEncoder implements GPUObjectBase {
  81111. private __brand: void;
  81112. label: string | undefined;
  81113. beginComputePass(
  81114. descriptor?: GPUComputePassDescriptor
  81115. ): GPUComputePassEncoder;
  81116. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81117. copyBufferToBuffer(
  81118. source: GPUBuffer,
  81119. sourceOffset: number,
  81120. destination: GPUBuffer,
  81121. destinationOffset: number,
  81122. size: number
  81123. ): void;
  81124. copyBufferToTexture(
  81125. source: GPUBufferCopyView,
  81126. destination: GPUTextureCopyView,
  81127. copySize: GPUExtent3D
  81128. ): void;
  81129. copyTextureToBuffer(
  81130. source: GPUTextureCopyView,
  81131. destination: GPUBufferCopyView,
  81132. copySize: GPUExtent3D
  81133. ): void;
  81134. copyTextureToTexture(
  81135. source: GPUTextureCopyView,
  81136. destination: GPUTextureCopyView,
  81137. copySize: GPUExtent3D
  81138. ): void;
  81139. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81140. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81141. popDebugGroup(): void;
  81142. pushDebugGroup(groupLabel: string): void;
  81143. insertDebugMarker(markerLabel: string): void;
  81144. }
  81145. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81146. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81147. private __brand: void;
  81148. label: string | undefined;
  81149. setBindGroup(
  81150. index: number,
  81151. bindGroup: GPUBindGroup,
  81152. dynamicOffsets?: Iterable<number>
  81153. ): void;
  81154. popDebugGroup(): void;
  81155. pushDebugGroup(groupLabel: string): void;
  81156. insertDebugMarker(markerLabel: string): void;
  81157. setPipeline(pipeline: GPUComputePipeline): void;
  81158. dispatch(x: number, y?: number, z?: number): void;
  81159. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81160. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81161. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81162. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81163. endPass(): void;
  81164. }
  81165. declare class GPUComputePipeline implements GPUPipelineBase {
  81166. private __brand: void;
  81167. label: string | undefined;
  81168. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81169. }
  81170. interface GPUObjectBase {
  81171. label: string | undefined;
  81172. }
  81173. interface GPUObjectDescriptorBase {
  81174. label?: string;
  81175. }
  81176. // SwapChain / CanvasContext
  81177. declare class GPUCanvasContext {
  81178. private __brand: void;
  81179. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81180. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81181. }
  81182. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81183. private __brand: void;
  81184. label: string | undefined;
  81185. readonly adapter: GPUAdapter;
  81186. readonly extensions: GPUExtensionName[];
  81187. readonly limits: Required<GPULimits>;
  81188. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81189. createBindGroupLayout(
  81190. descriptor: GPUBindGroupLayoutDescriptor
  81191. ): GPUBindGroupLayout;
  81192. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81193. createPipelineLayout(
  81194. descriptor: GPUPipelineLayoutDescriptor
  81195. ): GPUPipelineLayout;
  81196. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81197. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81198. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81199. createComputePipeline(
  81200. descriptor: GPUComputePipelineDescriptor
  81201. ): GPUComputePipeline;
  81202. createRenderPipeline(
  81203. descriptor: GPURenderPipelineDescriptor
  81204. ): GPURenderPipeline;
  81205. createReadyComputePipeline(
  81206. descriptor: GPUComputePipelineDescriptor
  81207. ): Promise<GPUComputePipeline>;
  81208. createReadyRenderPipeline(
  81209. descriptor: GPURenderPipelineDescriptor
  81210. ): Promise<GPURenderPipeline>;
  81211. createCommandEncoder(
  81212. descriptor?: GPUCommandEncoderDescriptor
  81213. ): GPUCommandEncoder;
  81214. createRenderBundleEncoder(
  81215. descriptor: GPURenderBundleEncoderDescriptor
  81216. ): GPURenderBundleEncoder;
  81217. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81218. defaultQueue: GPUQueue;
  81219. pushErrorScope(filter: GPUErrorFilter): void;
  81220. popErrorScope(): Promise<GPUError | null>;
  81221. onuncapturederror: Event | undefined;
  81222. readonly lost: Promise<GPUDeviceLostInfo>;
  81223. }
  81224. declare class GPUFence implements GPUObjectBase {
  81225. private __brand: void;
  81226. label: string | undefined;
  81227. getCompletedValue(): number;
  81228. onCompletion(completionValue: number): Promise<void>;
  81229. }
  81230. interface GPUPipelineBase extends GPUObjectBase {
  81231. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81232. }
  81233. declare class GPUPipelineLayout implements GPUObjectBase {
  81234. private __brand: void;
  81235. label: string | undefined;
  81236. }
  81237. interface GPUProgrammablePassEncoder {
  81238. setBindGroup(
  81239. index: number,
  81240. bindGroup: GPUBindGroup,
  81241. dynamicOffsets?: Iterable<number>
  81242. ): void;
  81243. popDebugGroup(): void;
  81244. pushDebugGroup(groupLabel: string): void;
  81245. insertDebugMarker(markerLabel: string): void;
  81246. }
  81247. declare class GPUQueue implements GPUObjectBase {
  81248. private __brand: void;
  81249. label: string | undefined;
  81250. signal(fence: GPUFence, signalValue: number): void;
  81251. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81252. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81253. writeBuffer(buffer: GPUBuffer,
  81254. bufferOffset: number,
  81255. data: BufferSource | ArrayBuffer,
  81256. dataOffset?: number,
  81257. size?: number): void;
  81258. writeTexture(destination: GPUTextureCopyView,
  81259. data: BufferSource | ArrayBuffer,
  81260. dataLayout: GPUTextureDataLayout,
  81261. size: GPUExtent3D): void;
  81262. copyImageBitmapToTexture(
  81263. source: GPUImageBitmapCopyView,
  81264. destination: GPUTextureCopyView,
  81265. copySize: GPUExtent3D
  81266. ): void;
  81267. }
  81268. type GPUQueryType =
  81269. | "occlusion"
  81270. | "timestamp"
  81271. | "pipeline-statistics";
  81272. type GPUPipelineStatisticName =
  81273. | "vertex-shader-invocations"
  81274. | "clipper-invocations"
  81275. | "clipper-primitives-out"
  81276. | "fragment-shader-invocations"
  81277. | "compute-shader-invocations";
  81278. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81279. type: GPUQueryType;
  81280. count: number;
  81281. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81282. }
  81283. declare class GPUQuerySet implements GPUObjectBase {
  81284. private __brand: void;
  81285. label: string | undefined;
  81286. destroy(): void;
  81287. }
  81288. interface GPURenderEncoderBase {
  81289. setPipeline(pipeline: GPURenderPipeline): void;
  81290. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81291. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81292. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81293. draw(
  81294. vertexCount: number,
  81295. instanceCount?: number,
  81296. firstVertex?: number,
  81297. firstInstance?: number
  81298. ): void;
  81299. drawIndexed(
  81300. indexCount: number,
  81301. instanceCount?: number,
  81302. firstIndex?: number,
  81303. baseVertex?: number,
  81304. firstInstance?: number
  81305. ): void;
  81306. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81307. drawIndexedIndirect(
  81308. indirectBuffer: GPUBuffer,
  81309. indirectOffset: number
  81310. ): void;
  81311. }
  81312. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81313. private __brand: void;
  81314. label: string | undefined;
  81315. setBindGroup(
  81316. index: number,
  81317. bindGroup: GPUBindGroup,
  81318. dynamicOffsets?: Iterable<number>
  81319. ): void;
  81320. popDebugGroup(): void;
  81321. pushDebugGroup(groupLabel: string): void;
  81322. insertDebugMarker(markerLabel: string): void;
  81323. setPipeline(pipeline: GPURenderPipeline): void;
  81324. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81325. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81326. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81327. draw(
  81328. vertexCount: number,
  81329. instanceCount?: number,
  81330. firstVertex?: number,
  81331. firstInstance?: number
  81332. ): void;
  81333. drawIndexed(
  81334. indexCount: number,
  81335. instanceCount?: number,
  81336. firstIndex?: number,
  81337. baseVertex?: number,
  81338. firstInstance?: number
  81339. ): void;
  81340. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81341. drawIndexedIndirect(
  81342. indirectBuffer: GPUBuffer,
  81343. indirectOffset: number
  81344. ): void;
  81345. setViewport(
  81346. x: number,
  81347. y: number,
  81348. width: number,
  81349. height: number,
  81350. minDepth: number,
  81351. maxDepth: number
  81352. ): void;
  81353. setScissorRect(x: number, y: number, width: number, height: number): void;
  81354. setBlendColor(color: GPUColor): void;
  81355. setStencilReference(reference: number): void;
  81356. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81357. beginOcclusionQuery(queryIndex: number): void;
  81358. endOcclusionQuery(): void;
  81359. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81360. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81361. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81362. endPass(): void;
  81363. }
  81364. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81365. declare class GPURenderBundle implements GPUObjectBase {
  81366. private __brand: void;
  81367. label: string | undefined;
  81368. }
  81369. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81370. private __brand: void;
  81371. label: string | undefined;
  81372. setBindGroup(
  81373. index: number,
  81374. bindGroup: GPUBindGroup,
  81375. dynamicOffsets?: Iterable<number>
  81376. ): void;
  81377. popDebugGroup(): void;
  81378. pushDebugGroup(groupLabel: string): void;
  81379. insertDebugMarker(markerLabel: string): void;
  81380. setPipeline(pipeline: GPURenderPipeline): void;
  81381. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81382. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81383. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81384. draw(
  81385. vertexCount: number,
  81386. instanceCount?: number,
  81387. firstVertex?: number,
  81388. firstInstance?: number
  81389. ): void;
  81390. drawIndexed(
  81391. indexCount: number,
  81392. instanceCount?: number,
  81393. firstIndex?: number,
  81394. baseVertex?: number,
  81395. firstInstance?: number
  81396. ): void;
  81397. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81398. drawIndexedIndirect(
  81399. indirectBuffer: GPUBuffer,
  81400. indirectOffset: number
  81401. ): void;
  81402. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81403. }
  81404. interface GPURenderBundleEncoderDescriptor
  81405. extends GPUObjectDescriptorBase {
  81406. colorFormats: Iterable<GPUTextureFormat>;
  81407. depthStencilFormat?: GPUTextureFormat;
  81408. sampleCount?: number;
  81409. }
  81410. declare class GPURenderPipeline implements GPUPipelineBase {
  81411. private __brand: void;
  81412. label: string | undefined;
  81413. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81414. }
  81415. declare class GPUSampler implements GPUObjectBase {
  81416. private __brand: void;
  81417. label: string | undefined;
  81418. }
  81419. type GPUCompilationMessageType =
  81420. | "error"
  81421. | "warning"
  81422. | "info";
  81423. interface GPUCompilationMessage {
  81424. readonly message: string;
  81425. readonly type: GPUCompilationMessageType;
  81426. readonly lineNum: number;
  81427. readonly linePos: number;
  81428. }
  81429. interface GPUCompilationInfo {
  81430. readonly messages: readonly GPUCompilationMessage[];
  81431. }
  81432. declare class GPUShaderModule implements GPUObjectBase {
  81433. private __brand: void;
  81434. label: string | undefined;
  81435. compilationInfo(): Promise<GPUCompilationInfo>;
  81436. }
  81437. declare class GPUSwapChain implements GPUObjectBase {
  81438. private __brand: void;
  81439. label: string | undefined;
  81440. getCurrentTexture(): GPUTexture;
  81441. }
  81442. declare class GPUTexture implements GPUObjectBase {
  81443. private __brand: void;
  81444. label: string | undefined;
  81445. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81446. destroy(): void;
  81447. }
  81448. declare class GPUTextureView implements GPUObjectBase {
  81449. private __brand: void;
  81450. label: string | undefined;
  81451. }
  81452. type GPUPowerPreference = "low-power" | "high-performance";
  81453. interface GPURequestAdapterOptions {
  81454. powerPreference?: GPUPowerPreference;
  81455. }
  81456. declare class GPU {
  81457. private __brand: void;
  81458. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81459. }
  81460. // ****************************************************************************
  81461. // ERROR SCOPES
  81462. // ****************************************************************************
  81463. type GPUErrorFilter = "out-of-memory" | "validation";
  81464. declare class GPUOutOfMemoryError {
  81465. private __brand: void;
  81466. constructor();
  81467. }
  81468. declare class GPUValidationError {
  81469. private __brand: void;
  81470. constructor(message: string);
  81471. readonly message: string;
  81472. }
  81473. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81474. // ****************************************************************************
  81475. // TELEMETRY
  81476. // ****************************************************************************
  81477. declare class GPUUncapturedErrorEvent extends Event {
  81478. private __brand: void;
  81479. constructor(
  81480. type: string,
  81481. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81482. );
  81483. readonly error: GPUError;
  81484. }
  81485. interface GPUUncapturedErrorEventInit extends EventInit {
  81486. error: GPUError;
  81487. }
  81488. declare class GPUDeviceLostInfo {
  81489. private __brand: void;
  81490. readonly message: string;
  81491. }
  81492. // Type definitions for WebVR API
  81493. // Project: https://w3c.github.io/webvr/
  81494. // Definitions by: six a <https://github.com/lostfictions>
  81495. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81496. interface VRDisplay extends EventTarget {
  81497. /**
  81498. * Dictionary of capabilities describing the VRDisplay.
  81499. */
  81500. readonly capabilities: VRDisplayCapabilities;
  81501. /**
  81502. * z-depth defining the far plane of the eye view frustum
  81503. * enables mapping of values in the render target depth
  81504. * attachment to scene coordinates. Initially set to 10000.0.
  81505. */
  81506. depthFar: number;
  81507. /**
  81508. * z-depth defining the near plane of the eye view frustum
  81509. * enables mapping of values in the render target depth
  81510. * attachment to scene coordinates. Initially set to 0.01.
  81511. */
  81512. depthNear: number;
  81513. /**
  81514. * An identifier for this distinct VRDisplay. Used as an
  81515. * association point in the Gamepad API.
  81516. */
  81517. readonly displayId: number;
  81518. /**
  81519. * A display name, a user-readable name identifying it.
  81520. */
  81521. readonly displayName: string;
  81522. readonly isConnected: boolean;
  81523. readonly isPresenting: boolean;
  81524. /**
  81525. * If this VRDisplay supports room-scale experiences, the optional
  81526. * stage attribute contains details on the room-scale parameters.
  81527. */
  81528. readonly stageParameters: VRStageParameters | null;
  81529. /**
  81530. * Passing the value returned by `requestAnimationFrame` to
  81531. * `cancelAnimationFrame` will unregister the callback.
  81532. * @param handle Define the hanle of the request to cancel
  81533. */
  81534. cancelAnimationFrame(handle: number): void;
  81535. /**
  81536. * Stops presenting to the VRDisplay.
  81537. * @returns a promise to know when it stopped
  81538. */
  81539. exitPresent(): Promise<void>;
  81540. /**
  81541. * Return the current VREyeParameters for the given eye.
  81542. * @param whichEye Define the eye we want the parameter for
  81543. * @returns the eye parameters
  81544. */
  81545. getEyeParameters(whichEye: string): VREyeParameters;
  81546. /**
  81547. * Populates the passed VRFrameData with the information required to render
  81548. * the current frame.
  81549. * @param frameData Define the data structure to populate
  81550. * @returns true if ok otherwise false
  81551. */
  81552. getFrameData(frameData: VRFrameData): boolean;
  81553. /**
  81554. * Get the layers currently being presented.
  81555. * @returns the list of VR layers
  81556. */
  81557. getLayers(): VRLayer[];
  81558. /**
  81559. * Return a VRPose containing the future predicted pose of the VRDisplay
  81560. * when the current frame will be presented. The value returned will not
  81561. * change until JavaScript has returned control to the browser.
  81562. *
  81563. * The VRPose will contain the position, orientation, velocity,
  81564. * and acceleration of each of these properties.
  81565. * @returns the pose object
  81566. */
  81567. getPose(): VRPose;
  81568. /**
  81569. * Return the current instantaneous pose of the VRDisplay, with no
  81570. * prediction applied.
  81571. * @returns the current instantaneous pose
  81572. */
  81573. getImmediatePose(): VRPose;
  81574. /**
  81575. * The callback passed to `requestAnimationFrame` will be called
  81576. * any time a new frame should be rendered. When the VRDisplay is
  81577. * presenting the callback will be called at the native refresh
  81578. * rate of the HMD. When not presenting this function acts
  81579. * identically to how window.requestAnimationFrame acts. Content should
  81580. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81581. * asynchronously from other displays and at differing refresh rates.
  81582. * @param callback Define the eaction to run next frame
  81583. * @returns the request handle it
  81584. */
  81585. requestAnimationFrame(callback: FrameRequestCallback): number;
  81586. /**
  81587. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81588. * Repeat calls while already presenting will update the VRLayers being displayed.
  81589. * @param layers Define the list of layer to present
  81590. * @returns a promise to know when the request has been fulfilled
  81591. */
  81592. requestPresent(layers: VRLayer[]): Promise<void>;
  81593. /**
  81594. * Reset the pose for this display, treating its current position and
  81595. * orientation as the "origin/zero" values. VRPose.position,
  81596. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81597. * updated when calling resetPose(). This should be called in only
  81598. * sitting-space experiences.
  81599. */
  81600. resetPose(): void;
  81601. /**
  81602. * The VRLayer provided to the VRDisplay will be captured and presented
  81603. * in the HMD. Calling this function has the same effect on the source
  81604. * canvas as any other operation that uses its source image, and canvases
  81605. * created without preserveDrawingBuffer set to true will be cleared.
  81606. * @param pose Define the pose to submit
  81607. */
  81608. submitFrame(pose?: VRPose): void;
  81609. }
  81610. declare var VRDisplay: {
  81611. prototype: VRDisplay;
  81612. new(): VRDisplay;
  81613. };
  81614. interface VRLayer {
  81615. leftBounds?: number[] | Float32Array | null;
  81616. rightBounds?: number[] | Float32Array | null;
  81617. source?: HTMLCanvasElement | null;
  81618. }
  81619. interface VRDisplayCapabilities {
  81620. readonly canPresent: boolean;
  81621. readonly hasExternalDisplay: boolean;
  81622. readonly hasOrientation: boolean;
  81623. readonly hasPosition: boolean;
  81624. readonly maxLayers: number;
  81625. }
  81626. interface VREyeParameters {
  81627. /** @deprecated */
  81628. readonly fieldOfView: VRFieldOfView;
  81629. readonly offset: Float32Array;
  81630. readonly renderHeight: number;
  81631. readonly renderWidth: number;
  81632. }
  81633. interface VRFieldOfView {
  81634. readonly downDegrees: number;
  81635. readonly leftDegrees: number;
  81636. readonly rightDegrees: number;
  81637. readonly upDegrees: number;
  81638. }
  81639. interface VRFrameData {
  81640. readonly leftProjectionMatrix: Float32Array;
  81641. readonly leftViewMatrix: Float32Array;
  81642. readonly pose: VRPose;
  81643. readonly rightProjectionMatrix: Float32Array;
  81644. readonly rightViewMatrix: Float32Array;
  81645. readonly timestamp: number;
  81646. }
  81647. interface VRPose {
  81648. readonly angularAcceleration: Float32Array | null;
  81649. readonly angularVelocity: Float32Array | null;
  81650. readonly linearAcceleration: Float32Array | null;
  81651. readonly linearVelocity: Float32Array | null;
  81652. readonly orientation: Float32Array | null;
  81653. readonly position: Float32Array | null;
  81654. readonly timestamp: number;
  81655. }
  81656. interface VRStageParameters {
  81657. sittingToStandingTransform?: Float32Array;
  81658. sizeX?: number;
  81659. sizeY?: number;
  81660. }
  81661. interface Navigator {
  81662. getVRDisplays(): Promise<VRDisplay[]>;
  81663. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81664. }
  81665. interface Window {
  81666. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81667. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81668. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81669. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81670. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81671. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81672. }
  81673. interface Gamepad {
  81674. readonly displayId: number;
  81675. }
  81676. /**
  81677. * Available session modes
  81678. */
  81679. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81680. /**
  81681. * Reference space types
  81682. */
  81683. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81684. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81685. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81686. /**
  81687. * Handedness types
  81688. */
  81689. type XRHandedness = "none" | "left" | "right";
  81690. /**
  81691. * InputSource target ray modes
  81692. */
  81693. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81694. /**
  81695. * Eye types
  81696. */
  81697. type XREye = "none" | "left" | "right";
  81698. /**
  81699. * Type of XR events available
  81700. */
  81701. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  81702. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  81703. type XRPlaneSet = Set<XRPlane>;
  81704. type XRAnchorSet = Set<XRAnchor>;
  81705. type XREventHandler = (callback: any) => void;
  81706. interface XRLayer extends EventTarget {}
  81707. interface XRSessionInit {
  81708. optionalFeatures?: string[];
  81709. requiredFeatures?: string[];
  81710. trackedImages?: XRTrackedImageInit[];
  81711. }
  81712. interface XRSessionEvent extends Event {
  81713. readonly session: XRSession;
  81714. }
  81715. interface XRSystem {
  81716. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  81717. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  81718. }
  81719. interface XRViewport {
  81720. readonly x: number;
  81721. readonly y: number;
  81722. readonly width: number;
  81723. readonly height: number;
  81724. }
  81725. interface XRWebGLLayerInit {
  81726. antialias?: boolean;
  81727. depth?: boolean;
  81728. stencil?: boolean;
  81729. alpha?: boolean;
  81730. multiview?: boolean;
  81731. framebufferScaleFactor?: number;
  81732. }
  81733. declare class XRWebGLLayer {
  81734. static getNativeFramebufferScaleFactor(session: XRSession): number;
  81735. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  81736. readonly antialias: boolean;
  81737. readonly framebuffer: WebGLFramebuffer;
  81738. readonly framebufferWidth: number;
  81739. readonly framebufferHeight: number;
  81740. readonly ignoreDepthValues: boolean;
  81741. getViewport: (view: XRView) => XRViewport;
  81742. }
  81743. // tslint:disable-next-line no-empty-interface
  81744. interface XRSpace extends EventTarget {}
  81745. interface XRRenderState {
  81746. readonly baseLayer?: XRWebGLLayer;
  81747. readonly depthFar: number;
  81748. readonly depthNear: number;
  81749. readonly inlineVerticalFieldOfView?: number;
  81750. }
  81751. interface XRRenderStateInit extends XRRenderState {
  81752. baseLayer: XRWebGLLayer;
  81753. depthFar: number;
  81754. depthNear: number;
  81755. inlineVerticalFieldOfView?: number;
  81756. layers?: XRLayer[];
  81757. }
  81758. interface XRReferenceSpace extends XRSpace {
  81759. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  81760. onreset: XREventHandler;
  81761. }
  81762. interface XRBoundedReferenceSpace extends XRSpace {
  81763. readonly boundsGeometry: DOMPointReadOnly[];
  81764. }
  81765. interface XRInputSource {
  81766. readonly handedness: XRHandedness;
  81767. readonly targetRayMode: XRTargetRayMode;
  81768. readonly targetRaySpace: XRSpace;
  81769. readonly gripSpace?: XRSpace;
  81770. readonly gamepad?: Gamepad;
  81771. readonly profiles: Array<string>;
  81772. readonly hand?: XRHand;
  81773. }
  81774. interface XRPose {
  81775. readonly transform: XRRigidTransform;
  81776. readonly emulatedPosition: boolean;
  81777. }
  81778. interface XRWorldInformation {
  81779. detectedPlanes?: XRPlaneSet;
  81780. }
  81781. interface XRFrame {
  81782. readonly session: XRSession;
  81783. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  81784. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  81785. // AR
  81786. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  81787. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  81788. // Anchors
  81789. trackedAnchors?: XRAnchorSet;
  81790. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  81791. // World geometries
  81792. worldInformation?: XRWorldInformation;
  81793. // Hand tracking
  81794. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  81795. // Image tracking
  81796. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  81797. }
  81798. interface XRInputSourceEvent extends Event {
  81799. readonly frame: XRFrame;
  81800. readonly inputSource: XRInputSource;
  81801. }
  81802. type XRInputSourceArray = XRInputSource[];
  81803. interface XRSession {
  81804. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  81805. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  81806. /**
  81807. * Returns a list of this session's XRInputSources, each representing an input device
  81808. * used to control the camera and/or scene.
  81809. */
  81810. readonly inputSources: Array<XRInputSource>;
  81811. /**
  81812. * object which contains options affecting how the imagery is rendered.
  81813. * This includes things such as the near and far clipping planes
  81814. */
  81815. readonly renderState: XRRenderState;
  81816. readonly visibilityState: XRVisibilityState;
  81817. /**
  81818. * Removes a callback from the animation frame painting callback from
  81819. * XRSession's set of animation frame rendering callbacks, given the
  81820. * identifying handle returned by a previous call to requestAnimationFrame().
  81821. */
  81822. cancelAnimationFrame: (handle: number) => void;
  81823. /**
  81824. * Ends the WebXR session. Returns a promise which resolves when the
  81825. * session has been shut down.
  81826. */
  81827. end(): Promise<void>;
  81828. /**
  81829. * Schedules the specified method to be called the next time the user agent
  81830. * is working on rendering an animation frame for the WebXR device. Returns an
  81831. * integer value which can be used to identify the request for the purposes of
  81832. * canceling the callback using cancelAnimationFrame(). This method is comparable
  81833. * to the Window.requestAnimationFrame() method.
  81834. */
  81835. requestAnimationFrame: XRFrameRequestCallback;
  81836. /**
  81837. * Requests that a new XRReferenceSpace of the specified type be created.
  81838. * Returns a promise which resolves with the XRReferenceSpace or
  81839. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  81840. * the requested space type isn't supported by the device.
  81841. */
  81842. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  81843. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  81844. onend: XREventHandler;
  81845. oninputsourceschange: XREventHandler;
  81846. onselect: XREventHandler;
  81847. onselectstart: XREventHandler;
  81848. onselectend: XREventHandler;
  81849. onsqueeze: XREventHandler;
  81850. onsqueezestart: XREventHandler;
  81851. onsqueezeend: XREventHandler;
  81852. onvisibilitychange: XREventHandler;
  81853. // hit test
  81854. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  81855. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  81856. // legacy AR hit test
  81857. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  81858. // legacy plane detection
  81859. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  81860. // image tracking
  81861. getTrackedImageScores?(): XRImageTrackingScore[];
  81862. }
  81863. interface XRViewerPose extends XRPose {
  81864. readonly views: Array<XRView>;
  81865. }
  81866. declare class XRRigidTransform {
  81867. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  81868. position: DOMPointReadOnly;
  81869. orientation: DOMPointReadOnly;
  81870. matrix: Float32Array;
  81871. inverse: XRRigidTransform;
  81872. }
  81873. interface XRView {
  81874. readonly eye: XREye;
  81875. readonly projectionMatrix: Float32Array;
  81876. readonly transform: XRRigidTransform;
  81877. readonly recommendedViewportScale?: number;
  81878. requestViewportScale(scale: number): void;
  81879. }
  81880. interface XRInputSourceChangeEvent extends Event {
  81881. session: XRSession;
  81882. removed: Array<XRInputSource>;
  81883. added: Array<XRInputSource>;
  81884. }
  81885. // Experimental/Draft features
  81886. declare class XRRay {
  81887. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  81888. origin: DOMPointReadOnly;
  81889. direction: DOMPointReadOnly;
  81890. matrix: Float32Array;
  81891. }
  81892. declare enum XRHitTestTrackableType {
  81893. "point",
  81894. "plane",
  81895. "mesh",
  81896. }
  81897. interface XRHitResult {
  81898. hitMatrix: Float32Array;
  81899. }
  81900. interface XRTransientInputHitTestResult {
  81901. readonly inputSource: XRInputSource;
  81902. readonly results: Array<XRHitTestResult>;
  81903. }
  81904. interface XRHitTestResult {
  81905. getPose(baseSpace: XRSpace): XRPose | undefined;
  81906. // When anchor system is enabled
  81907. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  81908. }
  81909. interface XRHitTestSource {
  81910. cancel(): void;
  81911. }
  81912. interface XRTransientInputHitTestSource {
  81913. cancel(): void;
  81914. }
  81915. interface XRHitTestOptionsInit {
  81916. space: XRSpace;
  81917. entityTypes?: Array<XRHitTestTrackableType>;
  81918. offsetRay?: XRRay;
  81919. }
  81920. interface XRTransientInputHitTestOptionsInit {
  81921. profile: string;
  81922. entityTypes?: Array<XRHitTestTrackableType>;
  81923. offsetRay?: XRRay;
  81924. }
  81925. interface XRAnchor {
  81926. anchorSpace: XRSpace;
  81927. delete(): void;
  81928. }
  81929. interface XRPlane {
  81930. orientation: "Horizontal" | "Vertical";
  81931. planeSpace: XRSpace;
  81932. polygon: Array<DOMPointReadOnly>;
  81933. lastChangedTime: number;
  81934. }
  81935. interface XRJointSpace extends XRSpace {}
  81936. interface XRJointPose extends XRPose {
  81937. radius: number | undefined;
  81938. }
  81939. interface XRHand extends Iterable<XRJointSpace> {
  81940. readonly length: number;
  81941. [index: number]: XRJointSpace;
  81942. readonly WRIST: number;
  81943. readonly THUMB_METACARPAL: number;
  81944. readonly THUMB_PHALANX_PROXIMAL: number;
  81945. readonly THUMB_PHALANX_DISTAL: number;
  81946. readonly THUMB_PHALANX_TIP: number;
  81947. readonly INDEX_METACARPAL: number;
  81948. readonly INDEX_PHALANX_PROXIMAL: number;
  81949. readonly INDEX_PHALANX_INTERMEDIATE: number;
  81950. readonly INDEX_PHALANX_DISTAL: number;
  81951. readonly INDEX_PHALANX_TIP: number;
  81952. readonly MIDDLE_METACARPAL: number;
  81953. readonly MIDDLE_PHALANX_PROXIMAL: number;
  81954. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  81955. readonly MIDDLE_PHALANX_DISTAL: number;
  81956. readonly MIDDLE_PHALANX_TIP: number;
  81957. readonly RING_METACARPAL: number;
  81958. readonly RING_PHALANX_PROXIMAL: number;
  81959. readonly RING_PHALANX_INTERMEDIATE: number;
  81960. readonly RING_PHALANX_DISTAL: number;
  81961. readonly RING_PHALANX_TIP: number;
  81962. readonly LITTLE_METACARPAL: number;
  81963. readonly LITTLE_PHALANX_PROXIMAL: number;
  81964. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  81965. readonly LITTLE_PHALANX_DISTAL: number;
  81966. readonly LITTLE_PHALANX_TIP: number;
  81967. }
  81968. type XRImageTrackingState = "tracked" | "emulated";
  81969. type XRImageTrackingScore = "untrackable" | "trackable";
  81970. interface XRTrackedImageInit {
  81971. image: ImageBitmap;
  81972. widthInMeters: number;
  81973. }
  81974. interface XRImageTrackingResult {
  81975. readonly imageSpace: XRSpace;
  81976. readonly index: number;
  81977. readonly trackingState: XRImageTrackingState;
  81978. readonly measuredWidthInMeters: number;
  81979. }
  81980. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  81981. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  81982. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  81983. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  81984. interface XRSceneObject {
  81985. type: XRSceneObjectType;
  81986. }
  81987. interface XRFieldOfView {
  81988. angleLeft: number;
  81989. angleRight: number;
  81990. angleUp: number;
  81991. angleDown: number;
  81992. }
  81993. interface XRFrustum {
  81994. position: DOMPointReadOnly;
  81995. orientation: DOMPointReadOnly;
  81996. fieldOfView: XRFieldOfView;
  81997. farDistance: number;
  81998. }
  81999. interface XRPlane {
  82000. parentSceneObject?: XRSceneObject;
  82001. }
  82002. interface XRMesh {
  82003. meshSpace: XRSpace;
  82004. positions: Float32Array;
  82005. indices: Uint32Array;
  82006. normals?: Float32Array;
  82007. lastChangedTime: number;
  82008. parentSceneObject?: XRSceneObject;
  82009. }
  82010. interface XRFrustumDetectionBoundary {
  82011. type: "frustum";
  82012. frustum: XRFrustum;
  82013. }
  82014. interface XRSphereDetectionBoundary {
  82015. type: "sphere";
  82016. radius: number;
  82017. }
  82018. interface XRBoxDetectionBoundary {
  82019. type: "box";
  82020. extent: DOMPointReadOnly;
  82021. }
  82022. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82023. interface XRGeometryDetectorOptions {
  82024. detectionBoundary?: XRDetectionBoundary;
  82025. updateInterval?: number;
  82026. }
  82027. interface XRSession {
  82028. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82029. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82030. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82031. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82032. }
  82033. interface XRFrame {
  82034. featurePointCloud?: Array<number>;
  82035. }
  82036. type XRMeshSet = Set<XRMesh>;
  82037. interface XRWorldInformation {
  82038. detectedMeshes?: XRMeshSet;
  82039. }
  82040. /**
  82041. * @ignore
  82042. */
  82043. declare module BABYLON.GLTF2.Exporter {
  82044. }
  82045. /**
  82046. * @ignore
  82047. */
  82048. declare module BABYLON.GLTF1 {
  82049. }
  82050. declare module BABYLON.GUI {
  82051. /**
  82052. * Interface used to define a control that can receive focus
  82053. */
  82054. export interface IFocusableControl {
  82055. /**
  82056. * Function called when the control receives the focus
  82057. */
  82058. onFocus(): void;
  82059. /**
  82060. * Function called when the control loses the focus
  82061. */
  82062. onBlur(): void;
  82063. /**
  82064. * Function called to let the control handle keyboard events
  82065. * @param evt defines the current keyboard event
  82066. */
  82067. processKeyboard(evt: KeyboardEvent): void;
  82068. /**
  82069. * Function called to get the list of controls that should not steal the focus from this control
  82070. * @returns an array of controls
  82071. */
  82072. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  82073. /**
  82074. * Function to focus the control programmatically
  82075. */
  82076. focus(): void;
  82077. /**
  82078. * Function to unfocus the control programmatically
  82079. */
  82080. blur(): void;
  82081. }
  82082. }
  82083. declare module BABYLON.GUI {
  82084. /**
  82085. * Class used to specific a value and its associated unit
  82086. */
  82087. export class ValueAndUnit {
  82088. /** defines the unit to store */
  82089. unit: number;
  82090. /** defines a boolean indicating if the value can be negative */
  82091. negativeValueAllowed: boolean;
  82092. private _value;
  82093. private _originalUnit;
  82094. /**
  82095. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82096. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82097. */
  82098. ignoreAdaptiveScaling: boolean;
  82099. /**
  82100. * Creates a new ValueAndUnit
  82101. * @param value defines the value to store
  82102. * @param unit defines the unit to store
  82103. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82104. */
  82105. constructor(value: number,
  82106. /** defines the unit to store */
  82107. unit?: number,
  82108. /** defines a boolean indicating if the value can be negative */
  82109. negativeValueAllowed?: boolean);
  82110. /** Gets a boolean indicating if the value is a percentage */
  82111. get isPercentage(): boolean;
  82112. /** Gets a boolean indicating if the value is store as pixel */
  82113. get isPixel(): boolean;
  82114. /** Gets direct internal value */
  82115. get internalValue(): number;
  82116. /**
  82117. * Gets value as pixel
  82118. * @param host defines the root host
  82119. * @param refValue defines the reference value for percentages
  82120. * @returns the value as pixel
  82121. */
  82122. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82123. /**
  82124. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82125. * @param value defines the value to store
  82126. * @param unit defines the unit to store
  82127. * @returns the current ValueAndUnit
  82128. */
  82129. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82130. /**
  82131. * Gets the value accordingly to its unit
  82132. * @param host defines the root host
  82133. * @returns the value
  82134. */
  82135. getValue(host: AdvancedDynamicTexture): number;
  82136. /**
  82137. * Gets a string representation of the value
  82138. * @param host defines the root host
  82139. * @param decimals defines an optional number of decimals to display
  82140. * @returns a string
  82141. */
  82142. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82143. /**
  82144. * Store a value parsed from a string
  82145. * @param source defines the source string
  82146. * @returns true if the value was successfully parsed
  82147. */
  82148. fromString(source: string | number): boolean;
  82149. private static _Regex;
  82150. private static _UNITMODE_PERCENTAGE;
  82151. private static _UNITMODE_PIXEL;
  82152. /** UNITMODE_PERCENTAGE */
  82153. static get UNITMODE_PERCENTAGE(): number;
  82154. /** UNITMODE_PIXEL */
  82155. static get UNITMODE_PIXEL(): number;
  82156. }
  82157. }
  82158. declare module BABYLON.GUI {
  82159. /**
  82160. * Define a style used by control to automatically setup properties based on a template.
  82161. * Only support font related properties so far
  82162. */
  82163. export class Style implements BABYLON.IDisposable {
  82164. private _fontFamily;
  82165. private _fontStyle;
  82166. private _fontWeight;
  82167. /** @hidden */
  82168. _host: AdvancedDynamicTexture;
  82169. /** @hidden */
  82170. _fontSize: ValueAndUnit;
  82171. /**
  82172. * BABYLON.Observable raised when the style values are changed
  82173. */
  82174. onChangedObservable: BABYLON.Observable<Style>;
  82175. /**
  82176. * Creates a new style object
  82177. * @param host defines the AdvancedDynamicTexture which hosts this style
  82178. */
  82179. constructor(host: AdvancedDynamicTexture);
  82180. /**
  82181. * Gets or sets the font size
  82182. */
  82183. get fontSize(): string | number;
  82184. set fontSize(value: string | number);
  82185. /**
  82186. * Gets or sets the font family
  82187. */
  82188. get fontFamily(): string;
  82189. set fontFamily(value: string);
  82190. /**
  82191. * Gets or sets the font style
  82192. */
  82193. get fontStyle(): string;
  82194. set fontStyle(value: string);
  82195. /** Gets or sets font weight */
  82196. get fontWeight(): string;
  82197. set fontWeight(value: string);
  82198. /** Dispose all associated resources */
  82199. dispose(): void;
  82200. }
  82201. }
  82202. declare module BABYLON.GUI {
  82203. /**
  82204. * Class used to transport BABYLON.Vector2 information for pointer events
  82205. */
  82206. export class Vector2WithInfo extends BABYLON.Vector2 {
  82207. /** defines the current mouse button index */
  82208. buttonIndex: number;
  82209. /**
  82210. * Creates a new Vector2WithInfo
  82211. * @param source defines the vector2 data to transport
  82212. * @param buttonIndex defines the current mouse button index
  82213. */
  82214. constructor(source: BABYLON.Vector2,
  82215. /** defines the current mouse button index */
  82216. buttonIndex?: number);
  82217. }
  82218. /** Class used to provide 2D matrix features */
  82219. export class Matrix2D {
  82220. /** Gets the internal array of 6 floats used to store matrix data */
  82221. m: Float32Array;
  82222. /**
  82223. * Creates a new matrix
  82224. * @param m00 defines value for (0, 0)
  82225. * @param m01 defines value for (0, 1)
  82226. * @param m10 defines value for (1, 0)
  82227. * @param m11 defines value for (1, 1)
  82228. * @param m20 defines value for (2, 0)
  82229. * @param m21 defines value for (2, 1)
  82230. */
  82231. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82232. /**
  82233. * Fills the matrix from direct values
  82234. * @param m00 defines value for (0, 0)
  82235. * @param m01 defines value for (0, 1)
  82236. * @param m10 defines value for (1, 0)
  82237. * @param m11 defines value for (1, 1)
  82238. * @param m20 defines value for (2, 0)
  82239. * @param m21 defines value for (2, 1)
  82240. * @returns the current modified matrix
  82241. */
  82242. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82243. /**
  82244. * Gets matrix determinant
  82245. * @returns the determinant
  82246. */
  82247. determinant(): number;
  82248. /**
  82249. * Inverses the matrix and stores it in a target matrix
  82250. * @param result defines the target matrix
  82251. * @returns the current matrix
  82252. */
  82253. invertToRef(result: Matrix2D): Matrix2D;
  82254. /**
  82255. * Multiplies the current matrix with another one
  82256. * @param other defines the second operand
  82257. * @param result defines the target matrix
  82258. * @returns the current matrix
  82259. */
  82260. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82261. /**
  82262. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82263. * @param x defines the x coordinate to transform
  82264. * @param y defines the x coordinate to transform
  82265. * @param result defines the target vector2
  82266. * @returns the current matrix
  82267. */
  82268. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82269. /**
  82270. * Creates an identity matrix
  82271. * @returns a new matrix
  82272. */
  82273. static Identity(): Matrix2D;
  82274. /**
  82275. * Creates a translation matrix and stores it in a target matrix
  82276. * @param x defines the x coordinate of the translation
  82277. * @param y defines the y coordinate of the translation
  82278. * @param result defines the target matrix
  82279. */
  82280. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82281. /**
  82282. * Creates a scaling matrix and stores it in a target matrix
  82283. * @param x defines the x coordinate of the scaling
  82284. * @param y defines the y coordinate of the scaling
  82285. * @param result defines the target matrix
  82286. */
  82287. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82288. /**
  82289. * Creates a rotation matrix and stores it in a target matrix
  82290. * @param angle defines the rotation angle
  82291. * @param result defines the target matrix
  82292. */
  82293. static RotationToRef(angle: number, result: Matrix2D): void;
  82294. private static _TempPreTranslationMatrix;
  82295. private static _TempPostTranslationMatrix;
  82296. private static _TempRotationMatrix;
  82297. private static _TempScalingMatrix;
  82298. private static _TempCompose0;
  82299. private static _TempCompose1;
  82300. private static _TempCompose2;
  82301. /**
  82302. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82303. * @param tx defines the x coordinate of the translation
  82304. * @param ty defines the y coordinate of the translation
  82305. * @param angle defines the rotation angle
  82306. * @param scaleX defines the x coordinate of the scaling
  82307. * @param scaleY defines the y coordinate of the scaling
  82308. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82309. * @param result defines the target matrix
  82310. */
  82311. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82312. }
  82313. }
  82314. declare module BABYLON.GUI {
  82315. /**
  82316. * Class used to store 2D control sizes
  82317. */
  82318. export class Measure {
  82319. /** defines left coordinate */
  82320. left: number;
  82321. /** defines top coordinate */
  82322. top: number;
  82323. /** defines width dimension */
  82324. width: number;
  82325. /** defines height dimension */
  82326. height: number;
  82327. /**
  82328. * Creates a new measure
  82329. * @param left defines left coordinate
  82330. * @param top defines top coordinate
  82331. * @param width defines width dimension
  82332. * @param height defines height dimension
  82333. */
  82334. constructor(
  82335. /** defines left coordinate */
  82336. left: number,
  82337. /** defines top coordinate */
  82338. top: number,
  82339. /** defines width dimension */
  82340. width: number,
  82341. /** defines height dimension */
  82342. height: number);
  82343. /**
  82344. * Copy from another measure
  82345. * @param other defines the other measure to copy from
  82346. */
  82347. copyFrom(other: Measure): void;
  82348. /**
  82349. * Copy from a group of 4 floats
  82350. * @param left defines left coordinate
  82351. * @param top defines top coordinate
  82352. * @param width defines width dimension
  82353. * @param height defines height dimension
  82354. */
  82355. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82356. /**
  82357. * Computes the axis aligned bounding box measure for two given measures
  82358. * @param a Input measure
  82359. * @param b Input measure
  82360. * @param result the resulting bounding measure
  82361. */
  82362. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82363. /**
  82364. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82365. * @param transform the matrix to transform the measure before computing the AABB
  82366. * @param addX number to add to left
  82367. * @param addY number to add to top
  82368. * @param addWidth number to add to width
  82369. * @param addHeight number to add to height
  82370. * @param result the resulting AABB
  82371. */
  82372. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82373. /**
  82374. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82375. * @param transform the matrix to transform the measure before computing the AABB
  82376. * @param result the resulting AABB
  82377. */
  82378. transformToRef(transform: Matrix2D, result: Measure): void;
  82379. /**
  82380. * Check equality between this measure and another one
  82381. * @param other defines the other measures
  82382. * @returns true if both measures are equals
  82383. */
  82384. isEqualsTo(other: Measure): boolean;
  82385. /**
  82386. * Creates an empty measure
  82387. * @returns a new measure
  82388. */
  82389. static Empty(): Measure;
  82390. }
  82391. }
  82392. declare module BABYLON.GUI {
  82393. /**
  82394. * Class used to create texture to support 2D GUI elements
  82395. * @see https://doc.babylonjs.com/how_to/gui
  82396. */
  82397. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82398. /** Define the Uurl to load snippets */
  82399. static SnippetUrl: string;
  82400. /** Snippet ID if the content was created from the snippet server */
  82401. snippetId: string;
  82402. private _isDirty;
  82403. private _renderObserver;
  82404. private _resizeObserver;
  82405. private _preKeyboardObserver;
  82406. private _pointerMoveObserver;
  82407. private _pointerObserver;
  82408. private _canvasPointerOutObserver;
  82409. private _canvasBlurObserver;
  82410. private _background;
  82411. /** @hidden */
  82412. _rootContainer: Container;
  82413. /** @hidden */
  82414. _lastPickedControl: Control;
  82415. /** @hidden */
  82416. _lastControlOver: {
  82417. [pointerId: number]: Control;
  82418. };
  82419. /** @hidden */
  82420. _lastControlDown: {
  82421. [pointerId: number]: Control;
  82422. };
  82423. /** @hidden */
  82424. _capturingControl: {
  82425. [pointerId: number]: Control;
  82426. };
  82427. /** @hidden */
  82428. _shouldBlockPointer: boolean;
  82429. /** @hidden */
  82430. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82431. /** @hidden */
  82432. _linkedControls: Control[];
  82433. private _isFullscreen;
  82434. private _fullscreenViewport;
  82435. private _idealWidth;
  82436. private _idealHeight;
  82437. private _useSmallestIdeal;
  82438. private _renderAtIdealSize;
  82439. private _focusedControl;
  82440. private _blockNextFocusCheck;
  82441. private _renderScale;
  82442. private _rootElement;
  82443. private _cursorChanged;
  82444. private _defaultMousePointerId;
  82445. /** @hidden */
  82446. _numLayoutCalls: number;
  82447. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82448. get numLayoutCalls(): number;
  82449. /** @hidden */
  82450. _numRenderCalls: number;
  82451. /** Gets the number of render calls made the last time the ADT has been rendered */
  82452. get numRenderCalls(): number;
  82453. /**
  82454. * Define type to string to ensure compatibility across browsers
  82455. * Safari doesn't support DataTransfer constructor
  82456. */
  82457. private _clipboardData;
  82458. /**
  82459. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82460. */
  82461. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82462. /**
  82463. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82464. */
  82465. onControlPickedObservable: BABYLON.Observable<Control>;
  82466. /**
  82467. * BABYLON.Observable event triggered before layout is evaluated
  82468. */
  82469. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82470. /**
  82471. * BABYLON.Observable event triggered after the layout was evaluated
  82472. */
  82473. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82474. /**
  82475. * BABYLON.Observable event triggered before the texture is rendered
  82476. */
  82477. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82478. /**
  82479. * BABYLON.Observable event triggered after the texture was rendered
  82480. */
  82481. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82482. /**
  82483. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82484. */
  82485. premulAlpha: boolean;
  82486. /**
  82487. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82488. */
  82489. applyYInversionOnUpdate: boolean;
  82490. /**
  82491. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82492. * Useful when you want more antialiasing
  82493. */
  82494. get renderScale(): number;
  82495. set renderScale(value: number);
  82496. /** Gets or sets the background color */
  82497. get background(): string;
  82498. set background(value: string);
  82499. /**
  82500. * Gets or sets the ideal width used to design controls.
  82501. * The GUI will then rescale everything accordingly
  82502. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82503. */
  82504. get idealWidth(): number;
  82505. set idealWidth(value: number);
  82506. /**
  82507. * Gets or sets the ideal height used to design controls.
  82508. * The GUI will then rescale everything accordingly
  82509. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82510. */
  82511. get idealHeight(): number;
  82512. set idealHeight(value: number);
  82513. /**
  82514. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82515. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82516. */
  82517. get useSmallestIdeal(): boolean;
  82518. set useSmallestIdeal(value: boolean);
  82519. /**
  82520. * Gets or sets a boolean indicating if adaptive scaling must be used
  82521. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82522. */
  82523. get renderAtIdealSize(): boolean;
  82524. set renderAtIdealSize(value: boolean);
  82525. /**
  82526. * Gets the ratio used when in "ideal mode"
  82527. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82528. * */
  82529. get idealRatio(): number;
  82530. /**
  82531. * Gets the underlying layer used to render the texture when in fullscreen mode
  82532. */
  82533. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82534. /**
  82535. * Gets the root container control
  82536. */
  82537. get rootContainer(): Container;
  82538. /**
  82539. * Returns an array containing the root container.
  82540. * This is mostly used to let the Inspector introspects the ADT
  82541. * @returns an array containing the rootContainer
  82542. */
  82543. getChildren(): Array<Container>;
  82544. /**
  82545. * Will return all controls that are inside this texture
  82546. * @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
  82547. * @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
  82548. * @return all child controls
  82549. */
  82550. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82551. /**
  82552. * Gets or sets the current focused control
  82553. */
  82554. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82555. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82556. /**
  82557. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82558. */
  82559. get isForeground(): boolean;
  82560. set isForeground(value: boolean);
  82561. /**
  82562. * Gets or set information about clipboardData
  82563. */
  82564. get clipboardData(): string;
  82565. set clipboardData(value: string);
  82566. /**
  82567. * Creates a new AdvancedDynamicTexture
  82568. * @param name defines the name of the texture
  82569. * @param width defines the width of the texture
  82570. * @param height defines the height of the texture
  82571. * @param scene defines the hosting scene
  82572. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82573. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82574. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82575. */
  82576. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82577. /**
  82578. * Get the current class name of the texture useful for serialization or dynamic coding.
  82579. * @returns "AdvancedDynamicTexture"
  82580. */
  82581. getClassName(): string;
  82582. /**
  82583. * Function used to execute a function on all controls
  82584. * @param func defines the function to execute
  82585. * @param container defines the container where controls belong. If null the root container will be used
  82586. */
  82587. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82588. private _useInvalidateRectOptimization;
  82589. /**
  82590. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82591. */
  82592. get useInvalidateRectOptimization(): boolean;
  82593. set useInvalidateRectOptimization(value: boolean);
  82594. private _invalidatedRectangle;
  82595. /**
  82596. * Invalidates a rectangle area on the gui texture
  82597. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  82598. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  82599. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  82600. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  82601. */
  82602. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  82603. /**
  82604. * Marks the texture as dirty forcing a complete update
  82605. */
  82606. markAsDirty(): void;
  82607. /**
  82608. * Helper function used to create a new style
  82609. * @returns a new style
  82610. * @see https://doc.babylonjs.com/how_to/gui#styles
  82611. */
  82612. createStyle(): Style;
  82613. /**
  82614. * Adds a new control to the root container
  82615. * @param control defines the control to add
  82616. * @returns the current texture
  82617. */
  82618. addControl(control: Control): AdvancedDynamicTexture;
  82619. /**
  82620. * Removes a control from the root container
  82621. * @param control defines the control to remove
  82622. * @returns the current texture
  82623. */
  82624. removeControl(control: Control): AdvancedDynamicTexture;
  82625. /**
  82626. * Release all resources
  82627. */
  82628. dispose(): void;
  82629. private _onResize;
  82630. /** @hidden */
  82631. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  82632. /**
  82633. * Get screen coordinates for a vector3
  82634. * @param position defines the position to project
  82635. * @param worldMatrix defines the world matrix to use
  82636. * @returns the projected position
  82637. */
  82638. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  82639. /**
  82640. * Get screen coordinates for a vector3
  82641. * @param position defines the position to project
  82642. * @param worldMatrix defines the world matrix to use
  82643. * @returns the projected position with Z
  82644. */
  82645. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  82646. private _checkUpdate;
  82647. private _clearMeasure;
  82648. private _render;
  82649. /** @hidden */
  82650. _changeCursor(cursor: string): void;
  82651. /** @hidden */
  82652. _registerLastControlDown(control: Control, pointerId: number): void;
  82653. private _doPicking;
  82654. /** @hidden */
  82655. _cleanControlAfterRemovalFromList(list: {
  82656. [pointerId: number]: Control;
  82657. }, control: Control): void;
  82658. /** @hidden */
  82659. _cleanControlAfterRemoval(control: Control): void;
  82660. /** Attach to all scene events required to support pointer events */
  82661. attach(): void;
  82662. /** @hidden */
  82663. private onClipboardCopy;
  82664. /** @hidden */
  82665. private onClipboardCut;
  82666. /** @hidden */
  82667. private onClipboardPaste;
  82668. /**
  82669. * Register the clipboard Events onto the canvas
  82670. */
  82671. registerClipboardEvents(): void;
  82672. /**
  82673. * Unregister the clipboard Events from the canvas
  82674. */
  82675. unRegisterClipboardEvents(): void;
  82676. /**
  82677. * Connect the texture to a hosting mesh to enable interactions
  82678. * @param mesh defines the mesh to attach to
  82679. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  82680. */
  82681. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  82682. /**
  82683. * Move the focus to a specific control
  82684. * @param control defines the control which will receive the focus
  82685. */
  82686. moveFocusToControl(control: IFocusableControl): void;
  82687. private _manageFocus;
  82688. private _attachToOnPointerOut;
  82689. private _attachToOnBlur;
  82690. /**
  82691. * Serializes the entire GUI system
  82692. * @returns an object with the JSON serialized data
  82693. */
  82694. serializeContent(): any;
  82695. /**
  82696. * Recreate the content of the ADT from a JSON object
  82697. * @param serializedObject define the JSON serialized object to restore from
  82698. */
  82699. parseContent(serializedObject: any): void;
  82700. /**
  82701. * Recreate the content of the ADT from a snippet saved by the GUI editor
  82702. * @param snippetId defines the snippet to load
  82703. * @returns a promise that will resolve on success
  82704. */
  82705. parseFromSnippetAsync(snippetId: string): Promise<void>;
  82706. /**
  82707. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  82708. * @param mesh defines the mesh which will receive the texture
  82709. * @param width defines the texture width (1024 by default)
  82710. * @param height defines the texture height (1024 by default)
  82711. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82712. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  82713. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82714. * @returns a new AdvancedDynamicTexture
  82715. */
  82716. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82717. /**
  82718. * 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
  82719. * @param mesh defines the mesh which will receive the texture
  82720. * @param width defines the texture width (1024 by default)
  82721. * @param height defines the texture height (1024 by default)
  82722. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82723. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82724. * @returns a new AdvancedDynamicTexture
  82725. */
  82726. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82727. /**
  82728. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  82729. * In this mode the texture will rely on a layer for its rendering.
  82730. * This allows it to be treated like any other layer.
  82731. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  82732. * LayerMask is set through advancedTexture.layer.layerMask
  82733. * @param name defines name for the texture
  82734. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  82735. * @param scene defines the hsoting scene
  82736. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  82737. * @returns a new AdvancedDynamicTexture
  82738. */
  82739. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  82740. }
  82741. }
  82742. declare module BABYLON.GUI {
  82743. /**
  82744. * Root class used for all 2D controls
  82745. * @see https://doc.babylonjs.com/how_to/gui#controls
  82746. */
  82747. export class Control {
  82748. /** defines the name of the control */
  82749. name?: string | undefined;
  82750. /**
  82751. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  82752. */
  82753. static AllowAlphaInheritance: boolean;
  82754. private _alpha;
  82755. private _alphaSet;
  82756. private _zIndex;
  82757. /** @hidden */
  82758. _host: AdvancedDynamicTexture;
  82759. /** Gets or sets the control parent */
  82760. parent: BABYLON.Nullable<Container>;
  82761. /** @hidden */
  82762. _currentMeasure: Measure;
  82763. private _fontFamily;
  82764. private _fontStyle;
  82765. private _fontWeight;
  82766. private _fontSize;
  82767. private _font;
  82768. /** @hidden */
  82769. _width: ValueAndUnit;
  82770. /** @hidden */
  82771. _height: ValueAndUnit;
  82772. /** @hidden */
  82773. protected _fontOffset: {
  82774. ascent: number;
  82775. height: number;
  82776. descent: number;
  82777. };
  82778. private _color;
  82779. private _style;
  82780. private _styleObserver;
  82781. /** @hidden */
  82782. protected _horizontalAlignment: number;
  82783. /** @hidden */
  82784. protected _verticalAlignment: number;
  82785. /** @hidden */
  82786. protected _isDirty: boolean;
  82787. /** @hidden */
  82788. protected _wasDirty: boolean;
  82789. /** @hidden */
  82790. _tempParentMeasure: Measure;
  82791. /** @hidden */
  82792. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  82793. /** @hidden */
  82794. protected _cachedParentMeasure: Measure;
  82795. private _paddingLeft;
  82796. private _paddingRight;
  82797. private _paddingTop;
  82798. private _paddingBottom;
  82799. /** @hidden */
  82800. _left: ValueAndUnit;
  82801. /** @hidden */
  82802. _top: ValueAndUnit;
  82803. private _scaleX;
  82804. private _scaleY;
  82805. private _rotation;
  82806. private _transformCenterX;
  82807. private _transformCenterY;
  82808. /** @hidden */
  82809. _transformMatrix: Matrix2D;
  82810. /** @hidden */
  82811. protected _invertTransformMatrix: Matrix2D;
  82812. /** @hidden */
  82813. protected _transformedPosition: BABYLON.Vector2;
  82814. private _isMatrixDirty;
  82815. private _cachedOffsetX;
  82816. private _cachedOffsetY;
  82817. private _isVisible;
  82818. private _isHighlighted;
  82819. /** @hidden */
  82820. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  82821. private _fontSet;
  82822. private _dummyVector2;
  82823. private _downCount;
  82824. private _enterCount;
  82825. private _doNotRender;
  82826. private _downPointerIds;
  82827. protected _isEnabled: boolean;
  82828. protected _disabledColor: string;
  82829. protected _disabledColorItem: string;
  82830. /** @hidden */
  82831. protected _rebuildLayout: boolean;
  82832. /** @hidden */
  82833. _customData: any;
  82834. /** @hidden */
  82835. _isClipped: boolean;
  82836. /** @hidden */
  82837. _automaticSize: boolean;
  82838. /** @hidden */
  82839. _tag: any;
  82840. /**
  82841. * 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
  82842. */
  82843. uniqueId: number;
  82844. /**
  82845. * Gets or sets an object used to store user defined information for the node
  82846. */
  82847. metadata: any;
  82848. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  82849. isHitTestVisible: boolean;
  82850. /** Gets or sets a boolean indicating if the control can block pointer events */
  82851. isPointerBlocker: boolean;
  82852. /** Gets or sets a boolean indicating if the control can be focusable */
  82853. isFocusInvisible: boolean;
  82854. /**
  82855. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  82856. * 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
  82857. */
  82858. clipChildren: boolean;
  82859. /**
  82860. * Gets or sets a boolean indicating that control content must be clipped
  82861. * 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
  82862. */
  82863. clipContent: boolean;
  82864. /**
  82865. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  82866. */
  82867. useBitmapCache: boolean;
  82868. private _cacheData;
  82869. private _shadowOffsetX;
  82870. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  82871. get shadowOffsetX(): number;
  82872. set shadowOffsetX(value: number);
  82873. private _shadowOffsetY;
  82874. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  82875. get shadowOffsetY(): number;
  82876. set shadowOffsetY(value: number);
  82877. private _shadowBlur;
  82878. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  82879. get shadowBlur(): number;
  82880. set shadowBlur(value: number);
  82881. private _shadowColor;
  82882. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  82883. get shadowColor(): string;
  82884. set shadowColor(value: string);
  82885. /** Gets or sets the cursor to use when the control is hovered */
  82886. hoverCursor: string;
  82887. /** @hidden */
  82888. protected _linkOffsetX: ValueAndUnit;
  82889. /** @hidden */
  82890. protected _linkOffsetY: ValueAndUnit;
  82891. /** Gets the control type name */
  82892. get typeName(): string;
  82893. /**
  82894. * Get the current class name of the control.
  82895. * @returns current class name
  82896. */
  82897. getClassName(): string;
  82898. /**
  82899. * An event triggered when pointer wheel is scrolled
  82900. */
  82901. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  82902. /**
  82903. * An event triggered when the pointer move over the control.
  82904. */
  82905. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  82906. /**
  82907. * An event triggered when the pointer move out of the control.
  82908. */
  82909. onPointerOutObservable: BABYLON.Observable<Control>;
  82910. /**
  82911. * An event triggered when the pointer taps the control
  82912. */
  82913. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  82914. /**
  82915. * An event triggered when pointer up
  82916. */
  82917. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  82918. /**
  82919. * An event triggered when a control is clicked on
  82920. */
  82921. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  82922. /**
  82923. * An event triggered when pointer enters the control
  82924. */
  82925. onPointerEnterObservable: BABYLON.Observable<Control>;
  82926. /**
  82927. * An event triggered when the control is marked as dirty
  82928. */
  82929. onDirtyObservable: BABYLON.Observable<Control>;
  82930. /**
  82931. * An event triggered before drawing the control
  82932. */
  82933. onBeforeDrawObservable: BABYLON.Observable<Control>;
  82934. /**
  82935. * An event triggered after the control was drawn
  82936. */
  82937. onAfterDrawObservable: BABYLON.Observable<Control>;
  82938. /**
  82939. * An event triggered when the control has been disposed
  82940. */
  82941. onDisposeObservable: BABYLON.Observable<Control>;
  82942. /**
  82943. * Get the hosting AdvancedDynamicTexture
  82944. */
  82945. get host(): AdvancedDynamicTexture;
  82946. /** Gets or set information about font offsets (used to render and align text) */
  82947. get fontOffset(): {
  82948. ascent: number;
  82949. height: number;
  82950. descent: number;
  82951. };
  82952. set fontOffset(offset: {
  82953. ascent: number;
  82954. height: number;
  82955. descent: number;
  82956. });
  82957. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  82958. get alpha(): number;
  82959. set alpha(value: number);
  82960. /**
  82961. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  82962. */
  82963. get isHighlighted(): boolean;
  82964. set isHighlighted(value: boolean);
  82965. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  82966. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82967. */
  82968. get scaleX(): number;
  82969. set scaleX(value: number);
  82970. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  82971. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82972. */
  82973. get scaleY(): number;
  82974. set scaleY(value: number);
  82975. /** Gets or sets the rotation angle (0 by default)
  82976. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82977. */
  82978. get rotation(): number;
  82979. set rotation(value: number);
  82980. /** Gets or sets the transformation center on Y axis (0 by default)
  82981. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82982. */
  82983. get transformCenterY(): number;
  82984. set transformCenterY(value: number);
  82985. /** Gets or sets the transformation center on X axis (0 by default)
  82986. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82987. */
  82988. get transformCenterX(): number;
  82989. set transformCenterX(value: number);
  82990. /**
  82991. * Gets or sets the horizontal alignment
  82992. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82993. */
  82994. get horizontalAlignment(): number;
  82995. set horizontalAlignment(value: number);
  82996. /**
  82997. * Gets or sets the vertical alignment
  82998. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82999. */
  83000. get verticalAlignment(): number;
  83001. set verticalAlignment(value: number);
  83002. /**
  83003. * Gets or sets a fixed ratio for this control.
  83004. * When different from 0, the ratio is used to compute the "second" dimension.
  83005. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83006. * second dimension is computed as first dimension * fixedRatio
  83007. */
  83008. fixedRatio: number;
  83009. private _fixedRatioMasterIsWidth;
  83010. /**
  83011. * Gets or sets control width
  83012. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83013. */
  83014. get width(): string | number;
  83015. set width(value: string | number);
  83016. /**
  83017. * Gets or sets the control width in pixel
  83018. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83019. */
  83020. get widthInPixels(): number;
  83021. set widthInPixels(value: number);
  83022. /**
  83023. * Gets or sets control height
  83024. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83025. */
  83026. get height(): string | number;
  83027. set height(value: string | number);
  83028. /**
  83029. * Gets or sets control height in pixel
  83030. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83031. */
  83032. get heightInPixels(): number;
  83033. set heightInPixels(value: number);
  83034. /** Gets or set font family */
  83035. get fontFamily(): string;
  83036. set fontFamily(value: string);
  83037. /** Gets or sets font style */
  83038. get fontStyle(): string;
  83039. set fontStyle(value: string);
  83040. /** Gets or sets font weight */
  83041. get fontWeight(): string;
  83042. set fontWeight(value: string);
  83043. /**
  83044. * Gets or sets style
  83045. * @see https://doc.babylonjs.com/how_to/gui#styles
  83046. */
  83047. get style(): BABYLON.Nullable<Style>;
  83048. set style(value: BABYLON.Nullable<Style>);
  83049. /** @hidden */
  83050. get _isFontSizeInPercentage(): boolean;
  83051. /** Gets or sets font size in pixels */
  83052. get fontSizeInPixels(): number;
  83053. set fontSizeInPixels(value: number);
  83054. /** Gets or sets font size */
  83055. get fontSize(): string | number;
  83056. set fontSize(value: string | number);
  83057. /** Gets or sets foreground color */
  83058. get color(): string;
  83059. set color(value: string);
  83060. /** Gets or sets z index which is used to reorder controls on the z axis */
  83061. get zIndex(): number;
  83062. set zIndex(value: number);
  83063. /** Gets or sets a boolean indicating if the control can be rendered */
  83064. get notRenderable(): boolean;
  83065. set notRenderable(value: boolean);
  83066. /** Gets or sets a boolean indicating if the control is visible */
  83067. get isVisible(): boolean;
  83068. set isVisible(value: boolean);
  83069. /** Gets a boolean indicating that the control needs to update its rendering */
  83070. get isDirty(): boolean;
  83071. /**
  83072. * Gets the current linked mesh (or null if none)
  83073. */
  83074. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  83075. /**
  83076. * Gets or sets a value indicating the padding to use on the left of the control
  83077. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83078. */
  83079. get paddingLeft(): string | number;
  83080. set paddingLeft(value: string | number);
  83081. /**
  83082. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83083. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83084. */
  83085. get paddingLeftInPixels(): number;
  83086. set paddingLeftInPixels(value: number);
  83087. /**
  83088. * Gets or sets a value indicating the padding to use on the right of the control
  83089. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83090. */
  83091. get paddingRight(): string | number;
  83092. set paddingRight(value: string | number);
  83093. /**
  83094. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83095. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83096. */
  83097. get paddingRightInPixels(): number;
  83098. set paddingRightInPixels(value: number);
  83099. /**
  83100. * Gets or sets a value indicating the padding to use on the top of the control
  83101. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83102. */
  83103. get paddingTop(): string | number;
  83104. set paddingTop(value: string | number);
  83105. /**
  83106. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83107. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83108. */
  83109. get paddingTopInPixels(): number;
  83110. set paddingTopInPixels(value: number);
  83111. /**
  83112. * Gets or sets a value indicating the padding to use on the bottom of the control
  83113. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83114. */
  83115. get paddingBottom(): string | number;
  83116. set paddingBottom(value: string | number);
  83117. /**
  83118. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83119. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83120. */
  83121. get paddingBottomInPixels(): number;
  83122. set paddingBottomInPixels(value: number);
  83123. /**
  83124. * Gets or sets a value indicating the left coordinate of the control
  83125. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83126. */
  83127. get left(): string | number;
  83128. set left(value: string | number);
  83129. /**
  83130. * Gets or sets a value indicating the left coordinate in pixels of the control
  83131. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83132. */
  83133. get leftInPixels(): number;
  83134. set leftInPixels(value: number);
  83135. /**
  83136. * Gets or sets a value indicating the top coordinate of the control
  83137. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83138. */
  83139. get top(): string | number;
  83140. set top(value: string | number);
  83141. /**
  83142. * Gets or sets a value indicating the top coordinate in pixels of the control
  83143. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83144. */
  83145. get topInPixels(): number;
  83146. set topInPixels(value: number);
  83147. /**
  83148. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83149. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83150. */
  83151. get linkOffsetX(): string | number;
  83152. set linkOffsetX(value: string | number);
  83153. /**
  83154. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83155. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83156. */
  83157. get linkOffsetXInPixels(): number;
  83158. set linkOffsetXInPixels(value: number);
  83159. /**
  83160. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83161. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83162. */
  83163. get linkOffsetY(): string | number;
  83164. set linkOffsetY(value: string | number);
  83165. /**
  83166. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83167. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83168. */
  83169. get linkOffsetYInPixels(): number;
  83170. set linkOffsetYInPixels(value: number);
  83171. /** Gets the center coordinate on X axis */
  83172. get centerX(): number;
  83173. /** Gets the center coordinate on Y axis */
  83174. get centerY(): number;
  83175. /** Gets or sets if control is Enabled */
  83176. get isEnabled(): boolean;
  83177. set isEnabled(value: boolean);
  83178. /** Gets or sets background color of control if it's disabled */
  83179. get disabledColor(): string;
  83180. set disabledColor(value: string);
  83181. /** Gets or sets front color of control if it's disabled */
  83182. get disabledColorItem(): string;
  83183. set disabledColorItem(value: string);
  83184. /**
  83185. * Creates a new control
  83186. * @param name defines the name of the control
  83187. */
  83188. constructor(
  83189. /** defines the name of the control */
  83190. name?: string | undefined);
  83191. /** @hidden */
  83192. protected _getTypeName(): string;
  83193. /**
  83194. * Gets the first ascendant in the hierarchy of the given type
  83195. * @param className defines the required type
  83196. * @returns the ascendant or null if not found
  83197. */
  83198. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83199. /** @hidden */
  83200. _resetFontCache(): void;
  83201. /**
  83202. * Determines if a container is an ascendant of the current control
  83203. * @param container defines the container to look for
  83204. * @returns true if the container is one of the ascendant of the control
  83205. */
  83206. isAscendant(container: Control): boolean;
  83207. /**
  83208. * Gets coordinates in local control space
  83209. * @param globalCoordinates defines the coordinates to transform
  83210. * @returns the new coordinates in local space
  83211. */
  83212. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83213. /**
  83214. * Gets coordinates in local control space
  83215. * @param globalCoordinates defines the coordinates to transform
  83216. * @param result defines the target vector2 where to store the result
  83217. * @returns the current control
  83218. */
  83219. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83220. /**
  83221. * Gets coordinates in parent local control space
  83222. * @param globalCoordinates defines the coordinates to transform
  83223. * @returns the new coordinates in parent local space
  83224. */
  83225. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83226. /**
  83227. * Move the current control to a vector3 position projected onto the screen.
  83228. * @param position defines the target position
  83229. * @param scene defines the hosting scene
  83230. */
  83231. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83232. /**
  83233. * Will store all controls that have this control as ascendant in a given array
  83234. * @param results defines the array where to store the descendants
  83235. * @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
  83236. * @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
  83237. */
  83238. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83239. /**
  83240. * Will return all controls that have this control as ascendant
  83241. * @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
  83242. * @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
  83243. * @return all child controls
  83244. */
  83245. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83246. /**
  83247. * Link current control with a target mesh
  83248. * @param mesh defines the mesh to link with
  83249. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83250. */
  83251. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83252. /**
  83253. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83254. * @param { string | number} paddingTop - The value of the top padding.
  83255. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83256. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83257. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83258. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83259. */
  83260. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83261. /**
  83262. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83263. * @param { number} paddingTop - The value in pixels of the top padding.
  83264. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83265. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83266. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83267. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83268. */
  83269. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83270. /** @hidden */
  83271. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83272. /** @hidden */
  83273. _offsetLeft(offset: number): void;
  83274. /** @hidden */
  83275. _offsetTop(offset: number): void;
  83276. /** @hidden */
  83277. _markMatrixAsDirty(): void;
  83278. /** @hidden */
  83279. _flagDescendantsAsMatrixDirty(): void;
  83280. /** @hidden */
  83281. _intersectsRect(rect: Measure): boolean;
  83282. /** @hidden */
  83283. protected invalidateRect(): void;
  83284. /** @hidden */
  83285. _markAsDirty(force?: boolean): void;
  83286. /** @hidden */
  83287. _markAllAsDirty(): void;
  83288. /** @hidden */
  83289. _link(host: AdvancedDynamicTexture): void;
  83290. /** @hidden */
  83291. protected _transform(context?: CanvasRenderingContext2D): void;
  83292. /** @hidden */
  83293. _renderHighlight(context: CanvasRenderingContext2D): void;
  83294. /** @hidden */
  83295. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83296. /** @hidden */
  83297. protected _applyStates(context: CanvasRenderingContext2D): void;
  83298. /** @hidden */
  83299. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83300. /** @hidden */
  83301. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83302. protected _evaluateClippingState(parentMeasure: Measure): void;
  83303. /** @hidden */
  83304. _measure(): void;
  83305. /** @hidden */
  83306. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83307. /** @hidden */
  83308. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83309. /** @hidden */
  83310. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83311. /** @hidden */
  83312. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83313. private static _ClipMeasure;
  83314. private _tmpMeasureA;
  83315. private _clip;
  83316. /** @hidden */
  83317. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83318. /** @hidden */
  83319. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83320. /**
  83321. * Tests if a given coordinates belong to the current control
  83322. * @param x defines x coordinate to test
  83323. * @param y defines y coordinate to test
  83324. * @returns true if the coordinates are inside the control
  83325. */
  83326. contains(x: number, y: number): boolean;
  83327. /** @hidden */
  83328. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83329. /** @hidden */
  83330. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83331. /** @hidden */
  83332. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83333. /** @hidden */
  83334. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83335. /** @hidden */
  83336. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83337. /** @hidden */
  83338. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83339. /** @hidden */
  83340. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83341. /** @hidden */
  83342. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83343. /** @hidden */
  83344. _onCanvasBlur(): void;
  83345. /** @hidden */
  83346. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83347. private _prepareFont;
  83348. /**
  83349. * Serializes the current control
  83350. * @param serializationObject defined the JSON serialized object
  83351. */
  83352. serialize(serializationObject: any): void;
  83353. /** @hidden */
  83354. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83355. /** Releases associated resources */
  83356. dispose(): void;
  83357. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83358. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83359. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83360. private static _VERTICAL_ALIGNMENT_TOP;
  83361. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83362. private static _VERTICAL_ALIGNMENT_CENTER;
  83363. /** HORIZONTAL_ALIGNMENT_LEFT */
  83364. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83365. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83366. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83367. /** HORIZONTAL_ALIGNMENT_CENTER */
  83368. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83369. /** VERTICAL_ALIGNMENT_TOP */
  83370. static get VERTICAL_ALIGNMENT_TOP(): number;
  83371. /** VERTICAL_ALIGNMENT_BOTTOM */
  83372. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83373. /** VERTICAL_ALIGNMENT_CENTER */
  83374. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83375. private static _FontHeightSizes;
  83376. /** @hidden */
  83377. static _GetFontOffset(font: string): {
  83378. ascent: number;
  83379. height: number;
  83380. descent: number;
  83381. };
  83382. /**
  83383. * Creates a Control from parsed data
  83384. * @param serializedObject defines parsed data
  83385. * @param host defines the hosting AdvancedDynamicTexture
  83386. * @returns a new Control
  83387. */
  83388. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83389. /**
  83390. * Creates a stack panel that can be used to render headers
  83391. * @param control defines the control to associate with the header
  83392. * @param text defines the text of the header
  83393. * @param size defines the size of the header
  83394. * @param options defines options used to configure the header
  83395. * @returns a new StackPanel
  83396. * @ignore
  83397. * @hidden
  83398. */
  83399. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83400. isHorizontal: boolean;
  83401. controlFirst: boolean;
  83402. }) => any;
  83403. /** @hidden */
  83404. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83405. }
  83406. }
  83407. declare module BABYLON.GUI {
  83408. /**
  83409. * Root class for 2D containers
  83410. * @see https://doc.babylonjs.com/how_to/gui#containers
  83411. */
  83412. export class Container extends Control {
  83413. name?: string | undefined;
  83414. /** @hidden */
  83415. _children: Control[];
  83416. /** @hidden */
  83417. protected _measureForChildren: Measure;
  83418. /** @hidden */
  83419. protected _background: string;
  83420. /** @hidden */
  83421. protected _adaptWidthToChildren: boolean;
  83422. /** @hidden */
  83423. protected _adaptHeightToChildren: boolean;
  83424. /**
  83425. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83426. */
  83427. logLayoutCycleErrors: boolean;
  83428. /**
  83429. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83430. */
  83431. maxLayoutCycle: number;
  83432. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83433. get adaptHeightToChildren(): boolean;
  83434. set adaptHeightToChildren(value: boolean);
  83435. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83436. get adaptWidthToChildren(): boolean;
  83437. set adaptWidthToChildren(value: boolean);
  83438. /** Gets or sets background color */
  83439. get background(): string;
  83440. set background(value: string);
  83441. /** Gets the list of children */
  83442. get children(): Control[];
  83443. /**
  83444. * Creates a new Container
  83445. * @param name defines the name of the container
  83446. */
  83447. constructor(name?: string | undefined);
  83448. protected _getTypeName(): string;
  83449. _flagDescendantsAsMatrixDirty(): void;
  83450. /**
  83451. * Gets a child using its name
  83452. * @param name defines the child name to look for
  83453. * @returns the child control if found
  83454. */
  83455. getChildByName(name: string): BABYLON.Nullable<Control>;
  83456. /**
  83457. * Gets a child using its type and its name
  83458. * @param name defines the child name to look for
  83459. * @param type defines the child type to look for
  83460. * @returns the child control if found
  83461. */
  83462. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83463. /**
  83464. * Search for a specific control in children
  83465. * @param control defines the control to look for
  83466. * @returns true if the control is in child list
  83467. */
  83468. containsControl(control: Control): boolean;
  83469. /**
  83470. * Adds a new control to the current container
  83471. * @param control defines the control to add
  83472. * @returns the current container
  83473. */
  83474. addControl(control: BABYLON.Nullable<Control>): Container;
  83475. /**
  83476. * Removes all controls from the current container
  83477. * @returns the current container
  83478. */
  83479. clearControls(): Container;
  83480. /**
  83481. * Removes a control from the current container
  83482. * @param control defines the control to remove
  83483. * @returns the current container
  83484. */
  83485. removeControl(control: Control): Container;
  83486. /** @hidden */
  83487. _reOrderControl(control: Control): void;
  83488. /** @hidden */
  83489. _offsetLeft(offset: number): void;
  83490. /** @hidden */
  83491. _offsetTop(offset: number): void;
  83492. /** @hidden */
  83493. _markAllAsDirty(): void;
  83494. /** @hidden */
  83495. protected _localDraw(context: CanvasRenderingContext2D): void;
  83496. /** @hidden */
  83497. _link(host: AdvancedDynamicTexture): void;
  83498. /** @hidden */
  83499. protected _beforeLayout(): void;
  83500. /** @hidden */
  83501. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83502. /** @hidden */
  83503. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83504. protected _postMeasure(): void;
  83505. /** @hidden */
  83506. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83507. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83508. /** @hidden */
  83509. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83510. /** @hidden */
  83511. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83512. /**
  83513. * Serializes the current control
  83514. * @param serializationObject defined the JSON serialized object
  83515. */
  83516. serialize(serializationObject: any): void;
  83517. /** Releases associated resources */
  83518. dispose(): void;
  83519. /** @hidden */
  83520. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83521. }
  83522. }
  83523. declare module BABYLON.GUI {
  83524. /** Class used to create rectangle container */
  83525. export class Rectangle extends Container {
  83526. name?: string | undefined;
  83527. private _thickness;
  83528. private _cornerRadius;
  83529. /** Gets or sets border thickness */
  83530. get thickness(): number;
  83531. set thickness(value: number);
  83532. /** Gets or sets the corner radius angle */
  83533. get cornerRadius(): number;
  83534. set cornerRadius(value: number);
  83535. /**
  83536. * Creates a new Rectangle
  83537. * @param name defines the control name
  83538. */
  83539. constructor(name?: string | undefined);
  83540. protected _getTypeName(): string;
  83541. protected _localDraw(context: CanvasRenderingContext2D): void;
  83542. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83543. private _drawRoundedRect;
  83544. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83545. }
  83546. }
  83547. declare module BABYLON.GUI {
  83548. /**
  83549. * Enum that determines the text-wrapping mode to use.
  83550. */
  83551. export enum TextWrapping {
  83552. /**
  83553. * Clip the text when it's larger than Control.width; this is the default mode.
  83554. */
  83555. Clip = 0,
  83556. /**
  83557. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83558. */
  83559. WordWrap = 1,
  83560. /**
  83561. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83562. */
  83563. Ellipsis = 2
  83564. }
  83565. /**
  83566. * Class used to create text block control
  83567. */
  83568. export class TextBlock extends Control {
  83569. /**
  83570. * Defines the name of the control
  83571. */
  83572. name?: string | undefined;
  83573. private _text;
  83574. private _textWrapping;
  83575. private _textHorizontalAlignment;
  83576. private _textVerticalAlignment;
  83577. private _lines;
  83578. private _resizeToFit;
  83579. private _lineSpacing;
  83580. private _outlineWidth;
  83581. private _outlineColor;
  83582. private _underline;
  83583. private _lineThrough;
  83584. /**
  83585. * An event triggered after the text is changed
  83586. */
  83587. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83588. /**
  83589. * An event triggered after the text was broken up into lines
  83590. */
  83591. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83592. /**
  83593. * Function used to split a string into words. By default, a string is split at each space character found
  83594. */
  83595. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  83596. /**
  83597. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  83598. */
  83599. get lines(): any[];
  83600. /**
  83601. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83602. */
  83603. get resizeToFit(): boolean;
  83604. /**
  83605. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83606. */
  83607. set resizeToFit(value: boolean);
  83608. /**
  83609. * Gets or sets a boolean indicating if text must be wrapped
  83610. */
  83611. get textWrapping(): TextWrapping | boolean;
  83612. /**
  83613. * Gets or sets a boolean indicating if text must be wrapped
  83614. */
  83615. set textWrapping(value: TextWrapping | boolean);
  83616. /**
  83617. * Gets or sets text to display
  83618. */
  83619. get text(): string;
  83620. /**
  83621. * Gets or sets text to display
  83622. */
  83623. set text(value: string);
  83624. /**
  83625. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83626. */
  83627. get textHorizontalAlignment(): number;
  83628. /**
  83629. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83630. */
  83631. set textHorizontalAlignment(value: number);
  83632. /**
  83633. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83634. */
  83635. get textVerticalAlignment(): number;
  83636. /**
  83637. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83638. */
  83639. set textVerticalAlignment(value: number);
  83640. /**
  83641. * Gets or sets line spacing value
  83642. */
  83643. set lineSpacing(value: string | number);
  83644. /**
  83645. * Gets or sets line spacing value
  83646. */
  83647. get lineSpacing(): string | number;
  83648. /**
  83649. * Gets or sets outlineWidth of the text to display
  83650. */
  83651. get outlineWidth(): number;
  83652. /**
  83653. * Gets or sets outlineWidth of the text to display
  83654. */
  83655. set outlineWidth(value: number);
  83656. /**
  83657. * Gets or sets a boolean indicating that text must have underline
  83658. */
  83659. get underline(): boolean;
  83660. /**
  83661. * Gets or sets a boolean indicating that text must have underline
  83662. */
  83663. set underline(value: boolean);
  83664. /**
  83665. * Gets or sets an boolean indicating that text must be crossed out
  83666. */
  83667. get lineThrough(): boolean;
  83668. /**
  83669. * Gets or sets an boolean indicating that text must be crossed out
  83670. */
  83671. set lineThrough(value: boolean);
  83672. /**
  83673. * Gets or sets outlineColor of the text to display
  83674. */
  83675. get outlineColor(): string;
  83676. /**
  83677. * Gets or sets outlineColor of the text to display
  83678. */
  83679. set outlineColor(value: string);
  83680. /**
  83681. * Creates a new TextBlock object
  83682. * @param name defines the name of the control
  83683. * @param text defines the text to display (emptry string by default)
  83684. */
  83685. constructor(
  83686. /**
  83687. * Defines the name of the control
  83688. */
  83689. name?: string | undefined, text?: string);
  83690. protected _getTypeName(): string;
  83691. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83692. private _drawText;
  83693. /** @hidden */
  83694. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83695. protected _applyStates(context: CanvasRenderingContext2D): void;
  83696. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  83697. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  83698. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  83699. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  83700. protected _renderLines(context: CanvasRenderingContext2D): void;
  83701. /**
  83702. * Given a width constraint applied on the text block, find the expected height
  83703. * @returns expected height
  83704. */
  83705. computeExpectedHeight(): number;
  83706. dispose(): void;
  83707. }
  83708. }
  83709. declare module BABYLON.GUI {
  83710. /**
  83711. * Class used to create 2D images
  83712. */
  83713. export class Image extends Control {
  83714. name?: string | undefined;
  83715. private _workingCanvas;
  83716. private _domImage;
  83717. private _imageWidth;
  83718. private _imageHeight;
  83719. private _loaded;
  83720. private _stretch;
  83721. private _source;
  83722. private _autoScale;
  83723. private _sourceLeft;
  83724. private _sourceTop;
  83725. private _sourceWidth;
  83726. private _sourceHeight;
  83727. private _svgAttributesComputationCompleted;
  83728. private _isSVG;
  83729. private _cellWidth;
  83730. private _cellHeight;
  83731. private _cellId;
  83732. private _populateNinePatchSlicesFromImage;
  83733. private _sliceLeft;
  83734. private _sliceRight;
  83735. private _sliceTop;
  83736. private _sliceBottom;
  83737. private _detectPointerOnOpaqueOnly;
  83738. private _imageDataCache;
  83739. /**
  83740. * BABYLON.Observable notified when the content is loaded
  83741. */
  83742. onImageLoadedObservable: BABYLON.Observable<Image>;
  83743. /**
  83744. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  83745. */
  83746. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  83747. /**
  83748. * Gets a boolean indicating that the content is loaded
  83749. */
  83750. get isLoaded(): boolean;
  83751. /**
  83752. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  83753. */
  83754. get populateNinePatchSlicesFromImage(): boolean;
  83755. set populateNinePatchSlicesFromImage(value: boolean);
  83756. /**
  83757. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  83758. * Beware using this as this will comsume more memory as the image has to be stored twice
  83759. */
  83760. get detectPointerOnOpaqueOnly(): boolean;
  83761. set detectPointerOnOpaqueOnly(value: boolean);
  83762. /**
  83763. * Gets or sets the left value for slicing (9-patch)
  83764. */
  83765. get sliceLeft(): number;
  83766. set sliceLeft(value: number);
  83767. /**
  83768. * Gets or sets the right value for slicing (9-patch)
  83769. */
  83770. get sliceRight(): number;
  83771. set sliceRight(value: number);
  83772. /**
  83773. * Gets or sets the top value for slicing (9-patch)
  83774. */
  83775. get sliceTop(): number;
  83776. set sliceTop(value: number);
  83777. /**
  83778. * Gets or sets the bottom value for slicing (9-patch)
  83779. */
  83780. get sliceBottom(): number;
  83781. set sliceBottom(value: number);
  83782. /**
  83783. * Gets or sets the left coordinate in the source image
  83784. */
  83785. get sourceLeft(): number;
  83786. set sourceLeft(value: number);
  83787. /**
  83788. * Gets or sets the top coordinate in the source image
  83789. */
  83790. get sourceTop(): number;
  83791. set sourceTop(value: number);
  83792. /**
  83793. * Gets or sets the width to capture in the source image
  83794. */
  83795. get sourceWidth(): number;
  83796. set sourceWidth(value: number);
  83797. /**
  83798. * Gets or sets the height to capture in the source image
  83799. */
  83800. get sourceHeight(): number;
  83801. set sourceHeight(value: number);
  83802. /** Indicates if the format of the image is SVG */
  83803. get isSVG(): boolean;
  83804. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  83805. get svgAttributesComputationCompleted(): boolean;
  83806. /**
  83807. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  83808. * @see https://doc.babylonjs.com/how_to/gui#image
  83809. */
  83810. get autoScale(): boolean;
  83811. set autoScale(value: boolean);
  83812. /** Gets or sets the streching mode used by the image */
  83813. get stretch(): number;
  83814. set stretch(value: number);
  83815. /** @hidden */
  83816. _rotate90(n: number, preserveProperties?: boolean): Image;
  83817. private _handleRotationForSVGImage;
  83818. private _rotate90SourceProperties;
  83819. /**
  83820. * Gets or sets the internal DOM image used to render the control
  83821. */
  83822. set domImage(value: HTMLImageElement);
  83823. get domImage(): HTMLImageElement;
  83824. private _onImageLoaded;
  83825. private _extractNinePatchSliceDataFromImage;
  83826. /**
  83827. * Gets the image source url
  83828. */
  83829. get source(): BABYLON.Nullable<string>;
  83830. /**
  83831. * Gets or sets image source url
  83832. */
  83833. set source(value: BABYLON.Nullable<string>);
  83834. /**
  83835. * Checks for svg document with icon id present
  83836. */
  83837. private _svgCheck;
  83838. /**
  83839. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  83840. * given external svg file and icon id
  83841. */
  83842. private _getSVGAttribs;
  83843. /**
  83844. * Gets or sets the cell width to use when animation sheet is enabled
  83845. * @see https://doc.babylonjs.com/how_to/gui#image
  83846. */
  83847. get cellWidth(): number;
  83848. set cellWidth(value: number);
  83849. /**
  83850. * Gets or sets the cell height to use when animation sheet is enabled
  83851. * @see https://doc.babylonjs.com/how_to/gui#image
  83852. */
  83853. get cellHeight(): number;
  83854. set cellHeight(value: number);
  83855. /**
  83856. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  83857. * @see https://doc.babylonjs.com/how_to/gui#image
  83858. */
  83859. get cellId(): number;
  83860. set cellId(value: number);
  83861. /**
  83862. * Creates a new Image
  83863. * @param name defines the control name
  83864. * @param url defines the image url
  83865. */
  83866. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  83867. /**
  83868. * Tests if a given coordinates belong to the current control
  83869. * @param x defines x coordinate to test
  83870. * @param y defines y coordinate to test
  83871. * @returns true if the coordinates are inside the control
  83872. */
  83873. contains(x: number, y: number): boolean;
  83874. protected _getTypeName(): string;
  83875. /** Force the control to synchronize with its content */
  83876. synchronizeSizeWithContent(): void;
  83877. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83878. private _prepareWorkingCanvasForOpaqueDetection;
  83879. private _drawImage;
  83880. _draw(context: CanvasRenderingContext2D): void;
  83881. private _renderCornerPatch;
  83882. private _renderNinePatch;
  83883. dispose(): void;
  83884. /** STRETCH_NONE */
  83885. static readonly STRETCH_NONE: number;
  83886. /** STRETCH_FILL */
  83887. static readonly STRETCH_FILL: number;
  83888. /** STRETCH_UNIFORM */
  83889. static readonly STRETCH_UNIFORM: number;
  83890. /** STRETCH_EXTEND */
  83891. static readonly STRETCH_EXTEND: number;
  83892. /** NINE_PATCH */
  83893. static readonly STRETCH_NINE_PATCH: number;
  83894. }
  83895. }
  83896. declare module BABYLON.GUI {
  83897. /**
  83898. * Class used to create 2D buttons
  83899. */
  83900. export class Button extends Rectangle {
  83901. name?: string | undefined;
  83902. /**
  83903. * Function called to generate a pointer enter animation
  83904. */
  83905. pointerEnterAnimation: () => void;
  83906. /**
  83907. * Function called to generate a pointer out animation
  83908. */
  83909. pointerOutAnimation: () => void;
  83910. /**
  83911. * Function called to generate a pointer down animation
  83912. */
  83913. pointerDownAnimation: () => void;
  83914. /**
  83915. * Function called to generate a pointer up animation
  83916. */
  83917. pointerUpAnimation: () => void;
  83918. /**
  83919. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  83920. */
  83921. delegatePickingToChildren: boolean;
  83922. private _image;
  83923. /**
  83924. * Returns the image part of the button (if any)
  83925. */
  83926. get image(): BABYLON.Nullable<Image>;
  83927. private _textBlock;
  83928. /**
  83929. * Returns the image part of the button (if any)
  83930. */
  83931. get textBlock(): BABYLON.Nullable<TextBlock>;
  83932. /**
  83933. * Creates a new Button
  83934. * @param name defines the name of the button
  83935. */
  83936. constructor(name?: string | undefined);
  83937. protected _getTypeName(): string;
  83938. /** @hidden */
  83939. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83940. /** @hidden */
  83941. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83942. /** @hidden */
  83943. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  83944. /** @hidden */
  83945. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83946. /** @hidden */
  83947. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  83948. /**
  83949. * Creates a new button made with an image and a text
  83950. * @param name defines the name of the button
  83951. * @param text defines the text of the button
  83952. * @param imageUrl defines the url of the image
  83953. * @returns a new Button
  83954. */
  83955. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  83956. /**
  83957. * Creates a new button made with an image
  83958. * @param name defines the name of the button
  83959. * @param imageUrl defines the url of the image
  83960. * @returns a new Button
  83961. */
  83962. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  83963. /**
  83964. * Creates a new button made with a text
  83965. * @param name defines the name of the button
  83966. * @param text defines the text of the button
  83967. * @returns a new Button
  83968. */
  83969. static CreateSimpleButton(name: string, text: string): Button;
  83970. /**
  83971. * Creates a new button made with an image and a centered text
  83972. * @param name defines the name of the button
  83973. * @param text defines the text of the button
  83974. * @param imageUrl defines the url of the image
  83975. * @returns a new Button
  83976. */
  83977. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  83978. }
  83979. }
  83980. declare module BABYLON.GUI {
  83981. /**
  83982. * Class used to create a 2D stack panel container
  83983. */
  83984. export class StackPanel extends Container {
  83985. name?: string | undefined;
  83986. private _isVertical;
  83987. private _manualWidth;
  83988. private _manualHeight;
  83989. private _doNotTrackManualChanges;
  83990. /**
  83991. * Gets or sets a boolean indicating that layou warnings should be ignored
  83992. */
  83993. ignoreLayoutWarnings: boolean;
  83994. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  83995. get isVertical(): boolean;
  83996. set isVertical(value: boolean);
  83997. /**
  83998. * Gets or sets panel width.
  83999. * This value should not be set when in horizontal mode as it will be computed automatically
  84000. */
  84001. set width(value: string | number);
  84002. get width(): string | number;
  84003. /**
  84004. * Gets or sets panel height.
  84005. * This value should not be set when in vertical mode as it will be computed automatically
  84006. */
  84007. set height(value: string | number);
  84008. get height(): string | number;
  84009. /**
  84010. * Creates a new StackPanel
  84011. * @param name defines control name
  84012. */
  84013. constructor(name?: string | undefined);
  84014. protected _getTypeName(): string;
  84015. /** @hidden */
  84016. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84017. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84018. protected _postMeasure(): void;
  84019. /**
  84020. * Serializes the current control
  84021. * @param serializationObject defined the JSON serialized object
  84022. */
  84023. serialize(serializationObject: any): void;
  84024. /** @hidden */
  84025. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84026. }
  84027. }
  84028. declare module BABYLON.GUI {
  84029. /**
  84030. * Class used to represent a 2D checkbox
  84031. */
  84032. export class Checkbox extends Control {
  84033. name?: string | undefined;
  84034. private _isChecked;
  84035. private _background;
  84036. private _checkSizeRatio;
  84037. private _thickness;
  84038. /** Gets or sets border thickness */
  84039. get thickness(): number;
  84040. set thickness(value: number);
  84041. /**
  84042. * BABYLON.Observable raised when isChecked property changes
  84043. */
  84044. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84045. /** Gets or sets a value indicating the ratio between overall size and check size */
  84046. get checkSizeRatio(): number;
  84047. set checkSizeRatio(value: number);
  84048. /** Gets or sets background color */
  84049. get background(): string;
  84050. set background(value: string);
  84051. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84052. get isChecked(): boolean;
  84053. set isChecked(value: boolean);
  84054. /**
  84055. * Creates a new CheckBox
  84056. * @param name defines the control name
  84057. */
  84058. constructor(name?: string | undefined);
  84059. protected _getTypeName(): string;
  84060. /** @hidden */
  84061. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84062. /** @hidden */
  84063. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84064. /**
  84065. * Utility function to easily create a checkbox with a header
  84066. * @param title defines the label to use for the header
  84067. * @param onValueChanged defines the callback to call when value changes
  84068. * @returns a StackPanel containing the checkbox and a textBlock
  84069. */
  84070. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  84071. }
  84072. }
  84073. declare module BABYLON.GUI {
  84074. /**
  84075. * Class used to store key control properties
  84076. */
  84077. export class KeyPropertySet {
  84078. /** Width */
  84079. width?: string;
  84080. /** Height */
  84081. height?: string;
  84082. /** Left padding */
  84083. paddingLeft?: string;
  84084. /** Right padding */
  84085. paddingRight?: string;
  84086. /** Top padding */
  84087. paddingTop?: string;
  84088. /** Bottom padding */
  84089. paddingBottom?: string;
  84090. /** Foreground color */
  84091. color?: string;
  84092. /** Background color */
  84093. background?: string;
  84094. }
  84095. /**
  84096. * Class used to create virtual keyboard
  84097. */
  84098. export class VirtualKeyboard extends StackPanel {
  84099. /** BABYLON.Observable raised when a key is pressed */
  84100. onKeyPressObservable: BABYLON.Observable<string>;
  84101. /** Gets or sets default key button width */
  84102. defaultButtonWidth: string;
  84103. /** Gets or sets default key button height */
  84104. defaultButtonHeight: string;
  84105. /** Gets or sets default key button left padding */
  84106. defaultButtonPaddingLeft: string;
  84107. /** Gets or sets default key button right padding */
  84108. defaultButtonPaddingRight: string;
  84109. /** Gets or sets default key button top padding */
  84110. defaultButtonPaddingTop: string;
  84111. /** Gets or sets default key button bottom padding */
  84112. defaultButtonPaddingBottom: string;
  84113. /** Gets or sets default key button foreground color */
  84114. defaultButtonColor: string;
  84115. /** Gets or sets default key button background color */
  84116. defaultButtonBackground: string;
  84117. /** Gets or sets shift button foreground color */
  84118. shiftButtonColor: string;
  84119. /** Gets or sets shift button thickness*/
  84120. selectedShiftThickness: number;
  84121. /** Gets shift key state */
  84122. shiftState: number;
  84123. protected _getTypeName(): string;
  84124. private _createKey;
  84125. /**
  84126. * Adds a new row of keys
  84127. * @param keys defines the list of keys to add
  84128. * @param propertySets defines the associated property sets
  84129. */
  84130. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84131. /**
  84132. * Set the shift key to a specific state
  84133. * @param shiftState defines the new shift state
  84134. */
  84135. applyShiftState(shiftState: number): void;
  84136. private _currentlyConnectedInputText;
  84137. private _connectedInputTexts;
  84138. private _onKeyPressObserver;
  84139. /** Gets the input text control currently attached to the keyboard */
  84140. get connectedInputText(): BABYLON.Nullable<InputText>;
  84141. /**
  84142. * Connects the keyboard with an input text control
  84143. *
  84144. * @param input defines the target control
  84145. */
  84146. connect(input: InputText): void;
  84147. /**
  84148. * Disconnects the keyboard from connected InputText controls
  84149. *
  84150. * @param input optionally defines a target control, otherwise all are disconnected
  84151. */
  84152. disconnect(input?: InputText): void;
  84153. private _removeConnectedInputObservables;
  84154. /**
  84155. * Release all resources
  84156. */
  84157. dispose(): void;
  84158. /**
  84159. * Creates a new keyboard using a default layout
  84160. *
  84161. * @param name defines control name
  84162. * @returns a new VirtualKeyboard
  84163. */
  84164. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84165. }
  84166. }
  84167. declare module BABYLON.GUI {
  84168. /** @hidden */
  84169. export class TextWrapper {
  84170. private _text;
  84171. private _characters;
  84172. get text(): string;
  84173. set text(txt: string);
  84174. get length(): number;
  84175. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84176. charAt(idx: number): string;
  84177. substr(from: number, length?: number): string;
  84178. substring(from: number, to?: number): string;
  84179. isWord(index: number): boolean;
  84180. }
  84181. }
  84182. declare module BABYLON.GUI {
  84183. /**
  84184. * Class used to create input text control
  84185. */
  84186. export class InputText extends Control implements IFocusableControl {
  84187. name?: string | undefined;
  84188. private _textWrapper;
  84189. private _placeholderText;
  84190. private _background;
  84191. private _focusedBackground;
  84192. private _focusedColor;
  84193. private _placeholderColor;
  84194. private _thickness;
  84195. private _margin;
  84196. private _autoStretchWidth;
  84197. private _maxWidth;
  84198. private _isFocused;
  84199. private _blinkTimeout;
  84200. private _blinkIsEven;
  84201. private _cursorOffset;
  84202. private _scrollLeft;
  84203. private _textWidth;
  84204. private _clickedCoordinate;
  84205. private _deadKey;
  84206. private _addKey;
  84207. private _currentKey;
  84208. private _isTextHighlightOn;
  84209. private _textHighlightColor;
  84210. private _highligherOpacity;
  84211. private _highlightedText;
  84212. private _startHighlightIndex;
  84213. private _endHighlightIndex;
  84214. private _cursorIndex;
  84215. private _onFocusSelectAll;
  84216. private _isPointerDown;
  84217. private _onClipboardObserver;
  84218. private _onPointerDblTapObserver;
  84219. /** @hidden */
  84220. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84221. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84222. promptMessage: string;
  84223. /** Force disable prompt on mobile device */
  84224. disableMobilePrompt: boolean;
  84225. /** BABYLON.Observable raised when the text changes */
  84226. onTextChangedObservable: BABYLON.Observable<InputText>;
  84227. /** BABYLON.Observable raised just before an entered character is to be added */
  84228. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84229. /** BABYLON.Observable raised when the control gets the focus */
  84230. onFocusObservable: BABYLON.Observable<InputText>;
  84231. /** BABYLON.Observable raised when the control loses the focus */
  84232. onBlurObservable: BABYLON.Observable<InputText>;
  84233. /**Observable raised when the text is highlighted */
  84234. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84235. /**Observable raised when copy event is triggered */
  84236. onTextCopyObservable: BABYLON.Observable<InputText>;
  84237. /** BABYLON.Observable raised when cut event is triggered */
  84238. onTextCutObservable: BABYLON.Observable<InputText>;
  84239. /** BABYLON.Observable raised when paste event is triggered */
  84240. onTextPasteObservable: BABYLON.Observable<InputText>;
  84241. /** BABYLON.Observable raised when a key event was processed */
  84242. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84243. /** Gets or sets the maximum width allowed by the control */
  84244. get maxWidth(): string | number;
  84245. /** Gets the maximum width allowed by the control in pixels */
  84246. get maxWidthInPixels(): number;
  84247. set maxWidth(value: string | number);
  84248. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84249. get highligherOpacity(): number;
  84250. set highligherOpacity(value: number);
  84251. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84252. get onFocusSelectAll(): boolean;
  84253. set onFocusSelectAll(value: boolean);
  84254. /** Gets or sets the text hightlight color */
  84255. get textHighlightColor(): string;
  84256. set textHighlightColor(value: string);
  84257. /** Gets or sets control margin */
  84258. get margin(): string;
  84259. /** Gets control margin in pixels */
  84260. get marginInPixels(): number;
  84261. set margin(value: string);
  84262. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84263. get autoStretchWidth(): boolean;
  84264. set autoStretchWidth(value: boolean);
  84265. /** Gets or sets border thickness */
  84266. get thickness(): number;
  84267. set thickness(value: number);
  84268. /** Gets or sets the background color when focused */
  84269. get focusedBackground(): string;
  84270. set focusedBackground(value: string);
  84271. /** Gets or sets the background color when focused */
  84272. get focusedColor(): string;
  84273. set focusedColor(value: string);
  84274. /** Gets or sets the background color */
  84275. get background(): string;
  84276. set background(value: string);
  84277. /** Gets or sets the placeholder color */
  84278. get placeholderColor(): string;
  84279. set placeholderColor(value: string);
  84280. /** Gets or sets the text displayed when the control is empty */
  84281. get placeholderText(): string;
  84282. set placeholderText(value: string);
  84283. /** Gets or sets the dead key flag */
  84284. get deadKey(): boolean;
  84285. set deadKey(flag: boolean);
  84286. /** Gets or sets the highlight text */
  84287. get highlightedText(): string;
  84288. set highlightedText(text: string);
  84289. /** Gets or sets if the current key should be added */
  84290. get addKey(): boolean;
  84291. set addKey(flag: boolean);
  84292. /** Gets or sets the value of the current key being entered */
  84293. get currentKey(): string;
  84294. set currentKey(key: string);
  84295. /** Gets or sets the text displayed in the control */
  84296. get text(): string;
  84297. set text(value: string);
  84298. private _textHasChanged;
  84299. /** Gets or sets control width */
  84300. get width(): string | number;
  84301. set width(value: string | number);
  84302. /**
  84303. * Creates a new InputText
  84304. * @param name defines the control name
  84305. * @param text defines the text of the control
  84306. */
  84307. constructor(name?: string | undefined, text?: string);
  84308. /** @hidden */
  84309. onBlur(): void;
  84310. /** @hidden */
  84311. onFocus(): void;
  84312. /**
  84313. * Function to focus an inputText programmatically
  84314. */
  84315. focus(): void;
  84316. /**
  84317. * Function to unfocus an inputText programmatically
  84318. */
  84319. blur(): void;
  84320. protected _getTypeName(): string;
  84321. /**
  84322. * Function called to get the list of controls that should not steal the focus from this control
  84323. * @returns an array of controls
  84324. */
  84325. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84326. /** @hidden */
  84327. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84328. /** @hidden */
  84329. private _updateValueFromCursorIndex;
  84330. /** @hidden */
  84331. private _processDblClick;
  84332. /** @hidden */
  84333. private _selectAllText;
  84334. /**
  84335. * Handles the keyboard event
  84336. * @param evt Defines the KeyboardEvent
  84337. */
  84338. processKeyboard(evt: KeyboardEvent): void;
  84339. /** @hidden */
  84340. private _onCopyText;
  84341. /** @hidden */
  84342. private _onCutText;
  84343. /** @hidden */
  84344. private _onPasteText;
  84345. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84346. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84347. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84348. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84349. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84350. dispose(): void;
  84351. }
  84352. }
  84353. declare module BABYLON.GUI {
  84354. /**
  84355. * Class used to create a 2D grid container
  84356. */
  84357. export class Grid extends Container {
  84358. name?: string | undefined;
  84359. private _rowDefinitions;
  84360. private _columnDefinitions;
  84361. private _cells;
  84362. private _childControls;
  84363. /**
  84364. * Gets the number of columns
  84365. */
  84366. get columnCount(): number;
  84367. /**
  84368. * Gets the number of rows
  84369. */
  84370. get rowCount(): number;
  84371. /** Gets the list of children */
  84372. get children(): Control[];
  84373. /** Gets the list of cells (e.g. the containers) */
  84374. get cells(): {
  84375. [key: string]: Container;
  84376. };
  84377. /**
  84378. * Gets the definition of a specific row
  84379. * @param index defines the index of the row
  84380. * @returns the row definition
  84381. */
  84382. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84383. /**
  84384. * Gets the definition of a specific column
  84385. * @param index defines the index of the column
  84386. * @returns the column definition
  84387. */
  84388. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84389. /**
  84390. * Adds a new row to the grid
  84391. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84392. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84393. * @returns the current grid
  84394. */
  84395. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84396. /**
  84397. * Adds a new column to the grid
  84398. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84399. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84400. * @returns the current grid
  84401. */
  84402. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84403. /**
  84404. * Update a row definition
  84405. * @param index defines the index of the row to update
  84406. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84407. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84408. * @returns the current grid
  84409. */
  84410. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84411. /**
  84412. * Update a column definition
  84413. * @param index defines the index of the column to update
  84414. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84415. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84416. * @returns the current grid
  84417. */
  84418. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84419. /**
  84420. * Gets the list of children stored in a specific cell
  84421. * @param row defines the row to check
  84422. * @param column defines the column to check
  84423. * @returns the list of controls
  84424. */
  84425. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84426. /**
  84427. * Gets a string representing the child cell info (row x column)
  84428. * @param child defines the control to get info from
  84429. * @returns a string containing the child cell info (row x column)
  84430. */
  84431. getChildCellInfo(child: Control): string;
  84432. private _removeCell;
  84433. private _offsetCell;
  84434. /**
  84435. * Remove a column definition at specified index
  84436. * @param index defines the index of the column to remove
  84437. * @returns the current grid
  84438. */
  84439. removeColumnDefinition(index: number): Grid;
  84440. /**
  84441. * Remove a row definition at specified index
  84442. * @param index defines the index of the row to remove
  84443. * @returns the current grid
  84444. */
  84445. removeRowDefinition(index: number): Grid;
  84446. /**
  84447. * Adds a new control to the current grid
  84448. * @param control defines the control to add
  84449. * @param row defines the row where to add the control (0 by default)
  84450. * @param column defines the column where to add the control (0 by default)
  84451. * @returns the current grid
  84452. */
  84453. addControl(control: Control, row?: number, column?: number): Grid;
  84454. /**
  84455. * Removes a control from the current container
  84456. * @param control defines the control to remove
  84457. * @returns the current container
  84458. */
  84459. removeControl(control: Control): Container;
  84460. /**
  84461. * Creates a new Grid
  84462. * @param name defines control name
  84463. */
  84464. constructor(name?: string | undefined);
  84465. protected _getTypeName(): string;
  84466. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84467. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84468. _flagDescendantsAsMatrixDirty(): void;
  84469. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84470. /** Releases associated resources */
  84471. dispose(): void;
  84472. }
  84473. }
  84474. declare module BABYLON.GUI {
  84475. /** Class used to create color pickers */
  84476. export class ColorPicker extends Control {
  84477. name?: string | undefined;
  84478. private static _Epsilon;
  84479. private _colorWheelCanvas;
  84480. private _value;
  84481. private _tmpColor;
  84482. private _pointerStartedOnSquare;
  84483. private _pointerStartedOnWheel;
  84484. private _squareLeft;
  84485. private _squareTop;
  84486. private _squareSize;
  84487. private _h;
  84488. private _s;
  84489. private _v;
  84490. private _lastPointerDownID;
  84491. /**
  84492. * BABYLON.Observable raised when the value changes
  84493. */
  84494. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84495. /** Gets or sets the color of the color picker */
  84496. get value(): BABYLON.Color3;
  84497. set value(value: BABYLON.Color3);
  84498. /**
  84499. * Gets or sets control width
  84500. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84501. */
  84502. get width(): string | number;
  84503. set width(value: string | number);
  84504. /**
  84505. * Gets or sets control height
  84506. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84507. */
  84508. get height(): string | number;
  84509. /** Gets or sets control height */
  84510. set height(value: string | number);
  84511. /** Gets or sets control size */
  84512. get size(): string | number;
  84513. set size(value: string | number);
  84514. /**
  84515. * Creates a new ColorPicker
  84516. * @param name defines the control name
  84517. */
  84518. constructor(name?: string | undefined);
  84519. protected _getTypeName(): string;
  84520. /** @hidden */
  84521. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84522. private _updateSquareProps;
  84523. private _drawGradientSquare;
  84524. private _drawCircle;
  84525. private _createColorWheelCanvas;
  84526. /** @hidden */
  84527. _draw(context: CanvasRenderingContext2D): void;
  84528. private _pointerIsDown;
  84529. private _updateValueFromPointer;
  84530. private _isPointOnSquare;
  84531. private _isPointOnWheel;
  84532. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84533. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84534. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84535. _onCanvasBlur(): void;
  84536. /**
  84537. * This function expands the color picker by creating a color picker dialog with manual
  84538. * color value input and the ability to save colors into an array to be used later in
  84539. * subsequent launches of the dialogue.
  84540. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84541. * @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.
  84542. * @returns picked color as a hex string and the saved colors array as hex strings.
  84543. */
  84544. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84545. pickerWidth?: string;
  84546. pickerHeight?: string;
  84547. headerHeight?: string;
  84548. lastColor?: string;
  84549. swatchLimit?: number;
  84550. numSwatchesPerLine?: number;
  84551. savedColors?: Array<string>;
  84552. }): Promise<{
  84553. savedColors?: string[];
  84554. pickedColor: string;
  84555. }>;
  84556. }
  84557. }
  84558. declare module BABYLON.GUI {
  84559. /** Class used to create 2D ellipse containers */
  84560. export class Ellipse extends Container {
  84561. name?: string | undefined;
  84562. private _thickness;
  84563. /** Gets or sets border thickness */
  84564. get thickness(): number;
  84565. set thickness(value: number);
  84566. /**
  84567. * Creates a new Ellipse
  84568. * @param name defines the control name
  84569. */
  84570. constructor(name?: string | undefined);
  84571. protected _getTypeName(): string;
  84572. protected _localDraw(context: CanvasRenderingContext2D): void;
  84573. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84574. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84575. }
  84576. }
  84577. declare module BABYLON.GUI {
  84578. /**
  84579. * Class used to create a focusable button that can easily handle keyboard events
  84580. */
  84581. export class FocusableButton extends Button implements IFocusableControl {
  84582. name?: string | undefined;
  84583. /** Highlight color when button is focused */
  84584. focusedColor: BABYLON.Nullable<string>;
  84585. private _isFocused;
  84586. private _unfocusedColor;
  84587. /** BABYLON.Observable raised when the control gets the focus */
  84588. onFocusObservable: BABYLON.Observable<Button>;
  84589. /** BABYLON.Observable raised when the control loses the focus */
  84590. onBlurObservable: BABYLON.Observable<Button>;
  84591. /** BABYLON.Observable raised when a key event was processed */
  84592. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84593. constructor(name?: string | undefined);
  84594. /** @hidden */
  84595. onBlur(): void;
  84596. /** @hidden */
  84597. onFocus(): void;
  84598. /**
  84599. * Function called to get the list of controls that should not steal the focus from this control
  84600. * @returns an array of controls
  84601. */
  84602. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84603. /**
  84604. * Function to focus a button programmatically
  84605. */
  84606. focus(): void;
  84607. /**
  84608. * Function to unfocus a button programmatically
  84609. */
  84610. blur(): void;
  84611. /**
  84612. * Handles the keyboard event
  84613. * @param evt Defines the KeyboardEvent
  84614. */
  84615. processKeyboard(evt: KeyboardEvent): void;
  84616. /** @hidden */
  84617. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84618. /** @hidden */
  84619. displose(): void;
  84620. }
  84621. }
  84622. declare module BABYLON.GUI {
  84623. /**
  84624. * Class used to create a password control
  84625. */
  84626. export class InputPassword extends InputText {
  84627. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84628. }
  84629. }
  84630. declare module BABYLON.GUI {
  84631. /** Class used to render 2D lines */
  84632. export class Line extends Control {
  84633. name?: string | undefined;
  84634. private _lineWidth;
  84635. private _x1;
  84636. private _y1;
  84637. private _x2;
  84638. private _y2;
  84639. private _dash;
  84640. private _connectedControl;
  84641. private _connectedControlDirtyObserver;
  84642. /** Gets or sets the dash pattern */
  84643. get dash(): Array<number>;
  84644. set dash(value: Array<number>);
  84645. /** Gets or sets the control connected with the line end */
  84646. get connectedControl(): Control;
  84647. set connectedControl(value: Control);
  84648. /** Gets or sets start coordinates on X axis */
  84649. get x1(): string | number;
  84650. set x1(value: string | number);
  84651. /** Gets or sets start coordinates on Y axis */
  84652. get y1(): string | number;
  84653. set y1(value: string | number);
  84654. /** Gets or sets end coordinates on X axis */
  84655. get x2(): string | number;
  84656. set x2(value: string | number);
  84657. /** Gets or sets end coordinates on Y axis */
  84658. get y2(): string | number;
  84659. set y2(value: string | number);
  84660. /** Gets or sets line width */
  84661. get lineWidth(): number;
  84662. set lineWidth(value: number);
  84663. /** Gets or sets horizontal alignment */
  84664. set horizontalAlignment(value: number);
  84665. /** Gets or sets vertical alignment */
  84666. set verticalAlignment(value: number);
  84667. private get _effectiveX2();
  84668. private get _effectiveY2();
  84669. /**
  84670. * Creates a new Line
  84671. * @param name defines the control name
  84672. */
  84673. constructor(name?: string | undefined);
  84674. protected _getTypeName(): string;
  84675. _draw(context: CanvasRenderingContext2D): void;
  84676. _measure(): void;
  84677. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84678. /**
  84679. * Move one end of the line given 3D cartesian coordinates.
  84680. * @param position Targeted world position
  84681. * @param scene BABYLON.Scene
  84682. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84683. */
  84684. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  84685. /**
  84686. * Move one end of the line to a position in screen absolute space.
  84687. * @param projectedPosition Position in screen absolute space (X, Y)
  84688. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84689. */
  84690. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  84691. }
  84692. }
  84693. declare module BABYLON.GUI {
  84694. /**
  84695. * Class used to store a point for a MultiLine object.
  84696. * The point can be pure 2D coordinates, a mesh or a control
  84697. */
  84698. export class MultiLinePoint {
  84699. private _multiLine;
  84700. private _x;
  84701. private _y;
  84702. private _control;
  84703. private _mesh;
  84704. private _controlObserver;
  84705. private _meshObserver;
  84706. /** @hidden */
  84707. _point: BABYLON.Vector3;
  84708. /**
  84709. * Creates a new MultiLinePoint
  84710. * @param multiLine defines the source MultiLine object
  84711. */
  84712. constructor(multiLine: MultiLine);
  84713. /** Gets or sets x coordinate */
  84714. get x(): string | number;
  84715. set x(value: string | number);
  84716. /** Gets or sets y coordinate */
  84717. get y(): string | number;
  84718. set y(value: string | number);
  84719. /** Gets or sets the control associated with this point */
  84720. get control(): BABYLON.Nullable<Control>;
  84721. set control(value: BABYLON.Nullable<Control>);
  84722. /** Gets or sets the mesh associated with this point */
  84723. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  84724. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  84725. /** Resets links */
  84726. resetLinks(): void;
  84727. /**
  84728. * Gets a translation vector with Z component
  84729. * @returns the translation vector
  84730. */
  84731. translate(): BABYLON.Vector3;
  84732. private _translatePoint;
  84733. /** Release associated resources */
  84734. dispose(): void;
  84735. }
  84736. }
  84737. declare module BABYLON.GUI {
  84738. /**
  84739. * Class used to create multi line control
  84740. */
  84741. export class MultiLine extends Control {
  84742. name?: string | undefined;
  84743. private _lineWidth;
  84744. private _dash;
  84745. private _points;
  84746. private _minX;
  84747. private _minY;
  84748. private _maxX;
  84749. private _maxY;
  84750. /**
  84751. * Creates a new MultiLine
  84752. * @param name defines the control name
  84753. */
  84754. constructor(name?: string | undefined);
  84755. /** Gets or sets dash pattern */
  84756. get dash(): Array<number>;
  84757. set dash(value: Array<number>);
  84758. /**
  84759. * Gets point stored at specified index
  84760. * @param index defines the index to look for
  84761. * @returns the requested point if found
  84762. */
  84763. getAt(index: number): MultiLinePoint;
  84764. /** Function called when a point is updated */
  84765. onPointUpdate: () => void;
  84766. /**
  84767. * Adds new points to the point collection
  84768. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  84769. * @returns the list of created MultiLinePoint
  84770. */
  84771. add(...items: (AbstractMesh | Control | {
  84772. x: string | number;
  84773. y: string | number;
  84774. })[]): MultiLinePoint[];
  84775. /**
  84776. * Adds a new point to the point collection
  84777. * @param item defines the item (mesh, control or 2d coordiantes) to add
  84778. * @returns the created MultiLinePoint
  84779. */
  84780. push(item?: (AbstractMesh | Control | {
  84781. x: string | number;
  84782. y: string | number;
  84783. })): MultiLinePoint;
  84784. /**
  84785. * Remove a specific value or point from the active point collection
  84786. * @param value defines the value or point to remove
  84787. */
  84788. remove(value: number | MultiLinePoint): void;
  84789. /**
  84790. * Resets this object to initial state (no point)
  84791. */
  84792. reset(): void;
  84793. /**
  84794. * Resets all links
  84795. */
  84796. resetLinks(): void;
  84797. /** Gets or sets line width */
  84798. get lineWidth(): number;
  84799. set lineWidth(value: number);
  84800. set horizontalAlignment(value: number);
  84801. set verticalAlignment(value: number);
  84802. protected _getTypeName(): string;
  84803. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84804. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84805. _measure(): void;
  84806. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84807. dispose(): void;
  84808. }
  84809. }
  84810. declare module BABYLON.GUI {
  84811. /**
  84812. * Class used to create radio button controls
  84813. */
  84814. export class RadioButton extends Control {
  84815. name?: string | undefined;
  84816. private _isChecked;
  84817. private _background;
  84818. private _checkSizeRatio;
  84819. private _thickness;
  84820. /** Gets or sets border thickness */
  84821. get thickness(): number;
  84822. set thickness(value: number);
  84823. /** Gets or sets group name */
  84824. group: string;
  84825. /** BABYLON.Observable raised when isChecked is changed */
  84826. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84827. /** Gets or sets a value indicating the ratio between overall size and check size */
  84828. get checkSizeRatio(): number;
  84829. set checkSizeRatio(value: number);
  84830. /** Gets or sets background color */
  84831. get background(): string;
  84832. set background(value: string);
  84833. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84834. get isChecked(): boolean;
  84835. set isChecked(value: boolean);
  84836. /**
  84837. * Creates a new RadioButton
  84838. * @param name defines the control name
  84839. */
  84840. constructor(name?: string | undefined);
  84841. protected _getTypeName(): string;
  84842. _draw(context: CanvasRenderingContext2D): void;
  84843. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84844. /**
  84845. * Utility function to easily create a radio button with a header
  84846. * @param title defines the label to use for the header
  84847. * @param group defines the group to use for the radio button
  84848. * @param isChecked defines the initial state of the radio button
  84849. * @param onValueChanged defines the callback to call when value changes
  84850. * @returns a StackPanel containing the radio button and a textBlock
  84851. */
  84852. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  84853. }
  84854. }
  84855. declare module BABYLON.GUI {
  84856. /**
  84857. * Class used to create slider controls
  84858. */
  84859. export class BaseSlider extends Control {
  84860. name?: string | undefined;
  84861. protected _thumbWidth: ValueAndUnit;
  84862. private _minimum;
  84863. private _maximum;
  84864. private _value;
  84865. private _isVertical;
  84866. protected _barOffset: ValueAndUnit;
  84867. private _isThumbClamped;
  84868. protected _displayThumb: boolean;
  84869. private _step;
  84870. private _lastPointerDownID;
  84871. protected _effectiveBarOffset: number;
  84872. protected _renderLeft: number;
  84873. protected _renderTop: number;
  84874. protected _renderWidth: number;
  84875. protected _renderHeight: number;
  84876. protected _backgroundBoxLength: number;
  84877. protected _backgroundBoxThickness: number;
  84878. protected _effectiveThumbThickness: number;
  84879. /** BABYLON.Observable raised when the sldier value changes */
  84880. onValueChangedObservable: BABYLON.Observable<number>;
  84881. /** Gets or sets a boolean indicating if the thumb must be rendered */
  84882. get displayThumb(): boolean;
  84883. set displayThumb(value: boolean);
  84884. /** Gets or sets a step to apply to values (0 by default) */
  84885. get step(): number;
  84886. set step(value: number);
  84887. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  84888. get barOffset(): string | number;
  84889. /** Gets main bar offset in pixels*/
  84890. get barOffsetInPixels(): number;
  84891. set barOffset(value: string | number);
  84892. /** Gets or sets thumb width */
  84893. get thumbWidth(): string | number;
  84894. /** Gets thumb width in pixels */
  84895. get thumbWidthInPixels(): number;
  84896. set thumbWidth(value: string | number);
  84897. /** Gets or sets minimum value */
  84898. get minimum(): number;
  84899. set minimum(value: number);
  84900. /** Gets or sets maximum value */
  84901. get maximum(): number;
  84902. set maximum(value: number);
  84903. /** Gets or sets current value */
  84904. get value(): number;
  84905. set value(value: number);
  84906. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  84907. get isVertical(): boolean;
  84908. set isVertical(value: boolean);
  84909. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  84910. get isThumbClamped(): boolean;
  84911. set isThumbClamped(value: boolean);
  84912. /**
  84913. * Creates a new BaseSlider
  84914. * @param name defines the control name
  84915. */
  84916. constructor(name?: string | undefined);
  84917. protected _getTypeName(): string;
  84918. protected _getThumbPosition(): number;
  84919. protected _getThumbThickness(type: string): number;
  84920. protected _prepareRenderingData(type: string): void;
  84921. private _pointerIsDown;
  84922. /** @hidden */
  84923. protected _updateValueFromPointer(x: number, y: number): void;
  84924. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84925. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84926. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84927. _onCanvasBlur(): void;
  84928. }
  84929. }
  84930. declare module BABYLON.GUI {
  84931. /**
  84932. * Class used to create slider controls
  84933. */
  84934. export class Slider extends BaseSlider {
  84935. name?: string | undefined;
  84936. private _background;
  84937. private _borderColor;
  84938. private _thumbColor;
  84939. private _isThumbCircle;
  84940. protected _displayValueBar: boolean;
  84941. /** Gets or sets a boolean indicating if the value bar must be rendered */
  84942. get displayValueBar(): boolean;
  84943. set displayValueBar(value: boolean);
  84944. /** Gets or sets border color */
  84945. get borderColor(): string;
  84946. set borderColor(value: string);
  84947. /** Gets or sets background color */
  84948. get background(): string;
  84949. set background(value: string);
  84950. /** Gets or sets thumb's color */
  84951. get thumbColor(): string;
  84952. set thumbColor(value: string);
  84953. /** Gets or sets a boolean indicating if the thumb should be round or square */
  84954. get isThumbCircle(): boolean;
  84955. set isThumbCircle(value: boolean);
  84956. /**
  84957. * Creates a new Slider
  84958. * @param name defines the control name
  84959. */
  84960. constructor(name?: string | undefined);
  84961. protected _getTypeName(): string;
  84962. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84963. }
  84964. }
  84965. declare module BABYLON.GUI {
  84966. /** Class used to create a RadioGroup
  84967. * which contains groups of radio buttons
  84968. */
  84969. export class SelectorGroup {
  84970. /** name of SelectorGroup */
  84971. name: string;
  84972. private _groupPanel;
  84973. private _selectors;
  84974. private _groupHeader;
  84975. /**
  84976. * Creates a new SelectorGroup
  84977. * @param name of group, used as a group heading
  84978. */
  84979. constructor(
  84980. /** name of SelectorGroup */
  84981. name: string);
  84982. /** Gets the groupPanel of the SelectorGroup */
  84983. get groupPanel(): StackPanel;
  84984. /** Gets the selectors array */
  84985. get selectors(): StackPanel[];
  84986. /** Gets and sets the group header */
  84987. get header(): string;
  84988. set header(label: string);
  84989. /** @hidden */
  84990. private _addGroupHeader;
  84991. /** @hidden*/
  84992. _getSelector(selectorNb: number): StackPanel | undefined;
  84993. /** Removes the selector at the given position
  84994. * @param selectorNb the position of the selector within the group
  84995. */
  84996. removeSelector(selectorNb: number): void;
  84997. }
  84998. /** Class used to create a CheckboxGroup
  84999. * which contains groups of checkbox buttons
  85000. */
  85001. export class CheckboxGroup extends SelectorGroup {
  85002. /** Adds a checkbox as a control
  85003. * @param text is the label for the selector
  85004. * @param func is the function called when the Selector is checked
  85005. * @param checked is true when Selector is checked
  85006. */
  85007. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85008. /** @hidden */
  85009. _setSelectorLabel(selectorNb: number, label: string): void;
  85010. /** @hidden */
  85011. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85012. /** @hidden */
  85013. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85014. /** @hidden */
  85015. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85016. }
  85017. /** Class used to create a RadioGroup
  85018. * which contains groups of radio buttons
  85019. */
  85020. export class RadioGroup extends SelectorGroup {
  85021. private _selectNb;
  85022. /** Adds a radio button as a control
  85023. * @param label is the label for the selector
  85024. * @param func is the function called when the Selector is checked
  85025. * @param checked is true when Selector is checked
  85026. */
  85027. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85028. /** @hidden */
  85029. _setSelectorLabel(selectorNb: number, label: string): void;
  85030. /** @hidden */
  85031. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85032. /** @hidden */
  85033. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85034. /** @hidden */
  85035. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85036. }
  85037. /** Class used to create a SliderGroup
  85038. * which contains groups of slider buttons
  85039. */
  85040. export class SliderGroup extends SelectorGroup {
  85041. /**
  85042. * Adds a slider to the SelectorGroup
  85043. * @param label is the label for the SliderBar
  85044. * @param func is the function called when the Slider moves
  85045. * @param unit is a string describing the units used, eg degrees or metres
  85046. * @param min is the minimum value for the Slider
  85047. * @param max is the maximum value for the Slider
  85048. * @param value is the start value for the Slider between min and max
  85049. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  85050. */
  85051. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  85052. /** @hidden */
  85053. _setSelectorLabel(selectorNb: number, label: string): void;
  85054. /** @hidden */
  85055. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85056. /** @hidden */
  85057. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85058. /** @hidden */
  85059. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85060. }
  85061. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  85062. * @see https://doc.babylonjs.com/how_to/selector
  85063. */
  85064. export class SelectionPanel extends Rectangle {
  85065. /** name of SelectionPanel */
  85066. name: string;
  85067. /** an array of SelectionGroups */
  85068. groups: SelectorGroup[];
  85069. private _panel;
  85070. private _buttonColor;
  85071. private _buttonBackground;
  85072. private _headerColor;
  85073. private _barColor;
  85074. private _barHeight;
  85075. private _spacerHeight;
  85076. private _labelColor;
  85077. private _groups;
  85078. private _bars;
  85079. /**
  85080. * Creates a new SelectionPanel
  85081. * @param name of SelectionPanel
  85082. * @param groups is an array of SelectionGroups
  85083. */
  85084. constructor(
  85085. /** name of SelectionPanel */
  85086. name: string,
  85087. /** an array of SelectionGroups */
  85088. groups?: SelectorGroup[]);
  85089. protected _getTypeName(): string;
  85090. /** Gets the (stack) panel of the SelectionPanel */
  85091. get panel(): StackPanel;
  85092. /** Gets or sets the headerColor */
  85093. get headerColor(): string;
  85094. set headerColor(color: string);
  85095. private _setHeaderColor;
  85096. /** Gets or sets the button color */
  85097. get buttonColor(): string;
  85098. set buttonColor(color: string);
  85099. private _setbuttonColor;
  85100. /** Gets or sets the label color */
  85101. get labelColor(): string;
  85102. set labelColor(color: string);
  85103. private _setLabelColor;
  85104. /** Gets or sets the button background */
  85105. get buttonBackground(): string;
  85106. set buttonBackground(color: string);
  85107. private _setButtonBackground;
  85108. /** Gets or sets the color of separator bar */
  85109. get barColor(): string;
  85110. set barColor(color: string);
  85111. private _setBarColor;
  85112. /** Gets or sets the height of separator bar */
  85113. get barHeight(): string;
  85114. set barHeight(value: string);
  85115. private _setBarHeight;
  85116. /** Gets or sets the height of spacers*/
  85117. get spacerHeight(): string;
  85118. set spacerHeight(value: string);
  85119. private _setSpacerHeight;
  85120. /** Adds a bar between groups */
  85121. private _addSpacer;
  85122. /** Add a group to the selection panel
  85123. * @param group is the selector group to add
  85124. */
  85125. addGroup(group: SelectorGroup): void;
  85126. /** Remove the group from the given position
  85127. * @param groupNb is the position of the group in the list
  85128. */
  85129. removeGroup(groupNb: number): void;
  85130. /** Change a group header label
  85131. * @param label is the new group header label
  85132. * @param groupNb is the number of the group to relabel
  85133. * */
  85134. setHeaderName(label: string, groupNb: number): void;
  85135. /** Change selector label to the one given
  85136. * @param label is the new selector label
  85137. * @param groupNb is the number of the groupcontaining the selector
  85138. * @param selectorNb is the number of the selector within a group to relabel
  85139. * */
  85140. relabel(label: string, groupNb: number, selectorNb: number): void;
  85141. /** For a given group position remove the selector at the given position
  85142. * @param groupNb is the number of the group to remove the selector from
  85143. * @param selectorNb is the number of the selector within the group
  85144. */
  85145. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85146. /** For a given group position of correct type add a checkbox button
  85147. * @param groupNb is the number of the group to remove the selector from
  85148. * @param label is the label for the selector
  85149. * @param func is the function called when the Selector is checked
  85150. * @param checked is true when Selector is checked
  85151. */
  85152. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85153. /** For a given group position of correct type add a radio button
  85154. * @param groupNb is the number of the group to remove the selector from
  85155. * @param label is the label for the selector
  85156. * @param func is the function called when the Selector is checked
  85157. * @param checked is true when Selector is checked
  85158. */
  85159. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85160. /**
  85161. * For a given slider group add a slider
  85162. * @param groupNb is the number of the group to add the slider to
  85163. * @param label is the label for the Slider
  85164. * @param func is the function called when the Slider moves
  85165. * @param unit is a string describing the units used, eg degrees or metres
  85166. * @param min is the minimum value for the Slider
  85167. * @param max is the maximum value for the Slider
  85168. * @param value is the start value for the Slider between min and max
  85169. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85170. */
  85171. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85172. }
  85173. }
  85174. declare module BABYLON.GUI {
  85175. /**
  85176. * Class used to hold a the container for ScrollViewer
  85177. * @hidden
  85178. */
  85179. export class _ScrollViewerWindow extends Container {
  85180. parentClientWidth: number;
  85181. parentClientHeight: number;
  85182. private _freezeControls;
  85183. private _parentMeasure;
  85184. private _oldLeft;
  85185. private _oldTop;
  85186. get freezeControls(): boolean;
  85187. set freezeControls(value: boolean);
  85188. private _bucketWidth;
  85189. private _bucketHeight;
  85190. private _buckets;
  85191. private _bucketLen;
  85192. get bucketWidth(): number;
  85193. get bucketHeight(): number;
  85194. setBucketSizes(width: number, height: number): void;
  85195. private _useBuckets;
  85196. private _makeBuckets;
  85197. private _dispatchInBuckets;
  85198. private _updateMeasures;
  85199. private _updateChildrenMeasures;
  85200. private _restoreMeasures;
  85201. /**
  85202. * Creates a new ScrollViewerWindow
  85203. * @param name of ScrollViewerWindow
  85204. */
  85205. constructor(name?: string);
  85206. protected _getTypeName(): string;
  85207. /** @hidden */
  85208. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85209. /** @hidden */
  85210. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85211. private _scrollChildren;
  85212. private _scrollChildrenWithBuckets;
  85213. /** @hidden */
  85214. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85215. protected _postMeasure(): void;
  85216. }
  85217. }
  85218. declare module BABYLON.GUI {
  85219. /**
  85220. * Class used to create slider controls
  85221. */
  85222. export class ScrollBar extends BaseSlider {
  85223. name?: string | undefined;
  85224. private _background;
  85225. private _borderColor;
  85226. private _tempMeasure;
  85227. /** Gets or sets border color */
  85228. get borderColor(): string;
  85229. set borderColor(value: string);
  85230. /** Gets or sets background color */
  85231. get background(): string;
  85232. set background(value: string);
  85233. /**
  85234. * Creates a new Slider
  85235. * @param name defines the control name
  85236. */
  85237. constructor(name?: string | undefined);
  85238. protected _getTypeName(): string;
  85239. protected _getThumbThickness(): number;
  85240. _draw(context: CanvasRenderingContext2D): void;
  85241. private _first;
  85242. private _originX;
  85243. private _originY;
  85244. /** @hidden */
  85245. protected _updateValueFromPointer(x: number, y: number): void;
  85246. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85247. }
  85248. }
  85249. declare module BABYLON.GUI {
  85250. /**
  85251. * Class used to create slider controls
  85252. */
  85253. export class ImageScrollBar extends BaseSlider {
  85254. name?: string | undefined;
  85255. private _backgroundBaseImage;
  85256. private _backgroundImage;
  85257. private _thumbImage;
  85258. private _thumbBaseImage;
  85259. private _thumbLength;
  85260. private _thumbHeight;
  85261. private _barImageHeight;
  85262. private _tempMeasure;
  85263. /** Number of 90° rotation to apply on the images when in vertical mode */
  85264. num90RotationInVerticalMode: number;
  85265. /**
  85266. * Gets or sets the image used to render the background for horizontal bar
  85267. */
  85268. get backgroundImage(): Image;
  85269. set backgroundImage(value: Image);
  85270. /**
  85271. * Gets or sets the image used to render the thumb
  85272. */
  85273. get thumbImage(): Image;
  85274. set thumbImage(value: Image);
  85275. /**
  85276. * Gets or sets the length of the thumb
  85277. */
  85278. get thumbLength(): number;
  85279. set thumbLength(value: number);
  85280. /**
  85281. * Gets or sets the height of the thumb
  85282. */
  85283. get thumbHeight(): number;
  85284. set thumbHeight(value: number);
  85285. /**
  85286. * Gets or sets the height of the bar image
  85287. */
  85288. get barImageHeight(): number;
  85289. set barImageHeight(value: number);
  85290. /**
  85291. * Creates a new ImageScrollBar
  85292. * @param name defines the control name
  85293. */
  85294. constructor(name?: string | undefined);
  85295. protected _getTypeName(): string;
  85296. protected _getThumbThickness(): number;
  85297. _draw(context: CanvasRenderingContext2D): void;
  85298. private _first;
  85299. private _originX;
  85300. private _originY;
  85301. /** @hidden */
  85302. protected _updateValueFromPointer(x: number, y: number): void;
  85303. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85304. }
  85305. }
  85306. declare module BABYLON.GUI {
  85307. /**
  85308. * Class used to hold a viewer window and sliders in a grid
  85309. */
  85310. export class ScrollViewer extends Rectangle {
  85311. private _grid;
  85312. private _horizontalBarSpace;
  85313. private _verticalBarSpace;
  85314. private _dragSpace;
  85315. private _horizontalBar;
  85316. private _verticalBar;
  85317. private _barColor;
  85318. private _barBackground;
  85319. private _barImage;
  85320. private _horizontalBarImage;
  85321. private _verticalBarImage;
  85322. private _barBackgroundImage;
  85323. private _horizontalBarBackgroundImage;
  85324. private _verticalBarBackgroundImage;
  85325. private _barSize;
  85326. private _window;
  85327. private _pointerIsOver;
  85328. private _wheelPrecision;
  85329. private _onWheelObserver;
  85330. private _clientWidth;
  85331. private _clientHeight;
  85332. private _useImageBar;
  85333. private _thumbLength;
  85334. private _thumbHeight;
  85335. private _barImageHeight;
  85336. private _horizontalBarImageHeight;
  85337. private _verticalBarImageHeight;
  85338. private _oldWindowContentsWidth;
  85339. private _oldWindowContentsHeight;
  85340. /**
  85341. * Gets the horizontal scrollbar
  85342. */
  85343. get horizontalBar(): ScrollBar | ImageScrollBar;
  85344. /**
  85345. * Gets the vertical scrollbar
  85346. */
  85347. get verticalBar(): ScrollBar | ImageScrollBar;
  85348. /**
  85349. * Adds a new control to the current container
  85350. * @param control defines the control to add
  85351. * @returns the current container
  85352. */
  85353. addControl(control: BABYLON.Nullable<Control>): Container;
  85354. /**
  85355. * Removes a control from the current container
  85356. * @param control defines the control to remove
  85357. * @returns the current container
  85358. */
  85359. removeControl(control: Control): Container;
  85360. /** Gets the list of children */
  85361. get children(): Control[];
  85362. _flagDescendantsAsMatrixDirty(): void;
  85363. /**
  85364. * Freezes or unfreezes the controls in the window.
  85365. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85366. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85367. */
  85368. get freezeControls(): boolean;
  85369. set freezeControls(value: boolean);
  85370. /** Gets the bucket width */
  85371. get bucketWidth(): number;
  85372. /** Gets the bucket height */
  85373. get bucketHeight(): number;
  85374. /**
  85375. * Sets the bucket sizes.
  85376. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85377. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85378. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85379. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85380. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85381. * used), that's why it is not enabled by default.
  85382. * @param width width of the bucket
  85383. * @param height height of the bucket
  85384. */
  85385. setBucketSizes(width: number, height: number): void;
  85386. private _forceHorizontalBar;
  85387. private _forceVerticalBar;
  85388. /**
  85389. * Forces the horizontal scroll bar to be displayed
  85390. */
  85391. get forceHorizontalBar(): boolean;
  85392. set forceHorizontalBar(value: boolean);
  85393. /**
  85394. * Forces the vertical scroll bar to be displayed
  85395. */
  85396. get forceVerticalBar(): boolean;
  85397. set forceVerticalBar(value: boolean);
  85398. /**
  85399. * Creates a new ScrollViewer
  85400. * @param name of ScrollViewer
  85401. */
  85402. constructor(name?: string, isImageBased?: boolean);
  85403. /** Reset the scroll viewer window to initial size */
  85404. resetWindow(): void;
  85405. protected _getTypeName(): string;
  85406. private _buildClientSizes;
  85407. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85408. protected _postMeasure(): void;
  85409. /**
  85410. * Gets or sets the mouse wheel precision
  85411. * from 0 to 1 with a default value of 0.05
  85412. * */
  85413. get wheelPrecision(): number;
  85414. set wheelPrecision(value: number);
  85415. /** Gets or sets the scroll bar container background color */
  85416. get scrollBackground(): string;
  85417. set scrollBackground(color: string);
  85418. /** Gets or sets the bar color */
  85419. get barColor(): string;
  85420. set barColor(color: string);
  85421. /** Gets or sets the bar image */
  85422. get thumbImage(): Image;
  85423. set thumbImage(value: Image);
  85424. /** Gets or sets the horizontal bar image */
  85425. get horizontalThumbImage(): Image;
  85426. set horizontalThumbImage(value: Image);
  85427. /** Gets or sets the vertical bar image */
  85428. get verticalThumbImage(): Image;
  85429. set verticalThumbImage(value: Image);
  85430. /** Gets or sets the size of the bar */
  85431. get barSize(): number;
  85432. set barSize(value: number);
  85433. /** Gets or sets the length of the thumb */
  85434. get thumbLength(): number;
  85435. set thumbLength(value: number);
  85436. /** Gets or sets the height of the thumb */
  85437. get thumbHeight(): number;
  85438. set thumbHeight(value: number);
  85439. /** Gets or sets the height of the bar image */
  85440. get barImageHeight(): number;
  85441. set barImageHeight(value: number);
  85442. /** Gets or sets the height of the horizontal bar image */
  85443. get horizontalBarImageHeight(): number;
  85444. set horizontalBarImageHeight(value: number);
  85445. /** Gets or sets the height of the vertical bar image */
  85446. get verticalBarImageHeight(): number;
  85447. set verticalBarImageHeight(value: number);
  85448. /** Gets or sets the bar background */
  85449. get barBackground(): string;
  85450. set barBackground(color: string);
  85451. /** Gets or sets the bar background image */
  85452. get barImage(): Image;
  85453. set barImage(value: Image);
  85454. /** Gets or sets the horizontal bar background image */
  85455. get horizontalBarImage(): Image;
  85456. set horizontalBarImage(value: Image);
  85457. /** Gets or sets the vertical bar background image */
  85458. get verticalBarImage(): Image;
  85459. set verticalBarImage(value: Image);
  85460. private _setWindowPosition;
  85461. /** @hidden */
  85462. private _updateScroller;
  85463. _link(host: AdvancedDynamicTexture): void;
  85464. /** @hidden */
  85465. private _addBar;
  85466. /** @hidden */
  85467. private _attachWheel;
  85468. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85469. /** Releases associated resources */
  85470. dispose(): void;
  85471. }
  85472. }
  85473. declare module BABYLON.GUI {
  85474. /**
  85475. * Class used to create toggle buttons
  85476. */
  85477. export class ToggleButton extends Rectangle {
  85478. name?: string | undefined;
  85479. /**
  85480. * Function called to generate the toActive animation
  85481. */
  85482. toActiveAnimation: () => void;
  85483. /**
  85484. * Function called to generate the toInactive animation
  85485. */
  85486. toInactiveAnimation: () => void;
  85487. /**
  85488. * Function called to generate a pointer enter animation when the toggle button is active.
  85489. */
  85490. pointerEnterActiveAnimation: () => void;
  85491. /**
  85492. * Function called to generate a pointer out animation when the toggle button is active.
  85493. */
  85494. pointerOutActiveAnimation: () => void;
  85495. /**
  85496. * Function called to generate a pointer down animation when the toggle button is active.
  85497. */
  85498. pointerDownActiveAnimation: () => void;
  85499. /**
  85500. * Function called to generate a pointer up animation when the toggle button is active.
  85501. */
  85502. pointerUpActiveAnimation: () => void;
  85503. /**
  85504. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85505. */
  85506. pointerEnterInactiveAnimation: () => void;
  85507. /**
  85508. * Function called to generate a pointer out animation when the toggle button is inactive.
  85509. */
  85510. pointerOutInactiveAnimation: () => void;
  85511. /**
  85512. * Function called to generate a pointer down animation when the toggle button is inactive.
  85513. */
  85514. pointerDownInactiveAnimation: () => void;
  85515. /**
  85516. * Function called to generate a pointer up animation when the toggle button is inactive.
  85517. */
  85518. pointerUpInactiveAnimation: () => void;
  85519. /** BABYLON.Observable raised when isActive is changed */
  85520. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85521. /**
  85522. * 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
  85523. */
  85524. delegatePickingToChildren: boolean;
  85525. private _image;
  85526. /**
  85527. * Returns the ToggleButton's image control if it exists
  85528. */
  85529. get image(): BABYLON.Nullable<Image>;
  85530. private _textBlock;
  85531. /**
  85532. * Returns the ToggleButton's child TextBlock control if it exists
  85533. */
  85534. get textBlock(): BABYLON.Nullable<TextBlock>;
  85535. private _group;
  85536. /** Gets or sets group name this toggle button belongs to */
  85537. get group(): string;
  85538. set group(value: string);
  85539. private _isActive;
  85540. /** Gets or sets a boolean indicating if the toogle button is active or not */
  85541. get isActive(): boolean;
  85542. set isActive(value: boolean);
  85543. /**
  85544. * Creates a new ToggleButton
  85545. * @param name defines the control name
  85546. * @param group defines the toggle group this toggle belongs to
  85547. */
  85548. constructor(name?: string | undefined, group?: string);
  85549. protected _getTypeName(): string;
  85550. /** @hidden */
  85551. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  85552. /** @hidden */
  85553. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  85554. /** @hidden */
  85555. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  85556. /** @hidden */
  85557. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85558. /** @hidden */
  85559. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85560. }
  85561. }
  85562. declare module BABYLON.GUI {
  85563. /** Class used to render a grid */
  85564. export class DisplayGrid extends Control {
  85565. name?: string | undefined;
  85566. private _cellWidth;
  85567. private _cellHeight;
  85568. private _minorLineTickness;
  85569. private _minorLineColor;
  85570. private _majorLineTickness;
  85571. private _majorLineColor;
  85572. private _majorLineFrequency;
  85573. private _background;
  85574. private _displayMajorLines;
  85575. private _displayMinorLines;
  85576. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  85577. get displayMinorLines(): boolean;
  85578. set displayMinorLines(value: boolean);
  85579. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  85580. get displayMajorLines(): boolean;
  85581. set displayMajorLines(value: boolean);
  85582. /** Gets or sets background color (Black by default) */
  85583. get background(): string;
  85584. set background(value: string);
  85585. /** Gets or sets the width of each cell (20 by default) */
  85586. get cellWidth(): number;
  85587. set cellWidth(value: number);
  85588. /** Gets or sets the height of each cell (20 by default) */
  85589. get cellHeight(): number;
  85590. set cellHeight(value: number);
  85591. /** Gets or sets the tickness of minor lines (1 by default) */
  85592. get minorLineTickness(): number;
  85593. set minorLineTickness(value: number);
  85594. /** Gets or sets the color of minor lines (DarkGray by default) */
  85595. get minorLineColor(): string;
  85596. set minorLineColor(value: string);
  85597. /** Gets or sets the tickness of major lines (2 by default) */
  85598. get majorLineTickness(): number;
  85599. set majorLineTickness(value: number);
  85600. /** Gets or sets the color of major lines (White by default) */
  85601. get majorLineColor(): string;
  85602. set majorLineColor(value: string);
  85603. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  85604. get majorLineFrequency(): number;
  85605. set majorLineFrequency(value: number);
  85606. /**
  85607. * Creates a new GridDisplayRectangle
  85608. * @param name defines the control name
  85609. */
  85610. constructor(name?: string | undefined);
  85611. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85612. protected _getTypeName(): string;
  85613. }
  85614. }
  85615. declare module BABYLON.GUI {
  85616. /**
  85617. * Class used to create slider controls based on images
  85618. */
  85619. export class ImageBasedSlider extends BaseSlider {
  85620. name?: string | undefined;
  85621. private _backgroundImage;
  85622. private _thumbImage;
  85623. private _valueBarImage;
  85624. private _tempMeasure;
  85625. get displayThumb(): boolean;
  85626. set displayThumb(value: boolean);
  85627. /**
  85628. * Gets or sets the image used to render the background
  85629. */
  85630. get backgroundImage(): Image;
  85631. set backgroundImage(value: Image);
  85632. /**
  85633. * Gets or sets the image used to render the value bar
  85634. */
  85635. get valueBarImage(): Image;
  85636. set valueBarImage(value: Image);
  85637. /**
  85638. * Gets or sets the image used to render the thumb
  85639. */
  85640. get thumbImage(): Image;
  85641. set thumbImage(value: Image);
  85642. /**
  85643. * Creates a new ImageBasedSlider
  85644. * @param name defines the control name
  85645. */
  85646. constructor(name?: string | undefined);
  85647. protected _getTypeName(): string;
  85648. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85649. }
  85650. }
  85651. declare module BABYLON.GUI {
  85652. /**
  85653. * Forcing an export so that this code will execute
  85654. * @hidden
  85655. */
  85656. const name = "Statics";
  85657. }
  85658. declare module BABYLON.GUI {
  85659. /**
  85660. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  85661. */
  85662. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  85663. /**
  85664. * Define the instrumented AdvancedDynamicTexture.
  85665. */
  85666. texture: AdvancedDynamicTexture;
  85667. private _captureRenderTime;
  85668. private _renderTime;
  85669. private _captureLayoutTime;
  85670. private _layoutTime;
  85671. private _onBeginRenderObserver;
  85672. private _onEndRenderObserver;
  85673. private _onBeginLayoutObserver;
  85674. private _onEndLayoutObserver;
  85675. /**
  85676. * Gets the perf counter used to capture render time
  85677. */
  85678. get renderTimeCounter(): BABYLON.PerfCounter;
  85679. /**
  85680. * Gets the perf counter used to capture layout time
  85681. */
  85682. get layoutTimeCounter(): BABYLON.PerfCounter;
  85683. /**
  85684. * Enable or disable the render time capture
  85685. */
  85686. get captureRenderTime(): boolean;
  85687. set captureRenderTime(value: boolean);
  85688. /**
  85689. * Enable or disable the layout time capture
  85690. */
  85691. get captureLayoutTime(): boolean;
  85692. set captureLayoutTime(value: boolean);
  85693. /**
  85694. * Instantiates a new advanced dynamic texture instrumentation.
  85695. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  85696. * @param texture Defines the AdvancedDynamicTexture to instrument
  85697. */
  85698. constructor(
  85699. /**
  85700. * Define the instrumented AdvancedDynamicTexture.
  85701. */
  85702. texture: AdvancedDynamicTexture);
  85703. /**
  85704. * Dispose and release associated resources.
  85705. */
  85706. dispose(): void;
  85707. }
  85708. }
  85709. declare module BABYLON.GUI {
  85710. /**
  85711. * Class used to load GUI via XML.
  85712. */
  85713. export class XmlLoader {
  85714. private _nodes;
  85715. private _nodeTypes;
  85716. private _isLoaded;
  85717. private _objectAttributes;
  85718. private _parentClass;
  85719. /**
  85720. * Create a new xml loader
  85721. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  85722. */
  85723. constructor(parentClass?: null);
  85724. private _getChainElement;
  85725. private _getClassAttribute;
  85726. private _createGuiElement;
  85727. private _parseGrid;
  85728. private _parseElement;
  85729. private _prepareSourceElement;
  85730. private _parseElementsFromSource;
  85731. private _parseXml;
  85732. /**
  85733. * Gets if the loading has finished.
  85734. * @returns whether the loading has finished or not
  85735. */
  85736. isLoaded(): boolean;
  85737. /**
  85738. * Gets a loaded node / control by id.
  85739. * @param id the Controls id set in the xml
  85740. * @returns element of type Control
  85741. */
  85742. getNodeById(id: string): any;
  85743. /**
  85744. * Gets all loaded nodes / controls
  85745. * @returns Array of controls
  85746. */
  85747. getNodes(): any;
  85748. /**
  85749. * Initiates the xml layout loading
  85750. * @param xmlFile defines the xml layout to load
  85751. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  85752. * @param callback defines the callback called on layout load.
  85753. */
  85754. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  85755. }
  85756. }
  85757. declare module BABYLON.GUI {
  85758. /**
  85759. * Class used to create containers for controls
  85760. */
  85761. export class Container3D extends Control3D {
  85762. private _blockLayout;
  85763. /**
  85764. * Gets the list of child controls
  85765. */
  85766. protected _children: Control3D[];
  85767. /**
  85768. * Gets the list of child controls
  85769. */
  85770. get children(): Array<Control3D>;
  85771. /**
  85772. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  85773. * This is helpful to optimize layout operation when adding multiple children in a row
  85774. */
  85775. get blockLayout(): boolean;
  85776. set blockLayout(value: boolean);
  85777. /**
  85778. * Creates a new container
  85779. * @param name defines the container name
  85780. */
  85781. constructor(name?: string);
  85782. /**
  85783. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  85784. * @returns the current container
  85785. */
  85786. updateLayout(): Container3D;
  85787. /**
  85788. * Gets a boolean indicating if the given control is in the children of this control
  85789. * @param control defines the control to check
  85790. * @returns true if the control is in the child list
  85791. */
  85792. containsControl(control: Control3D): boolean;
  85793. /**
  85794. * Adds a control to the children of this control
  85795. * @param control defines the control to add
  85796. * @returns the current container
  85797. */
  85798. addControl(control: Control3D): Container3D;
  85799. /**
  85800. * This function will be called everytime a new control is added
  85801. */
  85802. protected _arrangeChildren(): void;
  85803. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85804. /**
  85805. * Removes a control from the children of this control
  85806. * @param control defines the control to remove
  85807. * @returns the current container
  85808. */
  85809. removeControl(control: Control3D): Container3D;
  85810. protected _getTypeName(): string;
  85811. /**
  85812. * Releases all associated resources
  85813. */
  85814. dispose(): void;
  85815. /** Control rotation will remain unchanged */
  85816. static readonly UNSET_ORIENTATION: number;
  85817. /** Control will rotate to make it look at sphere central axis */
  85818. static readonly FACEORIGIN_ORIENTATION: number;
  85819. /** Control will rotate to make it look back at sphere central axis */
  85820. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  85821. /** Control will rotate to look at z axis (0, 0, 1) */
  85822. static readonly FACEFORWARD_ORIENTATION: number;
  85823. /** Control will rotate to look at negative z axis (0, 0, -1) */
  85824. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  85825. }
  85826. }
  85827. declare module BABYLON.GUI {
  85828. /**
  85829. * Class used to manage 3D user interface
  85830. * @see https://doc.babylonjs.com/how_to/gui3d
  85831. */
  85832. export class GUI3DManager implements BABYLON.IDisposable {
  85833. private _scene;
  85834. private _sceneDisposeObserver;
  85835. private _utilityLayer;
  85836. private _rootContainer;
  85837. private _pointerObserver;
  85838. private _pointerOutObserver;
  85839. /** @hidden */
  85840. _lastPickedControl: Control3D;
  85841. /** @hidden */
  85842. _lastControlOver: {
  85843. [pointerId: number]: Control3D;
  85844. };
  85845. /** @hidden */
  85846. _lastControlDown: {
  85847. [pointerId: number]: Control3D;
  85848. };
  85849. /**
  85850. * BABYLON.Observable raised when the point picked by the pointer events changed
  85851. */
  85852. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  85853. /** @hidden */
  85854. _sharedMaterials: {
  85855. [key: string]: BABYLON.Material;
  85856. };
  85857. /** Gets the hosting scene */
  85858. get scene(): BABYLON.Scene;
  85859. /** Gets associated utility layer */
  85860. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  85861. /**
  85862. * Creates a new GUI3DManager
  85863. * @param scene
  85864. */
  85865. constructor(scene?: BABYLON.Scene);
  85866. private _handlePointerOut;
  85867. private _doPicking;
  85868. /**
  85869. * Gets the root container
  85870. */
  85871. get rootContainer(): Container3D;
  85872. /**
  85873. * Gets a boolean indicating if the given control is in the root child list
  85874. * @param control defines the control to check
  85875. * @returns true if the control is in the root child list
  85876. */
  85877. containsControl(control: Control3D): boolean;
  85878. /**
  85879. * Adds a control to the root child list
  85880. * @param control defines the control to add
  85881. * @returns the current manager
  85882. */
  85883. addControl(control: Control3D): GUI3DManager;
  85884. /**
  85885. * Removes a control from the root child list
  85886. * @param control defines the control to remove
  85887. * @returns the current container
  85888. */
  85889. removeControl(control: Control3D): GUI3DManager;
  85890. /**
  85891. * Releases all associated resources
  85892. */
  85893. dispose(): void;
  85894. }
  85895. }
  85896. declare module BABYLON.GUI {
  85897. /**
  85898. * Class used to transport BABYLON.Vector3 information for pointer events
  85899. */
  85900. export class Vector3WithInfo extends BABYLON.Vector3 {
  85901. /** defines the current mouse button index */
  85902. buttonIndex: number;
  85903. /**
  85904. * Creates a new Vector3WithInfo
  85905. * @param source defines the vector3 data to transport
  85906. * @param buttonIndex defines the current mouse button index
  85907. */
  85908. constructor(source: BABYLON.Vector3,
  85909. /** defines the current mouse button index */
  85910. buttonIndex?: number);
  85911. }
  85912. }
  85913. declare module BABYLON.GUI {
  85914. /**
  85915. * Class used as base class for controls
  85916. */
  85917. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  85918. /** Defines the control name */
  85919. name?: string | undefined;
  85920. /** @hidden */
  85921. _host: GUI3DManager;
  85922. private _node;
  85923. private _downCount;
  85924. private _enterCount;
  85925. private _downPointerIds;
  85926. private _isVisible;
  85927. /** Gets or sets the control position in world space */
  85928. get position(): BABYLON.Vector3;
  85929. set position(value: BABYLON.Vector3);
  85930. /** Gets or sets the control scaling in world space */
  85931. get scaling(): BABYLON.Vector3;
  85932. set scaling(value: BABYLON.Vector3);
  85933. /** Callback used to start pointer enter animation */
  85934. pointerEnterAnimation: () => void;
  85935. /** Callback used to start pointer out animation */
  85936. pointerOutAnimation: () => void;
  85937. /** Callback used to start pointer down animation */
  85938. pointerDownAnimation: () => void;
  85939. /** Callback used to start pointer up animation */
  85940. pointerUpAnimation: () => void;
  85941. /**
  85942. * An event triggered when the pointer move over the control
  85943. */
  85944. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  85945. /**
  85946. * An event triggered when the pointer move out of the control
  85947. */
  85948. onPointerOutObservable: BABYLON.Observable<Control3D>;
  85949. /**
  85950. * An event triggered when the pointer taps the control
  85951. */
  85952. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  85953. /**
  85954. * An event triggered when pointer is up
  85955. */
  85956. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  85957. /**
  85958. * An event triggered when a control is clicked on (with a mouse)
  85959. */
  85960. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  85961. /**
  85962. * An event triggered when pointer enters the control
  85963. */
  85964. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  85965. /**
  85966. * Gets or sets the parent container
  85967. */
  85968. parent: BABYLON.Nullable<Container3D>;
  85969. private _behaviors;
  85970. /**
  85971. * Gets the list of attached behaviors
  85972. * @see https://doc.babylonjs.com/features/behaviour
  85973. */
  85974. get behaviors(): BABYLON.Behavior<Control3D>[];
  85975. /**
  85976. * Attach a behavior to the control
  85977. * @see https://doc.babylonjs.com/features/behaviour
  85978. * @param behavior defines the behavior to attach
  85979. * @returns the current control
  85980. */
  85981. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85982. /**
  85983. * Remove an attached behavior
  85984. * @see https://doc.babylonjs.com/features/behaviour
  85985. * @param behavior defines the behavior to attach
  85986. * @returns the current control
  85987. */
  85988. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85989. /**
  85990. * Gets an attached behavior by name
  85991. * @param name defines the name of the behavior to look for
  85992. * @see https://doc.babylonjs.com/features/behaviour
  85993. * @returns null if behavior was not found else the requested behavior
  85994. */
  85995. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  85996. /** Gets or sets a boolean indicating if the control is visible */
  85997. get isVisible(): boolean;
  85998. set isVisible(value: boolean);
  85999. /**
  86000. * Creates a new control
  86001. * @param name defines the control name
  86002. */
  86003. constructor(
  86004. /** Defines the control name */
  86005. name?: string | undefined);
  86006. /**
  86007. * Gets a string representing the class name
  86008. */
  86009. get typeName(): string;
  86010. /**
  86011. * Get the current class name of the control.
  86012. * @returns current class name
  86013. */
  86014. getClassName(): string;
  86015. protected _getTypeName(): string;
  86016. /**
  86017. * Gets the transform node used by this control
  86018. */
  86019. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  86020. /**
  86021. * Gets the mesh used to render this control
  86022. */
  86023. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  86024. /**
  86025. * Link the control as child of the given node
  86026. * @param node defines the node to link to. Use null to unlink the control
  86027. * @returns the current control
  86028. */
  86029. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  86030. /** @hidden **/
  86031. _prepareNode(scene: BABYLON.Scene): void;
  86032. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  86033. /**
  86034. * Node creation.
  86035. * Can be overriden by children
  86036. * @param scene defines the scene where the node must be attached
  86037. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  86038. */
  86039. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86040. /**
  86041. * Affect a material to the given mesh
  86042. * @param mesh defines the mesh which will represent the control
  86043. */
  86044. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86045. /** @hidden */
  86046. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  86047. /** @hidden */
  86048. _onPointerEnter(target: Control3D): boolean;
  86049. /** @hidden */
  86050. _onPointerOut(target: Control3D): void;
  86051. /** @hidden */
  86052. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86053. /** @hidden */
  86054. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  86055. /** @hidden */
  86056. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  86057. /** @hidden */
  86058. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86059. /** @hidden */
  86060. _disposeNode(): void;
  86061. /**
  86062. * Releases all associated resources
  86063. */
  86064. dispose(): void;
  86065. }
  86066. }
  86067. declare module BABYLON.GUI {
  86068. /**
  86069. * Class used as a root to all buttons
  86070. */
  86071. export class AbstractButton3D extends Control3D {
  86072. /**
  86073. * Creates a new button
  86074. * @param name defines the control name
  86075. */
  86076. constructor(name?: string);
  86077. protected _getTypeName(): string;
  86078. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86079. }
  86080. }
  86081. declare module BABYLON.GUI {
  86082. /**
  86083. * Class used to create a button in 3D
  86084. */
  86085. export class Button3D extends AbstractButton3D {
  86086. /** @hidden */
  86087. protected _currentMaterial: BABYLON.Material;
  86088. private _facadeTexture;
  86089. private _content;
  86090. private _contentResolution;
  86091. private _contentScaleRatio;
  86092. /**
  86093. * Gets or sets the texture resolution used to render content (512 by default)
  86094. */
  86095. get contentResolution(): BABYLON.int;
  86096. set contentResolution(value: BABYLON.int);
  86097. /**
  86098. * Gets or sets the texture scale ratio used to render content (2 by default)
  86099. */
  86100. get contentScaleRatio(): number;
  86101. set contentScaleRatio(value: number);
  86102. protected _disposeFacadeTexture(): void;
  86103. protected _resetContent(): void;
  86104. /**
  86105. * Creates a new button
  86106. * @param name defines the control name
  86107. */
  86108. constructor(name?: string);
  86109. /**
  86110. * Gets or sets the GUI 2D content used to display the button's facade
  86111. */
  86112. get content(): Control;
  86113. set content(value: Control);
  86114. /**
  86115. * Apply the facade texture (created from the content property).
  86116. * This function can be overloaded by child classes
  86117. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86118. */
  86119. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86120. protected _getTypeName(): string;
  86121. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86122. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86123. /**
  86124. * Releases all associated resources
  86125. */
  86126. dispose(): void;
  86127. }
  86128. }
  86129. declare module BABYLON.GUI {
  86130. /**
  86131. * Abstract class used to create a container panel deployed on the surface of a volume
  86132. */
  86133. export abstract class VolumeBasedPanel extends Container3D {
  86134. private _columns;
  86135. private _rows;
  86136. private _rowThenColum;
  86137. private _orientation;
  86138. protected _cellWidth: number;
  86139. protected _cellHeight: number;
  86140. /**
  86141. * Gets or sets the distance between elements
  86142. */
  86143. margin: number;
  86144. /**
  86145. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86146. * | Value | Type | Description |
  86147. * | ----- | ----------------------------------- | ----------- |
  86148. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86149. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86150. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86151. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86152. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86153. */
  86154. get orientation(): number;
  86155. set orientation(value: number);
  86156. /**
  86157. * Gets or sets the number of columns requested (10 by default).
  86158. * The panel will automatically compute the number of rows based on number of child controls.
  86159. */
  86160. get columns(): BABYLON.int;
  86161. set columns(value: BABYLON.int);
  86162. /**
  86163. * Gets or sets a the number of rows requested.
  86164. * The panel will automatically compute the number of columns based on number of child controls.
  86165. */
  86166. get rows(): BABYLON.int;
  86167. set rows(value: BABYLON.int);
  86168. /**
  86169. * Creates new VolumeBasedPanel
  86170. */
  86171. constructor();
  86172. protected _arrangeChildren(): void;
  86173. /** Child classes must implement this function to provide correct control positioning */
  86174. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86175. /** Child classes can implement this function to provide additional processing */
  86176. protected _finalProcessing(): void;
  86177. }
  86178. }
  86179. declare module BABYLON.GUI {
  86180. /**
  86181. * Class used to create a container panel deployed on the surface of a cylinder
  86182. */
  86183. export class CylinderPanel extends VolumeBasedPanel {
  86184. private _radius;
  86185. /**
  86186. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  86187. */
  86188. get radius(): BABYLON.float;
  86189. set radius(value: BABYLON.float);
  86190. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86191. private _cylindricalMapping;
  86192. }
  86193. }
  86194. declare module BABYLON.GUI {
  86195. /** @hidden */
  86196. export var fluentVertexShader: {
  86197. name: string;
  86198. shader: string;
  86199. };
  86200. }
  86201. declare module BABYLON.GUI {
  86202. /** @hidden */
  86203. export var fluentPixelShader: {
  86204. name: string;
  86205. shader: string;
  86206. };
  86207. }
  86208. declare module BABYLON.GUI {
  86209. /** @hidden */
  86210. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86211. INNERGLOW: boolean;
  86212. BORDER: boolean;
  86213. HOVERLIGHT: boolean;
  86214. TEXTURE: boolean;
  86215. constructor();
  86216. }
  86217. /**
  86218. * Class used to render controls with fluent desgin
  86219. */
  86220. export class FluentMaterial extends BABYLON.PushMaterial {
  86221. /**
  86222. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86223. */
  86224. innerGlowColorIntensity: number;
  86225. /**
  86226. * Gets or sets the inner glow color (white by default)
  86227. */
  86228. innerGlowColor: BABYLON.Color3;
  86229. /**
  86230. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86231. */
  86232. albedoColor: BABYLON.Color3;
  86233. /**
  86234. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86235. */
  86236. renderBorders: boolean;
  86237. /**
  86238. * Gets or sets border width (default is 0.5)
  86239. */
  86240. borderWidth: number;
  86241. /**
  86242. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86243. */
  86244. edgeSmoothingValue: number;
  86245. /**
  86246. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86247. */
  86248. borderMinValue: number;
  86249. /**
  86250. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86251. */
  86252. renderHoverLight: boolean;
  86253. /**
  86254. * Gets or sets the radius used to render the hover light (default is 1.0)
  86255. */
  86256. hoverRadius: number;
  86257. /**
  86258. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86259. */
  86260. hoverColor: BABYLON.Color4;
  86261. /**
  86262. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86263. */
  86264. hoverPosition: BABYLON.Vector3;
  86265. private _albedoTexture;
  86266. /** Gets or sets the texture to use for albedo color */
  86267. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86268. /**
  86269. * Creates a new Fluent material
  86270. * @param name defines the name of the material
  86271. * @param scene defines the hosting scene
  86272. */
  86273. constructor(name: string, scene: BABYLON.Scene);
  86274. needAlphaBlending(): boolean;
  86275. needAlphaTesting(): boolean;
  86276. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86277. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86278. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86279. getActiveTextures(): BABYLON.BaseTexture[];
  86280. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86281. dispose(forceDisposeEffect?: boolean): void;
  86282. clone(name: string): FluentMaterial;
  86283. serialize(): any;
  86284. getClassName(): string;
  86285. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86286. }
  86287. }
  86288. declare module BABYLON.GUI {
  86289. /**
  86290. * Class used to create a holographic button in 3D
  86291. */
  86292. export class HolographicButton extends Button3D {
  86293. private _backPlate;
  86294. private _textPlate;
  86295. private _frontPlate;
  86296. private _text;
  86297. private _imageUrl;
  86298. private _shareMaterials;
  86299. private _frontMaterial;
  86300. private _backMaterial;
  86301. private _plateMaterial;
  86302. private _pickedPointObserver;
  86303. private _tooltipFade;
  86304. private _tooltipTextBlock;
  86305. private _tooltipTexture;
  86306. private _tooltipMesh;
  86307. private _tooltipHoverObserver;
  86308. private _tooltipOutObserver;
  86309. private _disposeTooltip;
  86310. /**
  86311. * Rendering ground id of all the mesh in the button
  86312. */
  86313. set renderingGroupId(id: number);
  86314. get renderingGroupId(): number;
  86315. /**
  86316. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86317. */
  86318. set tooltipText(text: BABYLON.Nullable<string>);
  86319. get tooltipText(): BABYLON.Nullable<string>;
  86320. /**
  86321. * Gets or sets text for the button
  86322. */
  86323. get text(): string;
  86324. set text(value: string);
  86325. /**
  86326. * Gets or sets the image url for the button
  86327. */
  86328. get imageUrl(): string;
  86329. set imageUrl(value: string);
  86330. /**
  86331. * Gets the back material used by this button
  86332. */
  86333. get backMaterial(): FluentMaterial;
  86334. /**
  86335. * Gets the front material used by this button
  86336. */
  86337. get frontMaterial(): FluentMaterial;
  86338. /**
  86339. * Gets the plate material used by this button
  86340. */
  86341. get plateMaterial(): BABYLON.StandardMaterial;
  86342. /**
  86343. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86344. */
  86345. get shareMaterials(): boolean;
  86346. /**
  86347. * Creates a new button
  86348. * @param name defines the control name
  86349. */
  86350. constructor(name?: string, shareMaterials?: boolean);
  86351. protected _getTypeName(): string;
  86352. private _rebuildContent;
  86353. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86354. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86355. private _createBackMaterial;
  86356. private _createFrontMaterial;
  86357. private _createPlateMaterial;
  86358. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86359. /**
  86360. * Releases all associated resources
  86361. */
  86362. dispose(): void;
  86363. }
  86364. }
  86365. declare module BABYLON.GUI {
  86366. /**
  86367. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86368. */
  86369. export class MeshButton3D extends Button3D {
  86370. /** @hidden */
  86371. protected _currentMesh: BABYLON.Mesh;
  86372. /**
  86373. * Creates a new 3D button based on a mesh
  86374. * @param mesh mesh to become a 3D button
  86375. * @param name defines the control name
  86376. */
  86377. constructor(mesh: BABYLON.Mesh, name?: string);
  86378. protected _getTypeName(): string;
  86379. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86380. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86381. }
  86382. }
  86383. declare module BABYLON.GUI {
  86384. /**
  86385. * Class used to create a container panel deployed on the surface of a plane
  86386. */
  86387. export class PlanePanel extends VolumeBasedPanel {
  86388. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86389. }
  86390. }
  86391. declare module BABYLON.GUI {
  86392. /**
  86393. * Class used to create a container panel where items get randomized planar mapping
  86394. */
  86395. export class ScatterPanel extends VolumeBasedPanel {
  86396. private _iteration;
  86397. /**
  86398. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86399. */
  86400. get iteration(): BABYLON.float;
  86401. set iteration(value: BABYLON.float);
  86402. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86403. private _scatterMapping;
  86404. protected _finalProcessing(): void;
  86405. }
  86406. }
  86407. declare module BABYLON.GUI {
  86408. /**
  86409. * Class used to create a container panel deployed on the surface of a sphere
  86410. */
  86411. export class SpherePanel extends VolumeBasedPanel {
  86412. private _radius;
  86413. /**
  86414. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86415. */
  86416. get radius(): BABYLON.float;
  86417. set radius(value: BABYLON.float);
  86418. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86419. private _sphericalMapping;
  86420. }
  86421. }
  86422. declare module BABYLON.GUI {
  86423. /**
  86424. * Class used to create a stack panel in 3D on XY plane
  86425. */
  86426. export class StackPanel3D extends Container3D {
  86427. private _isVertical;
  86428. /**
  86429. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86430. */
  86431. get isVertical(): boolean;
  86432. set isVertical(value: boolean);
  86433. /**
  86434. * Gets or sets the distance between elements
  86435. */
  86436. margin: number;
  86437. /**
  86438. * Creates new StackPanel
  86439. * @param isVertical
  86440. */
  86441. constructor(isVertical?: boolean);
  86442. protected _arrangeChildren(): void;
  86443. }
  86444. }
  86445. declare module BABYLON {
  86446. /**
  86447. * Configuration for glTF validation
  86448. */
  86449. export interface IGLTFValidationConfiguration {
  86450. /**
  86451. * The url of the glTF validator.
  86452. */
  86453. url: string;
  86454. }
  86455. /**
  86456. * glTF validation
  86457. */
  86458. export class GLTFValidation {
  86459. /**
  86460. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86461. */
  86462. static Configuration: IGLTFValidationConfiguration;
  86463. private static _LoadScriptPromise;
  86464. /**
  86465. * Validate a glTF asset using the glTF-Validator.
  86466. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86467. * @param rootUrl The root url for the glTF
  86468. * @param fileName The file name for the glTF
  86469. * @param getExternalResource The callback to get external resources for the glTF validator
  86470. * @returns A promise that resolves with the glTF validation results once complete
  86471. */
  86472. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86473. }
  86474. }
  86475. declare module BABYLON {
  86476. /**
  86477. * Mode that determines the coordinate system to use.
  86478. */
  86479. export enum GLTFLoaderCoordinateSystemMode {
  86480. /**
  86481. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86482. */
  86483. AUTO = 0,
  86484. /**
  86485. * Sets the useRightHandedSystem flag on the scene.
  86486. */
  86487. FORCE_RIGHT_HANDED = 1
  86488. }
  86489. /**
  86490. * Mode that determines what animations will start.
  86491. */
  86492. export enum GLTFLoaderAnimationStartMode {
  86493. /**
  86494. * No animation will start.
  86495. */
  86496. NONE = 0,
  86497. /**
  86498. * The first animation will start.
  86499. */
  86500. FIRST = 1,
  86501. /**
  86502. * All animations will start.
  86503. */
  86504. ALL = 2
  86505. }
  86506. /**
  86507. * Interface that contains the data for the glTF asset.
  86508. */
  86509. export interface IGLTFLoaderData {
  86510. /**
  86511. * The object that represents the glTF JSON.
  86512. */
  86513. json: Object;
  86514. /**
  86515. * The BIN chunk of a binary glTF.
  86516. */
  86517. bin: Nullable<IDataBuffer>;
  86518. }
  86519. /**
  86520. * Interface for extending the loader.
  86521. */
  86522. export interface IGLTFLoaderExtension {
  86523. /**
  86524. * The name of this extension.
  86525. */
  86526. readonly name: string;
  86527. /**
  86528. * Defines whether this extension is enabled.
  86529. */
  86530. enabled: boolean;
  86531. /**
  86532. * Defines the order of this extension.
  86533. * The loader sorts the extensions using these values when loading.
  86534. */
  86535. order?: number;
  86536. }
  86537. /**
  86538. * Loader state.
  86539. */
  86540. export enum GLTFLoaderState {
  86541. /**
  86542. * The asset is loading.
  86543. */
  86544. LOADING = 0,
  86545. /**
  86546. * The asset is ready for rendering.
  86547. */
  86548. READY = 1,
  86549. /**
  86550. * The asset is completely loaded.
  86551. */
  86552. COMPLETE = 2
  86553. }
  86554. /** @hidden */
  86555. export interface IGLTFLoader extends IDisposable {
  86556. readonly state: Nullable<GLTFLoaderState>;
  86557. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  86558. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  86559. }
  86560. /**
  86561. * File loader for loading glTF files into a scene.
  86562. */
  86563. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  86564. /** @hidden */
  86565. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86566. /** @hidden */
  86567. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86568. /**
  86569. * Raised when the asset has been parsed
  86570. */
  86571. onParsedObservable: Observable<IGLTFLoaderData>;
  86572. private _onParsedObserver;
  86573. /**
  86574. * Raised when the asset has been parsed
  86575. */
  86576. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  86577. /**
  86578. * 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.
  86579. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  86580. * Defaults to true.
  86581. * @hidden
  86582. */
  86583. static IncrementalLoading: boolean;
  86584. /**
  86585. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  86586. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  86587. * @hidden
  86588. */
  86589. static HomogeneousCoordinates: boolean;
  86590. /**
  86591. * The coordinate system mode. Defaults to AUTO.
  86592. */
  86593. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  86594. /**
  86595. * The animation start mode. Defaults to FIRST.
  86596. */
  86597. animationStartMode: GLTFLoaderAnimationStartMode;
  86598. /**
  86599. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  86600. */
  86601. compileMaterials: boolean;
  86602. /**
  86603. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  86604. */
  86605. useClipPlane: boolean;
  86606. /**
  86607. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  86608. */
  86609. compileShadowGenerators: boolean;
  86610. /**
  86611. * Defines if the Alpha blended materials are only applied as coverage.
  86612. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  86613. * If true, no extra effects are applied to transparent pixels.
  86614. */
  86615. transparencyAsCoverage: boolean;
  86616. /**
  86617. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  86618. * Enabling will disable offline support and glTF validator.
  86619. * Defaults to false.
  86620. */
  86621. useRangeRequests: boolean;
  86622. /**
  86623. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  86624. */
  86625. createInstances: boolean;
  86626. /**
  86627. * 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.
  86628. */
  86629. alwaysComputeBoundingBox: boolean;
  86630. /**
  86631. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  86632. */
  86633. loadAllMaterials: boolean;
  86634. /**
  86635. * Function called before loading a url referenced by the asset.
  86636. */
  86637. preprocessUrlAsync: (url: string) => Promise<string>;
  86638. /**
  86639. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86640. * 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, ...)
  86641. */
  86642. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  86643. private _onMeshLoadedObserver;
  86644. /**
  86645. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86646. * 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, ...)
  86647. */
  86648. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  86649. /**
  86650. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  86651. */
  86652. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  86653. private _onTextureLoadedObserver;
  86654. /**
  86655. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  86656. */
  86657. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  86658. /**
  86659. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  86660. */
  86661. readonly onMaterialLoadedObservable: Observable<Material>;
  86662. private _onMaterialLoadedObserver;
  86663. /**
  86664. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  86665. */
  86666. set onMaterialLoaded(callback: (material: Material) => void);
  86667. /**
  86668. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  86669. */
  86670. readonly onCameraLoadedObservable: Observable<Camera>;
  86671. private _onCameraLoadedObserver;
  86672. /**
  86673. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  86674. */
  86675. set onCameraLoaded(callback: (camera: Camera) => void);
  86676. /**
  86677. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  86678. * For assets with LODs, raised when all of the LODs are complete.
  86679. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86680. */
  86681. readonly onCompleteObservable: Observable<void>;
  86682. private _onCompleteObserver;
  86683. /**
  86684. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  86685. * For assets with LODs, raised when all of the LODs are complete.
  86686. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86687. */
  86688. set onComplete(callback: () => void);
  86689. /**
  86690. * Observable raised when an error occurs.
  86691. */
  86692. readonly onErrorObservable: Observable<any>;
  86693. private _onErrorObserver;
  86694. /**
  86695. * Callback raised when an error occurs.
  86696. */
  86697. set onError(callback: (reason: any) => void);
  86698. /**
  86699. * Observable raised after the loader is disposed.
  86700. */
  86701. readonly onDisposeObservable: Observable<void>;
  86702. private _onDisposeObserver;
  86703. /**
  86704. * Callback raised after the loader is disposed.
  86705. */
  86706. set onDispose(callback: () => void);
  86707. /**
  86708. * Observable raised after a loader extension is created.
  86709. * Set additional options for a loader extension in this event.
  86710. */
  86711. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  86712. private _onExtensionLoadedObserver;
  86713. /**
  86714. * Callback raised after a loader extension is created.
  86715. */
  86716. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  86717. /**
  86718. * Defines if the loader logging is enabled.
  86719. */
  86720. get loggingEnabled(): boolean;
  86721. set loggingEnabled(value: boolean);
  86722. /**
  86723. * Defines if the loader should capture performance counters.
  86724. */
  86725. get capturePerformanceCounters(): boolean;
  86726. set capturePerformanceCounters(value: boolean);
  86727. /**
  86728. * Defines if the loader should validate the asset.
  86729. */
  86730. validate: boolean;
  86731. /**
  86732. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  86733. */
  86734. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  86735. private _onValidatedObserver;
  86736. /**
  86737. * Callback raised after a loader extension is created.
  86738. */
  86739. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  86740. private _loader;
  86741. private _progressCallback?;
  86742. private _requests;
  86743. private static magicBase64Encoded;
  86744. /**
  86745. * Name of the loader ("gltf")
  86746. */
  86747. name: string;
  86748. /** @hidden */
  86749. extensions: ISceneLoaderPluginExtensions;
  86750. /**
  86751. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  86752. */
  86753. dispose(): void;
  86754. /** @hidden */
  86755. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86756. /** @hidden */
  86757. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86758. /** @hidden */
  86759. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  86760. /** @hidden */
  86761. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  86762. /** @hidden */
  86763. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  86764. /** @hidden */
  86765. canDirectLoad(data: string): boolean;
  86766. /** @hidden */
  86767. directLoad(scene: Scene, data: string): Promise<any>;
  86768. /**
  86769. * The callback that allows custom handling of the root url based on the response url.
  86770. * @param rootUrl the original root url
  86771. * @param responseURL the response url if available
  86772. * @returns the new root url
  86773. */
  86774. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  86775. /** @hidden */
  86776. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  86777. /**
  86778. * The loader state or null if the loader is not active.
  86779. */
  86780. get loaderState(): Nullable<GLTFLoaderState>;
  86781. /**
  86782. * Returns a promise that resolves when the asset is completely loaded.
  86783. * @returns a promise that resolves when the asset is completely loaded.
  86784. */
  86785. whenCompleteAsync(): Promise<void>;
  86786. /** @hidden */
  86787. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  86788. /** @hidden */
  86789. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  86790. private _onProgress;
  86791. private _validate;
  86792. private _getLoader;
  86793. private _parseJson;
  86794. private _unpackBinaryAsync;
  86795. private _unpackBinaryV1Async;
  86796. private _unpackBinaryV2Async;
  86797. private static _parseVersion;
  86798. private static _compareVersion;
  86799. private static readonly _logSpaces;
  86800. private _logIndentLevel;
  86801. private _loggingEnabled;
  86802. /** @hidden */
  86803. _log: (message: string) => void;
  86804. /** @hidden */
  86805. _logOpen(message: string): void;
  86806. /** @hidden */
  86807. _logClose(): void;
  86808. private _logEnabled;
  86809. private _logDisabled;
  86810. private _capturePerformanceCounters;
  86811. /** @hidden */
  86812. _startPerformanceCounter: (counterName: string) => void;
  86813. /** @hidden */
  86814. _endPerformanceCounter: (counterName: string) => void;
  86815. private _startPerformanceCounterEnabled;
  86816. private _startPerformanceCounterDisabled;
  86817. private _endPerformanceCounterEnabled;
  86818. private _endPerformanceCounterDisabled;
  86819. }
  86820. }
  86821. declare module BABYLON.GLTF1 {
  86822. /**
  86823. * Enums
  86824. * @hidden
  86825. */
  86826. export enum EComponentType {
  86827. BYTE = 5120,
  86828. UNSIGNED_BYTE = 5121,
  86829. SHORT = 5122,
  86830. UNSIGNED_SHORT = 5123,
  86831. FLOAT = 5126
  86832. }
  86833. /** @hidden */
  86834. export enum EShaderType {
  86835. FRAGMENT = 35632,
  86836. VERTEX = 35633
  86837. }
  86838. /** @hidden */
  86839. export enum EParameterType {
  86840. BYTE = 5120,
  86841. UNSIGNED_BYTE = 5121,
  86842. SHORT = 5122,
  86843. UNSIGNED_SHORT = 5123,
  86844. INT = 5124,
  86845. UNSIGNED_INT = 5125,
  86846. FLOAT = 5126,
  86847. FLOAT_VEC2 = 35664,
  86848. FLOAT_VEC3 = 35665,
  86849. FLOAT_VEC4 = 35666,
  86850. INT_VEC2 = 35667,
  86851. INT_VEC3 = 35668,
  86852. INT_VEC4 = 35669,
  86853. BOOL = 35670,
  86854. BOOL_VEC2 = 35671,
  86855. BOOL_VEC3 = 35672,
  86856. BOOL_VEC4 = 35673,
  86857. FLOAT_MAT2 = 35674,
  86858. FLOAT_MAT3 = 35675,
  86859. FLOAT_MAT4 = 35676,
  86860. SAMPLER_2D = 35678
  86861. }
  86862. /** @hidden */
  86863. export enum ETextureWrapMode {
  86864. CLAMP_TO_EDGE = 33071,
  86865. MIRRORED_REPEAT = 33648,
  86866. REPEAT = 10497
  86867. }
  86868. /** @hidden */
  86869. export enum ETextureFilterType {
  86870. NEAREST = 9728,
  86871. LINEAR = 9728,
  86872. NEAREST_MIPMAP_NEAREST = 9984,
  86873. LINEAR_MIPMAP_NEAREST = 9985,
  86874. NEAREST_MIPMAP_LINEAR = 9986,
  86875. LINEAR_MIPMAP_LINEAR = 9987
  86876. }
  86877. /** @hidden */
  86878. export enum ETextureFormat {
  86879. ALPHA = 6406,
  86880. RGB = 6407,
  86881. RGBA = 6408,
  86882. LUMINANCE = 6409,
  86883. LUMINANCE_ALPHA = 6410
  86884. }
  86885. /** @hidden */
  86886. export enum ECullingType {
  86887. FRONT = 1028,
  86888. BACK = 1029,
  86889. FRONT_AND_BACK = 1032
  86890. }
  86891. /** @hidden */
  86892. export enum EBlendingFunction {
  86893. ZERO = 0,
  86894. ONE = 1,
  86895. SRC_COLOR = 768,
  86896. ONE_MINUS_SRC_COLOR = 769,
  86897. DST_COLOR = 774,
  86898. ONE_MINUS_DST_COLOR = 775,
  86899. SRC_ALPHA = 770,
  86900. ONE_MINUS_SRC_ALPHA = 771,
  86901. DST_ALPHA = 772,
  86902. ONE_MINUS_DST_ALPHA = 773,
  86903. CONSTANT_COLOR = 32769,
  86904. ONE_MINUS_CONSTANT_COLOR = 32770,
  86905. CONSTANT_ALPHA = 32771,
  86906. ONE_MINUS_CONSTANT_ALPHA = 32772,
  86907. SRC_ALPHA_SATURATE = 776
  86908. }
  86909. /** @hidden */
  86910. export interface IGLTFProperty {
  86911. extensions?: {
  86912. [key: string]: any;
  86913. };
  86914. extras?: Object;
  86915. }
  86916. /** @hidden */
  86917. export interface IGLTFChildRootProperty extends IGLTFProperty {
  86918. name?: string;
  86919. }
  86920. /** @hidden */
  86921. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  86922. bufferView: string;
  86923. byteOffset: number;
  86924. byteStride: number;
  86925. count: number;
  86926. type: string;
  86927. componentType: EComponentType;
  86928. max?: number[];
  86929. min?: number[];
  86930. name?: string;
  86931. }
  86932. /** @hidden */
  86933. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  86934. buffer: string;
  86935. byteOffset: number;
  86936. byteLength: number;
  86937. byteStride: number;
  86938. target?: number;
  86939. }
  86940. /** @hidden */
  86941. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  86942. uri: string;
  86943. byteLength?: number;
  86944. type?: string;
  86945. }
  86946. /** @hidden */
  86947. export interface IGLTFShader extends IGLTFChildRootProperty {
  86948. uri: string;
  86949. type: EShaderType;
  86950. }
  86951. /** @hidden */
  86952. export interface IGLTFProgram extends IGLTFChildRootProperty {
  86953. attributes: string[];
  86954. fragmentShader: string;
  86955. vertexShader: string;
  86956. }
  86957. /** @hidden */
  86958. export interface IGLTFTechniqueParameter {
  86959. type: number;
  86960. count?: number;
  86961. semantic?: string;
  86962. node?: string;
  86963. value?: number | boolean | string | Array<any>;
  86964. source?: string;
  86965. babylonValue?: any;
  86966. }
  86967. /** @hidden */
  86968. export interface IGLTFTechniqueCommonProfile {
  86969. lightingModel: string;
  86970. texcoordBindings: Object;
  86971. parameters?: Array<any>;
  86972. }
  86973. /** @hidden */
  86974. export interface IGLTFTechniqueStatesFunctions {
  86975. blendColor?: number[];
  86976. blendEquationSeparate?: number[];
  86977. blendFuncSeparate?: number[];
  86978. colorMask: boolean[];
  86979. cullFace: number[];
  86980. }
  86981. /** @hidden */
  86982. export interface IGLTFTechniqueStates {
  86983. enable: number[];
  86984. functions: IGLTFTechniqueStatesFunctions;
  86985. }
  86986. /** @hidden */
  86987. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  86988. parameters: {
  86989. [key: string]: IGLTFTechniqueParameter;
  86990. };
  86991. program: string;
  86992. attributes: {
  86993. [key: string]: string;
  86994. };
  86995. uniforms: {
  86996. [key: string]: string;
  86997. };
  86998. states: IGLTFTechniqueStates;
  86999. }
  87000. /** @hidden */
  87001. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  87002. technique?: string;
  87003. values: string[];
  87004. }
  87005. /** @hidden */
  87006. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  87007. attributes: {
  87008. [key: string]: string;
  87009. };
  87010. indices: string;
  87011. material: string;
  87012. mode?: number;
  87013. }
  87014. /** @hidden */
  87015. export interface IGLTFMesh extends IGLTFChildRootProperty {
  87016. primitives: IGLTFMeshPrimitive[];
  87017. }
  87018. /** @hidden */
  87019. export interface IGLTFImage extends IGLTFChildRootProperty {
  87020. uri: string;
  87021. }
  87022. /** @hidden */
  87023. export interface IGLTFSampler extends IGLTFChildRootProperty {
  87024. magFilter?: number;
  87025. minFilter?: number;
  87026. wrapS?: number;
  87027. wrapT?: number;
  87028. }
  87029. /** @hidden */
  87030. export interface IGLTFTexture extends IGLTFChildRootProperty {
  87031. sampler: string;
  87032. source: string;
  87033. format?: ETextureFormat;
  87034. internalFormat?: ETextureFormat;
  87035. target?: number;
  87036. type?: number;
  87037. babylonTexture?: Texture;
  87038. }
  87039. /** @hidden */
  87040. export interface IGLTFAmbienLight {
  87041. color?: number[];
  87042. }
  87043. /** @hidden */
  87044. export interface IGLTFDirectionalLight {
  87045. color?: number[];
  87046. }
  87047. /** @hidden */
  87048. export interface IGLTFPointLight {
  87049. color?: number[];
  87050. constantAttenuation?: number;
  87051. linearAttenuation?: number;
  87052. quadraticAttenuation?: number;
  87053. }
  87054. /** @hidden */
  87055. export interface IGLTFSpotLight {
  87056. color?: number[];
  87057. constantAttenuation?: number;
  87058. fallOfAngle?: number;
  87059. fallOffExponent?: number;
  87060. linearAttenuation?: number;
  87061. quadraticAttenuation?: number;
  87062. }
  87063. /** @hidden */
  87064. export interface IGLTFLight extends IGLTFChildRootProperty {
  87065. type: string;
  87066. }
  87067. /** @hidden */
  87068. export interface IGLTFCameraOrthographic {
  87069. xmag: number;
  87070. ymag: number;
  87071. zfar: number;
  87072. znear: number;
  87073. }
  87074. /** @hidden */
  87075. export interface IGLTFCameraPerspective {
  87076. aspectRatio: number;
  87077. yfov: number;
  87078. zfar: number;
  87079. znear: number;
  87080. }
  87081. /** @hidden */
  87082. export interface IGLTFCamera extends IGLTFChildRootProperty {
  87083. type: string;
  87084. }
  87085. /** @hidden */
  87086. export interface IGLTFAnimationChannelTarget {
  87087. id: string;
  87088. path: string;
  87089. }
  87090. /** @hidden */
  87091. export interface IGLTFAnimationChannel {
  87092. sampler: string;
  87093. target: IGLTFAnimationChannelTarget;
  87094. }
  87095. /** @hidden */
  87096. export interface IGLTFAnimationSampler {
  87097. input: string;
  87098. output: string;
  87099. interpolation?: string;
  87100. }
  87101. /** @hidden */
  87102. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  87103. channels?: IGLTFAnimationChannel[];
  87104. parameters?: {
  87105. [key: string]: string;
  87106. };
  87107. samplers?: {
  87108. [key: string]: IGLTFAnimationSampler;
  87109. };
  87110. }
  87111. /** @hidden */
  87112. export interface IGLTFNodeInstanceSkin {
  87113. skeletons: string[];
  87114. skin: string;
  87115. meshes: string[];
  87116. }
  87117. /** @hidden */
  87118. export interface IGLTFSkins extends IGLTFChildRootProperty {
  87119. bindShapeMatrix: number[];
  87120. inverseBindMatrices: string;
  87121. jointNames: string[];
  87122. babylonSkeleton?: Skeleton;
  87123. }
  87124. /** @hidden */
  87125. export interface IGLTFNode extends IGLTFChildRootProperty {
  87126. camera?: string;
  87127. children: string[];
  87128. skin?: string;
  87129. jointName?: string;
  87130. light?: string;
  87131. matrix: number[];
  87132. mesh?: string;
  87133. meshes?: string[];
  87134. rotation?: number[];
  87135. scale?: number[];
  87136. translation?: number[];
  87137. babylonNode?: Node;
  87138. }
  87139. /** @hidden */
  87140. export interface IGLTFScene extends IGLTFChildRootProperty {
  87141. nodes: string[];
  87142. }
  87143. /** @hidden */
  87144. export interface IGLTFRuntime {
  87145. extensions: {
  87146. [key: string]: any;
  87147. };
  87148. accessors: {
  87149. [key: string]: IGLTFAccessor;
  87150. };
  87151. buffers: {
  87152. [key: string]: IGLTFBuffer;
  87153. };
  87154. bufferViews: {
  87155. [key: string]: IGLTFBufferView;
  87156. };
  87157. meshes: {
  87158. [key: string]: IGLTFMesh;
  87159. };
  87160. lights: {
  87161. [key: string]: IGLTFLight;
  87162. };
  87163. cameras: {
  87164. [key: string]: IGLTFCamera;
  87165. };
  87166. nodes: {
  87167. [key: string]: IGLTFNode;
  87168. };
  87169. images: {
  87170. [key: string]: IGLTFImage;
  87171. };
  87172. textures: {
  87173. [key: string]: IGLTFTexture;
  87174. };
  87175. shaders: {
  87176. [key: string]: IGLTFShader;
  87177. };
  87178. programs: {
  87179. [key: string]: IGLTFProgram;
  87180. };
  87181. samplers: {
  87182. [key: string]: IGLTFSampler;
  87183. };
  87184. techniques: {
  87185. [key: string]: IGLTFTechnique;
  87186. };
  87187. materials: {
  87188. [key: string]: IGLTFMaterial;
  87189. };
  87190. animations: {
  87191. [key: string]: IGLTFAnimation;
  87192. };
  87193. skins: {
  87194. [key: string]: IGLTFSkins;
  87195. };
  87196. currentScene?: Object;
  87197. scenes: {
  87198. [key: string]: IGLTFScene;
  87199. };
  87200. extensionsUsed: string[];
  87201. extensionsRequired?: string[];
  87202. buffersCount: number;
  87203. shaderscount: number;
  87204. scene: Scene;
  87205. rootUrl: string;
  87206. loadedBufferCount: number;
  87207. loadedBufferViews: {
  87208. [name: string]: ArrayBufferView;
  87209. };
  87210. loadedShaderCount: number;
  87211. importOnlyMeshes: boolean;
  87212. importMeshesNames?: string[];
  87213. dummyNodes: Node[];
  87214. forAssetContainer: boolean;
  87215. }
  87216. /** @hidden */
  87217. export interface INodeToRoot {
  87218. bone: Bone;
  87219. node: IGLTFNode;
  87220. id: string;
  87221. }
  87222. /** @hidden */
  87223. export interface IJointNode {
  87224. node: IGLTFNode;
  87225. id: string;
  87226. }
  87227. }
  87228. declare module BABYLON.GLTF1 {
  87229. /**
  87230. * Utils functions for GLTF
  87231. * @hidden
  87232. */
  87233. export class GLTFUtils {
  87234. /**
  87235. * Sets the given "parameter" matrix
  87236. * @param scene: the Scene object
  87237. * @param source: the source node where to pick the matrix
  87238. * @param parameter: the GLTF technique parameter
  87239. * @param uniformName: the name of the shader's uniform
  87240. * @param shaderMaterial: the shader material
  87241. */
  87242. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87243. /**
  87244. * Sets the given "parameter" matrix
  87245. * @param shaderMaterial: the shader material
  87246. * @param uniform: the name of the shader's uniform
  87247. * @param value: the value of the uniform
  87248. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87249. */
  87250. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87251. /**
  87252. * Returns the wrap mode of the texture
  87253. * @param mode: the mode value
  87254. */
  87255. static GetWrapMode(mode: number): number;
  87256. /**
  87257. * Returns the byte stride giving an accessor
  87258. * @param accessor: the GLTF accessor objet
  87259. */
  87260. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87261. /**
  87262. * Returns the texture filter mode giving a mode value
  87263. * @param mode: the filter mode value
  87264. */
  87265. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87266. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87267. /**
  87268. * Returns a buffer from its accessor
  87269. * @param gltfRuntime: the GLTF runtime
  87270. * @param accessor: the GLTF accessor
  87271. */
  87272. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87273. /**
  87274. * Decodes a buffer view into a string
  87275. * @param view: the buffer view
  87276. */
  87277. static DecodeBufferToText(view: ArrayBufferView): string;
  87278. /**
  87279. * Returns the default material of gltf. Related to
  87280. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87281. * @param scene: the Babylon.js scene
  87282. */
  87283. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87284. private static _DefaultMaterial;
  87285. }
  87286. }
  87287. declare module BABYLON.GLTF1 {
  87288. /**
  87289. * Implementation of the base glTF spec
  87290. * @hidden
  87291. */
  87292. export class GLTFLoaderBase {
  87293. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87294. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87295. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87296. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87297. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87298. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87299. }
  87300. /**
  87301. * glTF V1 Loader
  87302. * @hidden
  87303. */
  87304. export class GLTFLoader implements IGLTFLoader {
  87305. static Extensions: {
  87306. [name: string]: GLTFLoaderExtension;
  87307. };
  87308. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87309. state: Nullable<GLTFLoaderState>;
  87310. dispose(): void;
  87311. private _importMeshAsync;
  87312. /**
  87313. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87314. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87315. * @param scene the scene the meshes should be added to
  87316. * @param forAssetContainer defines if the entities must be stored in the scene
  87317. * @param data gltf data containing information of the meshes in a loaded file
  87318. * @param rootUrl root url to load from
  87319. * @param onProgress event that fires when loading progress has occured
  87320. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87321. */
  87322. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87323. private _loadAsync;
  87324. /**
  87325. * Imports all objects from a loaded gltf file and adds them to the scene
  87326. * @param scene the scene the objects should be added to
  87327. * @param data gltf data containing information of the meshes in a loaded file
  87328. * @param rootUrl root url to load from
  87329. * @param onProgress event that fires when loading progress has occured
  87330. * @returns a promise which completes when objects have been loaded to the scene
  87331. */
  87332. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87333. private _loadShadersAsync;
  87334. private _loadBuffersAsync;
  87335. private _createNodes;
  87336. }
  87337. /** @hidden */
  87338. export abstract class GLTFLoaderExtension {
  87339. private _name;
  87340. constructor(name: string);
  87341. get name(): string;
  87342. /**
  87343. * Defines an override for loading the runtime
  87344. * Return true to stop further extensions from loading the runtime
  87345. */
  87346. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87347. /**
  87348. * Defines an onverride for creating gltf runtime
  87349. * Return true to stop further extensions from creating the runtime
  87350. */
  87351. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87352. /**
  87353. * Defines an override for loading buffers
  87354. * Return true to stop further extensions from loading this buffer
  87355. */
  87356. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87357. /**
  87358. * Defines an override for loading texture buffers
  87359. * Return true to stop further extensions from loading this texture data
  87360. */
  87361. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87362. /**
  87363. * Defines an override for creating textures
  87364. * Return true to stop further extensions from loading this texture
  87365. */
  87366. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87367. /**
  87368. * Defines an override for loading shader strings
  87369. * Return true to stop further extensions from loading this shader data
  87370. */
  87371. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87372. /**
  87373. * Defines an override for loading materials
  87374. * Return true to stop further extensions from loading this material
  87375. */
  87376. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87377. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87378. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87379. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87380. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87381. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87382. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87383. private static LoadTextureBufferAsync;
  87384. private static CreateTextureAsync;
  87385. private static ApplyExtensions;
  87386. }
  87387. }
  87388. declare module BABYLON.GLTF1 {
  87389. /** @hidden */
  87390. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87391. private _bin;
  87392. constructor();
  87393. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87394. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87395. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87396. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87397. }
  87398. }
  87399. declare module BABYLON.GLTF1 {
  87400. /** @hidden */
  87401. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87402. constructor();
  87403. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87404. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87405. private _loadTexture;
  87406. }
  87407. }
  87408. declare module BABYLON.GLTF2.Loader {
  87409. /**
  87410. * Loader interface with an index field.
  87411. */
  87412. export interface IArrayItem {
  87413. /**
  87414. * The index of this item in the array.
  87415. */
  87416. index: number;
  87417. }
  87418. /**
  87419. * Loader interface with additional members.
  87420. */
  87421. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87422. /** @hidden */
  87423. _data?: Promise<ArrayBufferView>;
  87424. /** @hidden */
  87425. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87426. }
  87427. /**
  87428. * Loader interface with additional members.
  87429. */
  87430. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87431. }
  87432. /** @hidden */
  87433. export interface _IAnimationSamplerData {
  87434. input: Float32Array;
  87435. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87436. output: Float32Array;
  87437. }
  87438. /**
  87439. * Loader interface with additional members.
  87440. */
  87441. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87442. /** @hidden */
  87443. _data?: Promise<_IAnimationSamplerData>;
  87444. }
  87445. /**
  87446. * Loader interface with additional members.
  87447. */
  87448. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87449. channels: IAnimationChannel[];
  87450. samplers: IAnimationSampler[];
  87451. /** @hidden */
  87452. _babylonAnimationGroup?: AnimationGroup;
  87453. }
  87454. /**
  87455. * Loader interface with additional members.
  87456. */
  87457. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87458. /** @hidden */
  87459. _data?: Promise<ArrayBufferView>;
  87460. }
  87461. /**
  87462. * Loader interface with additional members.
  87463. */
  87464. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87465. /** @hidden */
  87466. _data?: Promise<ArrayBufferView>;
  87467. /** @hidden */
  87468. _babylonBuffer?: Promise<Buffer>;
  87469. }
  87470. /**
  87471. * Loader interface with additional members.
  87472. */
  87473. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87474. }
  87475. /**
  87476. * Loader interface with additional members.
  87477. */
  87478. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87479. /** @hidden */
  87480. _data?: Promise<ArrayBufferView>;
  87481. }
  87482. /**
  87483. * Loader interface with additional members.
  87484. */
  87485. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87486. }
  87487. /**
  87488. * Loader interface with additional members.
  87489. */
  87490. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87491. }
  87492. /**
  87493. * Loader interface with additional members.
  87494. */
  87495. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87496. baseColorTexture?: ITextureInfo;
  87497. metallicRoughnessTexture?: ITextureInfo;
  87498. }
  87499. /**
  87500. * Loader interface with additional members.
  87501. */
  87502. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87503. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87504. normalTexture?: IMaterialNormalTextureInfo;
  87505. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87506. emissiveTexture?: ITextureInfo;
  87507. /** @hidden */
  87508. _data?: {
  87509. [babylonDrawMode: number]: {
  87510. babylonMaterial: Material;
  87511. babylonMeshes: AbstractMesh[];
  87512. promise: Promise<void>;
  87513. };
  87514. };
  87515. }
  87516. /**
  87517. * Loader interface with additional members.
  87518. */
  87519. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87520. primitives: IMeshPrimitive[];
  87521. }
  87522. /**
  87523. * Loader interface with additional members.
  87524. */
  87525. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87526. /** @hidden */
  87527. _instanceData?: {
  87528. babylonSourceMesh: Mesh;
  87529. promise: Promise<any>;
  87530. };
  87531. }
  87532. /**
  87533. * Loader interface with additional members.
  87534. */
  87535. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  87536. /**
  87537. * The parent glTF node.
  87538. */
  87539. parent?: INode;
  87540. /** @hidden */
  87541. _babylonTransformNode?: TransformNode;
  87542. /** @hidden */
  87543. _primitiveBabylonMeshes?: AbstractMesh[];
  87544. /** @hidden */
  87545. _babylonBones?: Bone[];
  87546. /** @hidden */
  87547. _numMorphTargets?: number;
  87548. }
  87549. /** @hidden */
  87550. export interface _ISamplerData {
  87551. noMipMaps: boolean;
  87552. samplingMode: number;
  87553. wrapU: number;
  87554. wrapV: number;
  87555. }
  87556. /**
  87557. * Loader interface with additional members.
  87558. */
  87559. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  87560. /** @hidden */
  87561. _data?: _ISamplerData;
  87562. }
  87563. /**
  87564. * Loader interface with additional members.
  87565. */
  87566. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  87567. }
  87568. /**
  87569. * Loader interface with additional members.
  87570. */
  87571. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  87572. /** @hidden */
  87573. _data?: {
  87574. babylonSkeleton: Skeleton;
  87575. promise: Promise<void>;
  87576. };
  87577. }
  87578. /**
  87579. * Loader interface with additional members.
  87580. */
  87581. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  87582. /** @hidden */
  87583. _textureInfo: ITextureInfo;
  87584. }
  87585. /**
  87586. * Loader interface with additional members.
  87587. */
  87588. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  87589. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  87590. nonColorData?: boolean;
  87591. }
  87592. /**
  87593. * Loader interface with additional members.
  87594. */
  87595. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  87596. accessors?: IAccessor[];
  87597. animations?: IAnimation[];
  87598. buffers?: IBuffer[];
  87599. bufferViews?: IBufferView[];
  87600. cameras?: ICamera[];
  87601. images?: IImage[];
  87602. materials?: IMaterial[];
  87603. meshes?: IMesh[];
  87604. nodes?: INode[];
  87605. samplers?: ISampler[];
  87606. scenes?: IScene[];
  87607. skins?: ISkin[];
  87608. textures?: ITexture[];
  87609. }
  87610. }
  87611. declare module BABYLON.GLTF2 {
  87612. /**
  87613. * Interface for a glTF loader extension.
  87614. */
  87615. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  87616. /**
  87617. * Called after the loader state changes to LOADING.
  87618. */
  87619. onLoading?(): void;
  87620. /**
  87621. * Called after the loader state changes to READY.
  87622. */
  87623. onReady?(): void;
  87624. /**
  87625. * Define this method to modify the default behavior when loading scenes.
  87626. * @param context The context when loading the asset
  87627. * @param scene The glTF scene property
  87628. * @returns A promise that resolves when the load is complete or null if not handled
  87629. */
  87630. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  87631. /**
  87632. * Define this method to modify the default behavior when loading nodes.
  87633. * @param context The context when loading the asset
  87634. * @param node The glTF node property
  87635. * @param assign A function called synchronously after parsing the glTF properties
  87636. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  87637. */
  87638. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87639. /**
  87640. * Define this method to modify the default behavior when loading cameras.
  87641. * @param context The context when loading the asset
  87642. * @param camera The glTF camera property
  87643. * @param assign A function called synchronously after parsing the glTF properties
  87644. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  87645. */
  87646. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  87647. /**
  87648. * @hidden
  87649. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  87650. * @param context The context when loading the asset
  87651. * @param primitive The glTF mesh primitive property
  87652. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  87653. */
  87654. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87655. /**
  87656. * @hidden
  87657. * Define this method to modify the default behavior when loading data for mesh primitives.
  87658. * @param context The context when loading the asset
  87659. * @param name The mesh name when loading the asset
  87660. * @param node The glTF node when loading the asset
  87661. * @param mesh The glTF mesh when loading the asset
  87662. * @param primitive The glTF mesh primitive property
  87663. * @param assign A function called synchronously after parsing the glTF properties
  87664. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87665. */
  87666. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87667. /**
  87668. * @hidden
  87669. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  87670. * @param context The context when loading the asset
  87671. * @param material The glTF material property
  87672. * @param assign A function called synchronously after parsing the glTF properties
  87673. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  87674. */
  87675. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  87676. /**
  87677. * Define this method to modify the default behavior when creating materials.
  87678. * @param context The context when loading the asset
  87679. * @param material The glTF material property
  87680. * @param babylonDrawMode The draw mode for the Babylon material
  87681. * @returns The Babylon material or null if not handled
  87682. */
  87683. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  87684. /**
  87685. * Define this method to modify the default behavior when loading material properties.
  87686. * @param context The context when loading the asset
  87687. * @param material The glTF material property
  87688. * @param babylonMaterial The Babylon material
  87689. * @returns A promise that resolves when the load is complete or null if not handled
  87690. */
  87691. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87692. /**
  87693. * Define this method to modify the default behavior when loading texture infos.
  87694. * @param context The context when loading the asset
  87695. * @param textureInfo The glTF texture info property
  87696. * @param assign A function called synchronously after parsing the glTF properties
  87697. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87698. */
  87699. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87700. /**
  87701. * @hidden
  87702. * Define this method to modify the default behavior when loading textures.
  87703. * @param context The context when loading the asset
  87704. * @param texture The glTF texture property
  87705. * @param assign A function called synchronously after parsing the glTF properties
  87706. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87707. */
  87708. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87709. /**
  87710. * Define this method to modify the default behavior when loading animations.
  87711. * @param context The context when loading the asset
  87712. * @param animation The glTF animation property
  87713. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  87714. */
  87715. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  87716. /**
  87717. * @hidden
  87718. * Define this method to modify the default behavior when loading skins.
  87719. * @param context The context when loading the asset
  87720. * @param node The glTF node property
  87721. * @param skin The glTF skin property
  87722. * @returns A promise that resolves when the load is complete or null if not handled
  87723. */
  87724. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  87725. /**
  87726. * @hidden
  87727. * Define this method to modify the default behavior when loading uris.
  87728. * @param context The context when loading the asset
  87729. * @param property The glTF property associated with the uri
  87730. * @param uri The uri to load
  87731. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87732. */
  87733. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  87734. /**
  87735. * Define this method to modify the default behavior when loading buffer views.
  87736. * @param context The context when loading the asset
  87737. * @param bufferView The glTF buffer view property
  87738. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87739. */
  87740. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87741. /**
  87742. * Define this method to modify the default behavior when loading buffers.
  87743. * @param context The context when loading the asset
  87744. * @param buffer The glTF buffer property
  87745. * @param byteOffset The byte offset to load
  87746. * @param byteLength The byte length to load
  87747. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87748. */
  87749. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  87750. }
  87751. }
  87752. declare module BABYLON.GLTF2 {
  87753. /**
  87754. * Helper class for working with arrays when loading the glTF asset
  87755. */
  87756. export class ArrayItem {
  87757. /**
  87758. * Gets an item from the given array.
  87759. * @param context The context when loading the asset
  87760. * @param array The array to get the item from
  87761. * @param index The index to the array
  87762. * @returns The array item
  87763. */
  87764. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  87765. /**
  87766. * Assign an `index` field to each item of the given array.
  87767. * @param array The array of items
  87768. */
  87769. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  87770. }
  87771. /**
  87772. * The glTF 2.0 loader
  87773. */
  87774. export class GLTFLoader implements IGLTFLoader {
  87775. /** @hidden */
  87776. _completePromises: Promise<any>[];
  87777. /** @hidden */
  87778. _forAssetContainer: boolean;
  87779. /** Storage */
  87780. _babylonLights: Light[];
  87781. /** @hidden */
  87782. _disableInstancedMesh: number;
  87783. private _disposed;
  87784. private _parent;
  87785. private _state;
  87786. private _extensions;
  87787. private _rootUrl;
  87788. private _fileName;
  87789. private _uniqueRootUrl;
  87790. private _gltf;
  87791. private _bin;
  87792. private _babylonScene;
  87793. private _rootBabylonMesh;
  87794. private _defaultBabylonMaterialData;
  87795. private static _RegisteredExtensions;
  87796. /**
  87797. * The default glTF sampler.
  87798. */
  87799. static readonly DefaultSampler: ISampler;
  87800. /**
  87801. * Registers a loader extension.
  87802. * @param name The name of the loader extension.
  87803. * @param factory The factory function that creates the loader extension.
  87804. */
  87805. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  87806. /**
  87807. * Unregisters a loader extension.
  87808. * @param name The name of the loader extension.
  87809. * @returns A boolean indicating whether the extension has been unregistered
  87810. */
  87811. static UnregisterExtension(name: string): boolean;
  87812. /**
  87813. * The loader state.
  87814. */
  87815. get state(): Nullable<GLTFLoaderState>;
  87816. /**
  87817. * The object that represents the glTF JSON.
  87818. */
  87819. get gltf(): IGLTF;
  87820. /**
  87821. * The BIN chunk of a binary glTF.
  87822. */
  87823. get bin(): Nullable<IDataBuffer>;
  87824. /**
  87825. * The parent file loader.
  87826. */
  87827. get parent(): GLTFFileLoader;
  87828. /**
  87829. * The Babylon scene when loading the asset.
  87830. */
  87831. get babylonScene(): Scene;
  87832. /**
  87833. * The root Babylon mesh when loading the asset.
  87834. */
  87835. get rootBabylonMesh(): Mesh;
  87836. /** @hidden */
  87837. constructor(parent: GLTFFileLoader);
  87838. /** @hidden */
  87839. dispose(): void;
  87840. /** @hidden */
  87841. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87842. /** @hidden */
  87843. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87844. private _loadAsync;
  87845. private _loadData;
  87846. private _setupData;
  87847. private _loadExtensions;
  87848. private _checkExtensions;
  87849. private _setState;
  87850. private _createRootNode;
  87851. /**
  87852. * Loads a glTF scene.
  87853. * @param context The context when loading the asset
  87854. * @param scene The glTF scene property
  87855. * @returns A promise that resolves when the load is complete
  87856. */
  87857. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  87858. private _forEachPrimitive;
  87859. private _getGeometries;
  87860. private _getMeshes;
  87861. private _getTransformNodes;
  87862. private _getSkeletons;
  87863. private _getAnimationGroups;
  87864. private _startAnimations;
  87865. /**
  87866. * Loads a glTF node.
  87867. * @param context The context when loading the asset
  87868. * @param node The glTF node property
  87869. * @param assign A function called synchronously after parsing the glTF properties
  87870. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  87871. */
  87872. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  87873. private _loadMeshAsync;
  87874. /**
  87875. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  87876. * @param context The context when loading the asset
  87877. * @param name The mesh name when loading the asset
  87878. * @param node The glTF node when loading the asset
  87879. * @param mesh The glTF mesh when loading the asset
  87880. * @param primitive The glTF mesh primitive property
  87881. * @param assign A function called synchronously after parsing the glTF properties
  87882. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87883. */
  87884. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  87885. private _loadVertexDataAsync;
  87886. private _createMorphTargets;
  87887. private _loadMorphTargetsAsync;
  87888. private _loadMorphTargetVertexDataAsync;
  87889. private static _LoadTransform;
  87890. private _loadSkinAsync;
  87891. private _loadBones;
  87892. private _loadBone;
  87893. private _loadSkinInverseBindMatricesDataAsync;
  87894. private _updateBoneMatrices;
  87895. private _getNodeMatrix;
  87896. /**
  87897. * Loads a glTF camera.
  87898. * @param context The context when loading the asset
  87899. * @param camera The glTF camera property
  87900. * @param assign A function called synchronously after parsing the glTF properties
  87901. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  87902. */
  87903. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  87904. private _loadAnimationsAsync;
  87905. /**
  87906. * Loads a glTF animation.
  87907. * @param context The context when loading the asset
  87908. * @param animation The glTF animation property
  87909. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  87910. */
  87911. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  87912. /**
  87913. * @hidden Loads a glTF animation channel.
  87914. * @param context The context when loading the asset
  87915. * @param animationContext The context of the animation when loading the asset
  87916. * @param animation The glTF animation property
  87917. * @param channel The glTF animation channel property
  87918. * @param babylonAnimationGroup The babylon animation group property
  87919. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  87920. * @returns A void promise when the channel load is complete
  87921. */
  87922. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  87923. private _loadAnimationSamplerAsync;
  87924. /**
  87925. * Loads a glTF buffer.
  87926. * @param context The context when loading the asset
  87927. * @param buffer The glTF buffer property
  87928. * @param byteOffset The byte offset to use
  87929. * @param byteLength The byte length to use
  87930. * @returns A promise that resolves with the loaded data when the load is complete
  87931. */
  87932. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  87933. /**
  87934. * Loads a glTF buffer view.
  87935. * @param context The context when loading the asset
  87936. * @param bufferView The glTF buffer view property
  87937. * @returns A promise that resolves with the loaded data when the load is complete
  87938. */
  87939. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  87940. private _loadAccessorAsync;
  87941. /** @hidden */
  87942. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  87943. private _loadIndicesAccessorAsync;
  87944. private _loadVertexBufferViewAsync;
  87945. private _loadVertexAccessorAsync;
  87946. private _loadMaterialMetallicRoughnessPropertiesAsync;
  87947. /** @hidden */
  87948. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  87949. private _createDefaultMaterial;
  87950. /**
  87951. * Creates a Babylon material from a glTF material.
  87952. * @param context The context when loading the asset
  87953. * @param material The glTF material property
  87954. * @param babylonDrawMode The draw mode for the Babylon material
  87955. * @returns The Babylon material
  87956. */
  87957. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  87958. /**
  87959. * Loads properties from a glTF material into a Babylon material.
  87960. * @param context The context when loading the asset
  87961. * @param material The glTF material property
  87962. * @param babylonMaterial The Babylon material
  87963. * @returns A promise that resolves when the load is complete
  87964. */
  87965. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87966. /**
  87967. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  87968. * @param context The context when loading the asset
  87969. * @param material The glTF material property
  87970. * @param babylonMaterial The Babylon material
  87971. * @returns A promise that resolves when the load is complete
  87972. */
  87973. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87974. /**
  87975. * Loads the alpha properties from a glTF material into a Babylon material.
  87976. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  87977. * @param context The context when loading the asset
  87978. * @param material The glTF material property
  87979. * @param babylonMaterial The Babylon material
  87980. */
  87981. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  87982. /**
  87983. * Loads a glTF texture info.
  87984. * @param context The context when loading the asset
  87985. * @param textureInfo The glTF texture info property
  87986. * @param assign A function called synchronously after parsing the glTF properties
  87987. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  87988. */
  87989. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87990. /** @hidden */
  87991. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87992. /** @hidden */
  87993. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  87994. private _loadSampler;
  87995. /**
  87996. * Loads a glTF image.
  87997. * @param context The context when loading the asset
  87998. * @param image The glTF image property
  87999. * @returns A promise that resolves with the loaded data when the load is complete
  88000. */
  88001. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  88002. /**
  88003. * Loads a glTF uri.
  88004. * @param context The context when loading the asset
  88005. * @param property The glTF property associated with the uri
  88006. * @param uri The base64 or relative uri
  88007. * @returns A promise that resolves with the loaded data when the load is complete
  88008. */
  88009. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  88010. /**
  88011. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  88012. * @param babylonObject the Babylon object with metadata
  88013. * @param pointer the JSON pointer
  88014. */
  88015. static AddPointerMetadata(babylonObject: {
  88016. metadata: any;
  88017. }, pointer: string): void;
  88018. private static _GetTextureWrapMode;
  88019. private static _GetTextureSamplingMode;
  88020. private static _GetTypedArrayConstructor;
  88021. private static _GetTypedArray;
  88022. private static _GetNumComponents;
  88023. private static _ValidateUri;
  88024. /** @hidden */
  88025. static _GetDrawMode(context: string, mode: number | undefined): number;
  88026. private _compileMaterialsAsync;
  88027. private _compileShadowGeneratorsAsync;
  88028. private _forEachExtensions;
  88029. private _applyExtensions;
  88030. private _extensionsOnLoading;
  88031. private _extensionsOnReady;
  88032. private _extensionsLoadSceneAsync;
  88033. private _extensionsLoadNodeAsync;
  88034. private _extensionsLoadCameraAsync;
  88035. private _extensionsLoadVertexDataAsync;
  88036. private _extensionsLoadMeshPrimitiveAsync;
  88037. private _extensionsLoadMaterialAsync;
  88038. private _extensionsCreateMaterial;
  88039. private _extensionsLoadMaterialPropertiesAsync;
  88040. private _extensionsLoadTextureInfoAsync;
  88041. private _extensionsLoadTextureAsync;
  88042. private _extensionsLoadAnimationAsync;
  88043. private _extensionsLoadSkinAsync;
  88044. private _extensionsLoadUriAsync;
  88045. private _extensionsLoadBufferViewAsync;
  88046. private _extensionsLoadBufferAsync;
  88047. /**
  88048. * Helper method called by a loader extension to load an glTF extension.
  88049. * @param context The context when loading the asset
  88050. * @param property The glTF property to load the extension from
  88051. * @param extensionName The name of the extension to load
  88052. * @param actionAsync The action to run
  88053. * @returns The promise returned by actionAsync or null if the extension does not exist
  88054. */
  88055. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88056. /**
  88057. * Helper method called by a loader extension to load a glTF extra.
  88058. * @param context The context when loading the asset
  88059. * @param property The glTF property to load the extra from
  88060. * @param extensionName The name of the extension to load
  88061. * @param actionAsync The action to run
  88062. * @returns The promise returned by actionAsync or null if the extra does not exist
  88063. */
  88064. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88065. /**
  88066. * Checks for presence of an extension.
  88067. * @param name The name of the extension to check
  88068. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  88069. */
  88070. isExtensionUsed(name: string): boolean;
  88071. /**
  88072. * Increments the indentation level and logs a message.
  88073. * @param message The message to log
  88074. */
  88075. logOpen(message: string): void;
  88076. /**
  88077. * Decrements the indentation level.
  88078. */
  88079. logClose(): void;
  88080. /**
  88081. * Logs a message
  88082. * @param message The message to log
  88083. */
  88084. log(message: string): void;
  88085. /**
  88086. * Starts a performance counter.
  88087. * @param counterName The name of the performance counter
  88088. */
  88089. startPerformanceCounter(counterName: string): void;
  88090. /**
  88091. * Ends a performance counter.
  88092. * @param counterName The name of the performance counter
  88093. */
  88094. endPerformanceCounter(counterName: string): void;
  88095. }
  88096. }
  88097. declare module BABYLON.GLTF2.Loader.Extensions {
  88098. /** @hidden */
  88099. interface IEXTLightsImageBased_LightImageBased {
  88100. _babylonTexture?: BaseTexture;
  88101. _loaded?: Promise<void>;
  88102. }
  88103. /**
  88104. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  88105. */
  88106. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  88107. /**
  88108. * The name of this extension.
  88109. */
  88110. readonly name: string;
  88111. /**
  88112. * Defines whether this extension is enabled.
  88113. */
  88114. enabled: boolean;
  88115. private _loader;
  88116. private _lights?;
  88117. /** @hidden */
  88118. constructor(loader: GLTFLoader);
  88119. /** @hidden */
  88120. dispose(): void;
  88121. /** @hidden */
  88122. onLoading(): void;
  88123. /** @hidden */
  88124. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88125. private _loadLightAsync;
  88126. }
  88127. }
  88128. declare module BABYLON.GLTF2.Loader.Extensions {
  88129. /**
  88130. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  88131. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  88132. * !!! Experimental Extension Subject to Changes !!!
  88133. */
  88134. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  88135. /**
  88136. * The name of this extension.
  88137. */
  88138. readonly name: string;
  88139. /**
  88140. * Defines whether this extension is enabled.
  88141. */
  88142. enabled: boolean;
  88143. private _loader;
  88144. /** @hidden */
  88145. constructor(loader: GLTFLoader);
  88146. /** @hidden */
  88147. dispose(): void;
  88148. /** @hidden */
  88149. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88150. }
  88151. }
  88152. declare module BABYLON.GLTF2.Loader.Extensions {
  88153. /**
  88154. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  88155. *
  88156. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  88157. */
  88158. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  88159. /**
  88160. * The name of this extension.
  88161. */
  88162. readonly name: string;
  88163. /**
  88164. * Defines whether this extension is enabled.
  88165. */
  88166. enabled: boolean;
  88167. /**
  88168. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  88169. */
  88170. static DecoderPath: string;
  88171. private _loader;
  88172. private _decoderPromise?;
  88173. /** @hidden */
  88174. constructor(loader: GLTFLoader);
  88175. /** @hidden */
  88176. dispose(): void;
  88177. /** @hidden */
  88178. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88179. }
  88180. }
  88181. declare module BABYLON.GLTF2.Loader.Extensions {
  88182. /**
  88183. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  88184. */
  88185. export class EXT_texture_webp implements IGLTFLoaderExtension {
  88186. /** The name of this extension. */
  88187. readonly name: string;
  88188. /** Defines whether this extension is enabled. */
  88189. enabled: boolean;
  88190. private _loader;
  88191. /** @hidden */
  88192. constructor(loader: GLTFLoader);
  88193. /** @hidden */
  88194. dispose(): void;
  88195. /** @hidden */
  88196. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88197. }
  88198. }
  88199. declare module BABYLON.GLTF2.Loader.Extensions {
  88200. /**
  88201. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  88202. */
  88203. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88204. /**
  88205. * The name of this extension.
  88206. */
  88207. readonly name: string;
  88208. /**
  88209. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88210. */
  88211. dracoCompression?: DracoCompression;
  88212. /**
  88213. * Defines whether this extension is enabled.
  88214. */
  88215. enabled: boolean;
  88216. private _loader;
  88217. /** @hidden */
  88218. constructor(loader: GLTFLoader);
  88219. /** @hidden */
  88220. dispose(): void;
  88221. /** @hidden */
  88222. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88223. }
  88224. }
  88225. declare module BABYLON.GLTF2.Loader.Extensions {
  88226. /**
  88227. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88228. */
  88229. export class KHR_lights implements IGLTFLoaderExtension {
  88230. /**
  88231. * The name of this extension.
  88232. */
  88233. readonly name: string;
  88234. /**
  88235. * Defines whether this extension is enabled.
  88236. */
  88237. enabled: boolean;
  88238. private _loader;
  88239. private _lights?;
  88240. /** @hidden */
  88241. constructor(loader: GLTFLoader);
  88242. /** @hidden */
  88243. dispose(): void;
  88244. /** @hidden */
  88245. onLoading(): void;
  88246. /** @hidden */
  88247. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88248. }
  88249. }
  88250. declare module BABYLON.GLTF2.Loader.Extensions {
  88251. /**
  88252. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88253. */
  88254. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88255. /**
  88256. * The name of this extension.
  88257. */
  88258. readonly name: string;
  88259. /**
  88260. * Defines whether this extension is enabled.
  88261. */
  88262. enabled: boolean;
  88263. /**
  88264. * Defines a number that determines the order the extensions are applied.
  88265. */
  88266. order: number;
  88267. private _loader;
  88268. /** @hidden */
  88269. constructor(loader: GLTFLoader);
  88270. /** @hidden */
  88271. dispose(): void;
  88272. /** @hidden */
  88273. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88274. private _loadSpecularGlossinessPropertiesAsync;
  88275. }
  88276. }
  88277. declare module BABYLON.GLTF2.Loader.Extensions {
  88278. /**
  88279. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88280. */
  88281. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88282. /**
  88283. * The name of this extension.
  88284. */
  88285. readonly name: string;
  88286. /**
  88287. * Defines whether this extension is enabled.
  88288. */
  88289. enabled: boolean;
  88290. /**
  88291. * Defines a number that determines the order the extensions are applied.
  88292. */
  88293. order: number;
  88294. private _loader;
  88295. /** @hidden */
  88296. constructor(loader: GLTFLoader);
  88297. /** @hidden */
  88298. dispose(): void;
  88299. /** @hidden */
  88300. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88301. private _loadUnlitPropertiesAsync;
  88302. }
  88303. }
  88304. declare module BABYLON.GLTF2.Loader.Extensions {
  88305. /**
  88306. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88307. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88308. */
  88309. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88310. /**
  88311. * The name of this extension.
  88312. */
  88313. readonly name: string;
  88314. /**
  88315. * Defines whether this extension is enabled.
  88316. */
  88317. enabled: boolean;
  88318. /**
  88319. * Defines a number that determines the order the extensions are applied.
  88320. */
  88321. order: number;
  88322. private _loader;
  88323. /** @hidden */
  88324. constructor(loader: GLTFLoader);
  88325. /** @hidden */
  88326. dispose(): void;
  88327. /** @hidden */
  88328. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88329. private _loadClearCoatPropertiesAsync;
  88330. }
  88331. }
  88332. declare module BABYLON.GLTF2.Loader.Extensions {
  88333. /**
  88334. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88335. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88336. * !!! Experimental Extension Subject to Changes !!!
  88337. */
  88338. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88339. /**
  88340. * The name of this extension.
  88341. */
  88342. readonly name: string;
  88343. /**
  88344. * Defines whether this extension is enabled.
  88345. */
  88346. enabled: boolean;
  88347. /**
  88348. * Defines a number that determines the order the extensions are applied.
  88349. */
  88350. order: number;
  88351. private _loader;
  88352. /** @hidden */
  88353. constructor(loader: GLTFLoader);
  88354. /** @hidden */
  88355. dispose(): void;
  88356. /** @hidden */
  88357. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88358. private _loadSheenPropertiesAsync;
  88359. }
  88360. }
  88361. declare module BABYLON.GLTF2.Loader.Extensions {
  88362. /**
  88363. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88364. * !!! Experimental Extension Subject to Changes !!!
  88365. */
  88366. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88367. /**
  88368. * The name of this extension.
  88369. */
  88370. readonly name: string;
  88371. /**
  88372. * Defines whether this extension is enabled.
  88373. */
  88374. enabled: boolean;
  88375. /**
  88376. * Defines a number that determines the order the extensions are applied.
  88377. */
  88378. order: number;
  88379. private _loader;
  88380. /** @hidden */
  88381. constructor(loader: GLTFLoader);
  88382. /** @hidden */
  88383. dispose(): void;
  88384. /** @hidden */
  88385. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88386. private _loadSpecularPropertiesAsync;
  88387. }
  88388. }
  88389. declare module BABYLON.GLTF2.Loader.Extensions {
  88390. /**
  88391. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88392. * !!! Experimental Extension Subject to Changes !!!
  88393. */
  88394. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88395. /**
  88396. * Default ior Value from the spec.
  88397. */
  88398. private static readonly _DEFAULT_IOR;
  88399. /**
  88400. * The name of this extension.
  88401. */
  88402. readonly name: string;
  88403. /**
  88404. * Defines whether this extension is enabled.
  88405. */
  88406. enabled: boolean;
  88407. /**
  88408. * Defines a number that determines the order the extensions are applied.
  88409. */
  88410. order: number;
  88411. private _loader;
  88412. /** @hidden */
  88413. constructor(loader: GLTFLoader);
  88414. /** @hidden */
  88415. dispose(): void;
  88416. /** @hidden */
  88417. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88418. private _loadIorPropertiesAsync;
  88419. }
  88420. }
  88421. declare module BABYLON.GLTF2.Loader.Extensions {
  88422. /**
  88423. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88424. */
  88425. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88426. /**
  88427. * The name of this extension.
  88428. */
  88429. readonly name: string;
  88430. /**
  88431. * Defines whether this extension is enabled.
  88432. */
  88433. enabled: boolean;
  88434. private _loader;
  88435. private _variants?;
  88436. /** @hidden */
  88437. constructor(loader: GLTFLoader);
  88438. /** @hidden */
  88439. dispose(): void;
  88440. /**
  88441. * Gets the list of available variant names for this asset.
  88442. * @param rootMesh The glTF root mesh
  88443. * @returns the list of all the variant names for this model
  88444. */
  88445. static GetAvailableVariants(rootMesh: Mesh): string[];
  88446. /**
  88447. * Gets the list of available variant names for this asset.
  88448. * @param rootMesh The glTF root mesh
  88449. * @returns the list of all the variant names for this model
  88450. */
  88451. getAvailableVariants(rootMesh: Mesh): string[];
  88452. /**
  88453. * Select a variant given a variant name or a list of variant names.
  88454. * @param rootMesh The glTF root mesh
  88455. * @param variantName The variant name(s) to select.
  88456. */
  88457. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88458. /**
  88459. * Select a variant given a variant name or a list of variant names.
  88460. * @param rootMesh The glTF root mesh
  88461. * @param variantName The variant name(s) to select.
  88462. */
  88463. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88464. /**
  88465. * Reset back to the original before selecting a variant.
  88466. * @param rootMesh The glTF root mesh
  88467. */
  88468. static Reset(rootMesh: Mesh): void;
  88469. /**
  88470. * Reset back to the original before selecting a variant.
  88471. * @param rootMesh The glTF root mesh
  88472. */
  88473. reset(rootMesh: Mesh): void;
  88474. /**
  88475. * Gets the last selected variant name(s) or null if original.
  88476. * @param rootMesh The glTF root mesh
  88477. * @returns The selected variant name(s).
  88478. */
  88479. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88480. /**
  88481. * Gets the last selected variant name(s) or null if original.
  88482. * @param rootMesh The glTF root mesh
  88483. * @returns The selected variant name(s).
  88484. */
  88485. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88486. private static _GetExtensionMetadata;
  88487. /** @hidden */
  88488. onLoading(): void;
  88489. /** @hidden */
  88490. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88491. }
  88492. }
  88493. declare module BABYLON.GLTF2.Loader.Extensions {
  88494. /**
  88495. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88496. */
  88497. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88498. /**
  88499. * The name of this extension.
  88500. */
  88501. readonly name: string;
  88502. /**
  88503. * Defines whether this extension is enabled.
  88504. */
  88505. enabled: boolean;
  88506. /**
  88507. * Defines a number that determines the order the extensions are applied.
  88508. */
  88509. order: number;
  88510. private _loader;
  88511. /** @hidden */
  88512. constructor(loader: GLTFLoader);
  88513. /** @hidden */
  88514. dispose(): void;
  88515. /** @hidden */
  88516. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88517. private _loadTransparentPropertiesAsync;
  88518. }
  88519. }
  88520. declare module BABYLON.GLTF2.Loader.Extensions {
  88521. /**
  88522. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88523. * !!! Experimental Extension Subject to Changes !!!
  88524. */
  88525. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88526. /**
  88527. * The name of this extension.
  88528. */
  88529. readonly name: string;
  88530. /**
  88531. * Defines whether this extension is enabled.
  88532. */
  88533. enabled: boolean;
  88534. /**
  88535. * Defines a number that determines the order the extensions are applied.
  88536. */
  88537. order: number;
  88538. private _loader;
  88539. /** @hidden */
  88540. constructor(loader: GLTFLoader);
  88541. /** @hidden */
  88542. dispose(): void;
  88543. /** @hidden */
  88544. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88545. private _loadTranslucentPropertiesAsync;
  88546. }
  88547. }
  88548. declare module BABYLON.GLTF2.Loader.Extensions {
  88549. /**
  88550. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  88551. */
  88552. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  88553. /**
  88554. * The name of this extension.
  88555. */
  88556. readonly name: string;
  88557. /**
  88558. * Defines whether this extension is enabled.
  88559. */
  88560. enabled: boolean;
  88561. /** @hidden */
  88562. constructor(loader: GLTFLoader);
  88563. /** @hidden */
  88564. dispose(): void;
  88565. }
  88566. }
  88567. declare module BABYLON.GLTF2.Loader.Extensions {
  88568. /**
  88569. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  88570. * !!! Experimental Extension Subject to Changes !!!
  88571. */
  88572. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  88573. /** The name of this extension. */
  88574. readonly name: string;
  88575. /** Defines whether this extension is enabled. */
  88576. enabled: boolean;
  88577. private _loader;
  88578. /** @hidden */
  88579. constructor(loader: GLTFLoader);
  88580. /** @hidden */
  88581. dispose(): void;
  88582. /** @hidden */
  88583. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88584. }
  88585. }
  88586. declare module BABYLON.GLTF2.Loader.Extensions {
  88587. /**
  88588. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  88589. */
  88590. export class KHR_texture_transform implements IGLTFLoaderExtension {
  88591. /**
  88592. * The name of this extension.
  88593. */
  88594. readonly name: string;
  88595. /**
  88596. * Defines whether this extension is enabled.
  88597. */
  88598. enabled: boolean;
  88599. private _loader;
  88600. /** @hidden */
  88601. constructor(loader: GLTFLoader);
  88602. /** @hidden */
  88603. dispose(): void;
  88604. /** @hidden */
  88605. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88606. }
  88607. }
  88608. declare module BABYLON.GLTF2.Loader.Extensions {
  88609. /**
  88610. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  88611. * !!! Experimental Extension Subject to Changes !!!
  88612. */
  88613. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  88614. /**
  88615. * The name of this extension.
  88616. */
  88617. readonly name: string;
  88618. /**
  88619. * Defines whether this extension is enabled.
  88620. */
  88621. enabled: boolean;
  88622. /**
  88623. * Defines a number that determines the order the extensions are applied.
  88624. */
  88625. order: number;
  88626. private _loader;
  88627. /** @hidden */
  88628. constructor(loader: GLTFLoader);
  88629. /** @hidden */
  88630. dispose(): void;
  88631. /**
  88632. * Called after the loader state changes to LOADING.
  88633. */
  88634. onLoading(): void;
  88635. }
  88636. }
  88637. declare module BABYLON.GLTF2.Loader.Extensions {
  88638. /**
  88639. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  88640. */
  88641. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  88642. /**
  88643. * The name of this extension.
  88644. */
  88645. readonly name: string;
  88646. /**
  88647. * Defines whether this extension is enabled.
  88648. */
  88649. enabled: boolean;
  88650. private _loader;
  88651. private _clips;
  88652. private _emitters;
  88653. /** @hidden */
  88654. constructor(loader: GLTFLoader);
  88655. /** @hidden */
  88656. dispose(): void;
  88657. /** @hidden */
  88658. onLoading(): void;
  88659. /** @hidden */
  88660. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88661. /** @hidden */
  88662. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88663. /** @hidden */
  88664. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88665. private _loadClipAsync;
  88666. private _loadEmitterAsync;
  88667. private _getEventAction;
  88668. private _loadAnimationEventAsync;
  88669. }
  88670. }
  88671. declare module BABYLON.GLTF2.Loader.Extensions {
  88672. /**
  88673. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  88674. */
  88675. export class MSFT_lod implements IGLTFLoaderExtension {
  88676. /**
  88677. * The name of this extension.
  88678. */
  88679. readonly name: string;
  88680. /**
  88681. * Defines whether this extension is enabled.
  88682. */
  88683. enabled: boolean;
  88684. /**
  88685. * Defines a number that determines the order the extensions are applied.
  88686. */
  88687. order: number;
  88688. /**
  88689. * Maximum number of LODs to load, starting from the lowest LOD.
  88690. */
  88691. maxLODsToLoad: number;
  88692. /**
  88693. * Observable raised when all node LODs of one level are loaded.
  88694. * The event data is the index of the loaded LOD starting from zero.
  88695. * Dispose the loader to cancel the loading of the next level of LODs.
  88696. */
  88697. onNodeLODsLoadedObservable: Observable<number>;
  88698. /**
  88699. * Observable raised when all material LODs of one level are loaded.
  88700. * The event data is the index of the loaded LOD starting from zero.
  88701. * Dispose the loader to cancel the loading of the next level of LODs.
  88702. */
  88703. onMaterialLODsLoadedObservable: Observable<number>;
  88704. private _loader;
  88705. private _bufferLODs;
  88706. private _nodeIndexLOD;
  88707. private _nodeSignalLODs;
  88708. private _nodePromiseLODs;
  88709. private _nodeBufferLODs;
  88710. private _materialIndexLOD;
  88711. private _materialSignalLODs;
  88712. private _materialPromiseLODs;
  88713. private _materialBufferLODs;
  88714. /** @hidden */
  88715. constructor(loader: GLTFLoader);
  88716. /** @hidden */
  88717. dispose(): void;
  88718. /** @hidden */
  88719. onReady(): void;
  88720. /** @hidden */
  88721. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88722. /** @hidden */
  88723. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88724. /** @hidden */
  88725. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88726. /** @hidden */
  88727. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88728. /** @hidden */
  88729. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88730. private _loadBufferLOD;
  88731. /**
  88732. * Gets an array of LOD properties from lowest to highest.
  88733. */
  88734. private _getLODs;
  88735. private _disposeTransformNode;
  88736. private _disposeMaterials;
  88737. }
  88738. }
  88739. declare module BABYLON.GLTF2.Loader.Extensions {
  88740. /** @hidden */
  88741. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  88742. readonly name: string;
  88743. enabled: boolean;
  88744. private _loader;
  88745. constructor(loader: GLTFLoader);
  88746. dispose(): void;
  88747. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88748. }
  88749. }
  88750. declare module BABYLON.GLTF2.Loader.Extensions {
  88751. /** @hidden */
  88752. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  88753. readonly name: string;
  88754. enabled: boolean;
  88755. private _loader;
  88756. constructor(loader: GLTFLoader);
  88757. dispose(): void;
  88758. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88759. }
  88760. }
  88761. declare module BABYLON.GLTF2.Loader.Extensions {
  88762. /**
  88763. * Store glTF extras (if present) in BJS objects' metadata
  88764. */
  88765. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  88766. /**
  88767. * The name of this extension.
  88768. */
  88769. readonly name: string;
  88770. /**
  88771. * Defines whether this extension is enabled.
  88772. */
  88773. enabled: boolean;
  88774. private _loader;
  88775. private _assignExtras;
  88776. /** @hidden */
  88777. constructor(loader: GLTFLoader);
  88778. /** @hidden */
  88779. dispose(): void;
  88780. /** @hidden */
  88781. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88782. /** @hidden */
  88783. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88784. /** @hidden */
  88785. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88786. }
  88787. }
  88788. declare module BABYLON {
  88789. /**
  88790. * Class reading and parsing the MTL file bundled with the obj file.
  88791. */
  88792. export class MTLFileLoader {
  88793. /**
  88794. * Invert Y-Axis of referenced textures on load
  88795. */
  88796. static INVERT_TEXTURE_Y: boolean;
  88797. /**
  88798. * All material loaded from the mtl will be set here
  88799. */
  88800. materials: StandardMaterial[];
  88801. /**
  88802. * This function will read the mtl file and create each material described inside
  88803. * This function could be improve by adding :
  88804. * -some component missing (Ni, Tf...)
  88805. * -including the specific options available
  88806. *
  88807. * @param scene defines the scene the material will be created in
  88808. * @param data defines the mtl data to parse
  88809. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  88810. * @param forAssetContainer defines if the material should be registered in the scene
  88811. */
  88812. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  88813. /**
  88814. * Gets the texture for the material.
  88815. *
  88816. * If the material is imported from input file,
  88817. * We sanitize the url to ensure it takes the textre from aside the material.
  88818. *
  88819. * @param rootUrl The root url to load from
  88820. * @param value The value stored in the mtl
  88821. * @return The Texture
  88822. */
  88823. private static _getTexture;
  88824. }
  88825. }
  88826. declare module BABYLON {
  88827. /**
  88828. * Options for loading OBJ/MTL files
  88829. */
  88830. type MeshLoadOptions = {
  88831. /**
  88832. * Defines if UVs are optimized by default during load.
  88833. */
  88834. OptimizeWithUV: boolean;
  88835. /**
  88836. * Defines custom scaling of UV coordinates of loaded meshes.
  88837. */
  88838. UVScaling: Vector2;
  88839. /**
  88840. * Invert model on y-axis (does a model scaling inversion)
  88841. */
  88842. InvertY: boolean;
  88843. /**
  88844. * Invert Y-Axis of referenced textures on load
  88845. */
  88846. InvertTextureY: boolean;
  88847. /**
  88848. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88849. */
  88850. ImportVertexColors: boolean;
  88851. /**
  88852. * Compute the normals for the model, even if normals are present in the file.
  88853. */
  88854. ComputeNormals: boolean;
  88855. /**
  88856. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88857. */
  88858. SkipMaterials: boolean;
  88859. /**
  88860. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88861. */
  88862. MaterialLoadingFailsSilently: boolean;
  88863. };
  88864. /**
  88865. * OBJ file type loader.
  88866. * This is a babylon scene loader plugin.
  88867. */
  88868. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  88869. /**
  88870. * Defines if UVs are optimized by default during load.
  88871. */
  88872. static OPTIMIZE_WITH_UV: boolean;
  88873. /**
  88874. * Invert model on y-axis (does a model scaling inversion)
  88875. */
  88876. static INVERT_Y: boolean;
  88877. /**
  88878. * Invert Y-Axis of referenced textures on load
  88879. */
  88880. static get INVERT_TEXTURE_Y(): boolean;
  88881. static set INVERT_TEXTURE_Y(value: boolean);
  88882. /**
  88883. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88884. */
  88885. static IMPORT_VERTEX_COLORS: boolean;
  88886. /**
  88887. * Compute the normals for the model, even if normals are present in the file.
  88888. */
  88889. static COMPUTE_NORMALS: boolean;
  88890. /**
  88891. * Defines custom scaling of UV coordinates of loaded meshes.
  88892. */
  88893. static UV_SCALING: Vector2;
  88894. /**
  88895. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88896. */
  88897. static SKIP_MATERIALS: boolean;
  88898. /**
  88899. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88900. *
  88901. * Defaults to true for backwards compatibility.
  88902. */
  88903. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  88904. /**
  88905. * Defines the name of the plugin.
  88906. */
  88907. name: string;
  88908. /**
  88909. * Defines the extension the plugin is able to load.
  88910. */
  88911. extensions: string;
  88912. /** @hidden */
  88913. obj: RegExp;
  88914. /** @hidden */
  88915. group: RegExp;
  88916. /** @hidden */
  88917. mtllib: RegExp;
  88918. /** @hidden */
  88919. usemtl: RegExp;
  88920. /** @hidden */
  88921. smooth: RegExp;
  88922. /** @hidden */
  88923. vertexPattern: RegExp;
  88924. /** @hidden */
  88925. normalPattern: RegExp;
  88926. /** @hidden */
  88927. uvPattern: RegExp;
  88928. /** @hidden */
  88929. facePattern1: RegExp;
  88930. /** @hidden */
  88931. facePattern2: RegExp;
  88932. /** @hidden */
  88933. facePattern3: RegExp;
  88934. /** @hidden */
  88935. facePattern4: RegExp;
  88936. /** @hidden */
  88937. facePattern5: RegExp;
  88938. private _forAssetContainer;
  88939. private _meshLoadOptions;
  88940. /**
  88941. * Creates loader for .OBJ files
  88942. *
  88943. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  88944. */
  88945. constructor(meshLoadOptions?: MeshLoadOptions);
  88946. private static get currentMeshLoadOptions();
  88947. /**
  88948. * Calls synchronously the MTL file attached to this obj.
  88949. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  88950. * Without this function materials are not displayed in the first frame (but displayed after).
  88951. * In consequence it is impossible to get material information in your HTML file
  88952. *
  88953. * @param url The URL of the MTL file
  88954. * @param rootUrl
  88955. * @param onSuccess Callback function to be called when the MTL file is loaded
  88956. * @private
  88957. */
  88958. private _loadMTL;
  88959. /**
  88960. * Instantiates a OBJ file loader plugin.
  88961. * @returns the created plugin
  88962. */
  88963. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  88964. /**
  88965. * If the data string can be loaded directly.
  88966. *
  88967. * @param data string containing the file data
  88968. * @returns if the data can be loaded directly
  88969. */
  88970. canDirectLoad(data: string): boolean;
  88971. /**
  88972. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  88973. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  88974. * @param scene the scene the meshes should be added to
  88975. * @param data the OBJ data to load
  88976. * @param rootUrl root url to load from
  88977. * @param onProgress event that fires when loading progress has occured
  88978. * @param fileName Defines the name of the file to load
  88979. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  88980. */
  88981. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88982. /**
  88983. * Imports all objects from the loaded OBJ data and adds them to the scene
  88984. * @param scene the scene the objects should be added to
  88985. * @param data the OBJ data to load
  88986. * @param rootUrl root url to load from
  88987. * @param onProgress event that fires when loading progress has occured
  88988. * @param fileName Defines the name of the file to load
  88989. * @returns a promise which completes when objects have been loaded to the scene
  88990. */
  88991. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88992. /**
  88993. * Load into an asset container.
  88994. * @param scene The scene to load into
  88995. * @param data The data to import
  88996. * @param rootUrl The root url for scene and resources
  88997. * @param onProgress The callback when the load progresses
  88998. * @param fileName Defines the name of the file to load
  88999. * @returns The loaded asset container
  89000. */
  89001. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  89002. /**
  89003. * Read the OBJ file and create an Array of meshes.
  89004. * Each mesh contains all information given by the OBJ and the MTL file.
  89005. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  89006. *
  89007. * @param meshesNames
  89008. * @param scene Scene The scene where are displayed the data
  89009. * @param data String The content of the obj file
  89010. * @param rootUrl String The path to the folder
  89011. * @returns Array<AbstractMesh>
  89012. * @private
  89013. */
  89014. private _parseSolid;
  89015. }
  89016. }
  89017. declare module BABYLON {
  89018. /**
  89019. * STL file type loader.
  89020. * This is a babylon scene loader plugin.
  89021. */
  89022. export class STLFileLoader implements ISceneLoaderPlugin {
  89023. /** @hidden */
  89024. solidPattern: RegExp;
  89025. /** @hidden */
  89026. facetsPattern: RegExp;
  89027. /** @hidden */
  89028. normalPattern: RegExp;
  89029. /** @hidden */
  89030. vertexPattern: RegExp;
  89031. /**
  89032. * Defines the name of the plugin.
  89033. */
  89034. name: string;
  89035. /**
  89036. * Defines the extensions the stl loader is able to load.
  89037. * force data to come in as an ArrayBuffer
  89038. * we'll convert to string if it looks like it's an ASCII .stl
  89039. */
  89040. extensions: ISceneLoaderPluginExtensions;
  89041. /**
  89042. * Import meshes into a scene.
  89043. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  89044. * @param scene The scene to import into
  89045. * @param data The data to import
  89046. * @param rootUrl The root url for scene and resources
  89047. * @param meshes The meshes array to import into
  89048. * @param particleSystems The particle systems array to import into
  89049. * @param skeletons The skeletons array to import into
  89050. * @param onError The callback when import fails
  89051. * @returns True if successful or false otherwise
  89052. */
  89053. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  89054. /**
  89055. * Load into a scene.
  89056. * @param scene The scene to load into
  89057. * @param data The data to import
  89058. * @param rootUrl The root url for scene and resources
  89059. * @param onError The callback when import fails
  89060. * @returns true if successful or false otherwise
  89061. */
  89062. load(scene: Scene, data: any, rootUrl: string): boolean;
  89063. /**
  89064. * Load into an asset container.
  89065. * @param scene The scene to load into
  89066. * @param data The data to import
  89067. * @param rootUrl The root url for scene and resources
  89068. * @param onError The callback when import fails
  89069. * @returns The loaded asset container
  89070. */
  89071. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  89072. private _isBinary;
  89073. private _parseBinary;
  89074. private _parseASCII;
  89075. }
  89076. }
  89077. declare module BABYLON {
  89078. /**
  89079. * Class for generating OBJ data from a Babylon scene.
  89080. */
  89081. export class OBJExport {
  89082. /**
  89083. * Exports the geometry of a Mesh array in .OBJ file format (text)
  89084. * @param mesh defines the list of meshes to serialize
  89085. * @param materials defines if materials should be exported
  89086. * @param matlibname defines the name of the associated mtl file
  89087. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  89088. * @returns the OBJ content
  89089. */
  89090. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  89091. /**
  89092. * Exports the material(s) of a mesh in .MTL file format (text)
  89093. * @param mesh defines the mesh to extract the material from
  89094. * @returns the mtl content
  89095. */
  89096. static MTL(mesh: Mesh): string;
  89097. }
  89098. }
  89099. declare module BABYLON {
  89100. /** @hidden */
  89101. export var __IGLTFExporterExtension: number;
  89102. /**
  89103. * Interface for extending the exporter
  89104. * @hidden
  89105. */
  89106. export interface IGLTFExporterExtension {
  89107. /**
  89108. * The name of this extension
  89109. */
  89110. readonly name: string;
  89111. /**
  89112. * Defines whether this extension is enabled
  89113. */
  89114. enabled: boolean;
  89115. /**
  89116. * Defines whether this extension is required
  89117. */
  89118. required: boolean;
  89119. }
  89120. }
  89121. declare module BABYLON.GLTF2.Exporter {
  89122. /** @hidden */
  89123. export var __IGLTFExporterExtensionV2: number;
  89124. /**
  89125. * Interface for a glTF exporter extension
  89126. * @hidden
  89127. */
  89128. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  89129. /**
  89130. * Define this method to modify the default behavior before exporting a texture
  89131. * @param context The context when loading the asset
  89132. * @param babylonTexture The Babylon.js texture
  89133. * @param mimeType The mime-type of the generated image
  89134. * @returns A promise that resolves with the exported texture
  89135. */
  89136. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  89137. /**
  89138. * Define this method to get notified when a texture info is created
  89139. * @param context The context when loading the asset
  89140. * @param textureInfo The glTF texture info
  89141. * @param babylonTexture The Babylon.js texture
  89142. */
  89143. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89144. /**
  89145. * Define this method to modify the default behavior when exporting texture info
  89146. * @param context The context when loading the asset
  89147. * @param meshPrimitive glTF mesh primitive
  89148. * @param babylonSubMesh Babylon submesh
  89149. * @param binaryWriter glTF serializer binary writer instance
  89150. * @returns nullable IMeshPrimitive promise
  89151. */
  89152. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  89153. /**
  89154. * Define this method to modify the default behavior when exporting a node
  89155. * @param context The context when exporting the node
  89156. * @param node glTF node
  89157. * @param babylonNode BabylonJS node
  89158. * @returns nullable INode promise
  89159. */
  89160. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89161. [key: number]: number;
  89162. }): Promise<Nullable<INode>>;
  89163. /**
  89164. * Define this method to modify the default behavior when exporting a material
  89165. * @param material glTF material
  89166. * @param babylonMaterial BabylonJS material
  89167. * @returns nullable IMaterial promise
  89168. */
  89169. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  89170. /**
  89171. * Define this method to return additional textures to export from a material
  89172. * @param material glTF material
  89173. * @param babylonMaterial BabylonJS material
  89174. * @returns List of textures
  89175. */
  89176. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89177. /** Gets a boolean indicating that this extension was used */
  89178. wasUsed: boolean;
  89179. /** Gets a boolean indicating that this extension is required for the file to work */
  89180. required: boolean;
  89181. /**
  89182. * Called after the exporter state changes to EXPORTING
  89183. */
  89184. onExporting?(): void;
  89185. }
  89186. }
  89187. declare module BABYLON.GLTF2.Exporter {
  89188. /**
  89189. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  89190. * @hidden
  89191. */
  89192. export class _GLTFMaterialExporter {
  89193. /**
  89194. * Represents the dielectric specular values for R, G and B
  89195. */
  89196. private static readonly _DielectricSpecular;
  89197. /**
  89198. * Allows the maximum specular power to be defined for material calculations
  89199. */
  89200. private static readonly _MaxSpecularPower;
  89201. /**
  89202. * Mapping to store textures
  89203. */
  89204. private _textureMap;
  89205. /**
  89206. * Numeric tolerance value
  89207. */
  89208. private static readonly _Epsilon;
  89209. /**
  89210. * Reference to the glTF Exporter
  89211. */
  89212. private _exporter;
  89213. constructor(exporter: _Exporter);
  89214. /**
  89215. * Specifies if two colors are approximately equal in value
  89216. * @param color1 first color to compare to
  89217. * @param color2 second color to compare to
  89218. * @param epsilon threshold value
  89219. */
  89220. private static FuzzyEquals;
  89221. /**
  89222. * Gets the materials from a Babylon scene and converts them to glTF materials
  89223. * @param scene babylonjs scene
  89224. * @param mimeType texture mime type
  89225. * @param images array of images
  89226. * @param textures array of textures
  89227. * @param materials array of materials
  89228. * @param imageData mapping of texture names to base64 textures
  89229. * @param hasTextureCoords specifies if texture coordinates are present on the material
  89230. */
  89231. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89232. /**
  89233. * Makes a copy of the glTF material without the texture parameters
  89234. * @param originalMaterial original glTF material
  89235. * @returns glTF material without texture parameters
  89236. */
  89237. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89238. /**
  89239. * Specifies if the material has any texture parameters present
  89240. * @param material glTF Material
  89241. * @returns boolean specifying if texture parameters are present
  89242. */
  89243. _hasTexturesPresent(material: IMaterial): boolean;
  89244. /**
  89245. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89246. * @param babylonStandardMaterial
  89247. * @returns glTF Metallic Roughness Material representation
  89248. */
  89249. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89250. /**
  89251. * Computes the metallic factor
  89252. * @param diffuse diffused value
  89253. * @param specular specular value
  89254. * @param oneMinusSpecularStrength one minus the specular strength
  89255. * @returns metallic value
  89256. */
  89257. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89258. /**
  89259. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89260. * @param glTFMaterial glTF material
  89261. * @param babylonMaterial Babylon material
  89262. */
  89263. private static _SetAlphaMode;
  89264. /**
  89265. * Converts a Babylon Standard Material to a glTF Material
  89266. * @param babylonStandardMaterial BJS Standard Material
  89267. * @param mimeType mime type to use for the textures
  89268. * @param images array of glTF image interfaces
  89269. * @param textures array of glTF texture interfaces
  89270. * @param materials array of glTF material interfaces
  89271. * @param imageData map of image file name to data
  89272. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89273. */
  89274. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89275. private _finishMaterial;
  89276. /**
  89277. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89278. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89279. * @param mimeType mime type to use for the textures
  89280. * @param images array of glTF image interfaces
  89281. * @param textures array of glTF texture interfaces
  89282. * @param materials array of glTF material interfaces
  89283. * @param imageData map of image file name to data
  89284. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89285. */
  89286. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89287. /**
  89288. * Converts an image typed array buffer to a base64 image
  89289. * @param buffer typed array buffer
  89290. * @param width width of the image
  89291. * @param height height of the image
  89292. * @param mimeType mimetype of the image
  89293. * @returns base64 image string
  89294. */
  89295. private _createBase64FromCanvasAsync;
  89296. /**
  89297. * Generates a white texture based on the specified width and height
  89298. * @param width width of the texture in pixels
  89299. * @param height height of the texture in pixels
  89300. * @param scene babylonjs scene
  89301. * @returns white texture
  89302. */
  89303. private _createWhiteTexture;
  89304. /**
  89305. * 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
  89306. * @param texture1 first texture to resize
  89307. * @param texture2 second texture to resize
  89308. * @param scene babylonjs scene
  89309. * @returns resized textures or null
  89310. */
  89311. private _resizeTexturesToSameDimensions;
  89312. /**
  89313. * Converts an array of pixels to a Float32Array
  89314. * Throws an error if the pixel format is not supported
  89315. * @param pixels - array buffer containing pixel values
  89316. * @returns Float32 of pixels
  89317. */
  89318. private _convertPixelArrayToFloat32;
  89319. /**
  89320. * Convert Specular Glossiness Textures to Metallic Roughness
  89321. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89322. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89323. * @param diffuseTexture texture used to store diffuse information
  89324. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89325. * @param factors specular glossiness material factors
  89326. * @param mimeType the mime type to use for the texture
  89327. * @returns pbr metallic roughness interface or null
  89328. */
  89329. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89330. /**
  89331. * Converts specular glossiness material properties to metallic roughness
  89332. * @param specularGlossiness interface with specular glossiness material properties
  89333. * @returns interface with metallic roughness material properties
  89334. */
  89335. private _convertSpecularGlossinessToMetallicRoughness;
  89336. /**
  89337. * Calculates the surface reflectance, independent of lighting conditions
  89338. * @param color Color source to calculate brightness from
  89339. * @returns number representing the perceived brightness, or zero if color is undefined
  89340. */
  89341. private _getPerceivedBrightness;
  89342. /**
  89343. * Returns the maximum color component value
  89344. * @param color
  89345. * @returns maximum color component value, or zero if color is null or undefined
  89346. */
  89347. private _getMaxComponent;
  89348. /**
  89349. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89350. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89351. * @param mimeType mime type to use for the textures
  89352. * @param images array of glTF image interfaces
  89353. * @param textures array of glTF texture interfaces
  89354. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89355. * @param imageData map of image file name to data
  89356. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89357. * @returns glTF PBR Metallic Roughness factors
  89358. */
  89359. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89360. private _getGLTFTextureSampler;
  89361. private _getGLTFTextureWrapMode;
  89362. private _getGLTFTextureWrapModesSampler;
  89363. /**
  89364. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89365. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89366. * @param mimeType mime type to use for the textures
  89367. * @param images array of glTF image interfaces
  89368. * @param textures array of glTF texture interfaces
  89369. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89370. * @param imageData map of image file name to data
  89371. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89372. * @returns glTF PBR Metallic Roughness factors
  89373. */
  89374. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89375. /**
  89376. * Converts a Babylon PBR Base Material to a glTF Material
  89377. * @param babylonPBRMaterial BJS PBR Base Material
  89378. * @param mimeType mime type to use for the textures
  89379. * @param images array of glTF image interfaces
  89380. * @param textures array of glTF texture interfaces
  89381. * @param materials array of glTF material interfaces
  89382. * @param imageData map of image file name to data
  89383. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89384. */
  89385. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89386. private setMetallicRoughnessPbrMaterial;
  89387. private getPixelsFromTexture;
  89388. /**
  89389. * Extracts a texture from a Babylon texture into file data and glTF data
  89390. * @param babylonTexture Babylon texture to extract
  89391. * @param mimeType Mime Type of the babylonTexture
  89392. * @return glTF texture info, or null if the texture format is not supported
  89393. */
  89394. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89395. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89396. /**
  89397. * Builds a texture from base64 string
  89398. * @param base64Texture base64 texture string
  89399. * @param baseTextureName Name to use for the texture
  89400. * @param mimeType image mime type for the texture
  89401. * @param images array of images
  89402. * @param textures array of textures
  89403. * @param imageData map of image data
  89404. * @returns glTF texture info, or null if the texture format is not supported
  89405. */
  89406. private _getTextureInfoFromBase64;
  89407. }
  89408. }
  89409. declare module BABYLON {
  89410. /**
  89411. * Class for holding and downloading glTF file data
  89412. */
  89413. export class GLTFData {
  89414. /**
  89415. * Object which contains the file name as the key and its data as the value
  89416. */
  89417. glTFFiles: {
  89418. [fileName: string]: string | Blob;
  89419. };
  89420. /**
  89421. * Initializes the glTF file object
  89422. */
  89423. constructor();
  89424. /**
  89425. * Downloads the glTF data as files based on their names and data
  89426. */
  89427. downloadFiles(): void;
  89428. }
  89429. }
  89430. declare module BABYLON {
  89431. /**
  89432. * Holds a collection of exporter options and parameters
  89433. */
  89434. export interface IExportOptions {
  89435. /**
  89436. * Function which indicates whether a babylon node should be exported or not
  89437. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89438. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89439. */
  89440. shouldExportNode?(node: Node): boolean;
  89441. /**
  89442. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89443. * @param metadata source metadata to read from
  89444. * @returns the data to store to glTF node extras
  89445. */
  89446. metadataSelector?(metadata: any): any;
  89447. /**
  89448. * The sample rate to bake animation curves
  89449. */
  89450. animationSampleRate?: number;
  89451. /**
  89452. * Begin serialization without waiting for the scene to be ready
  89453. */
  89454. exportWithoutWaitingForScene?: boolean;
  89455. /**
  89456. * Indicates if coordinate system swapping root nodes should be included in export
  89457. */
  89458. includeCoordinateSystemConversionNodes?: boolean;
  89459. }
  89460. /**
  89461. * Class for generating glTF data from a Babylon scene.
  89462. */
  89463. export class GLTF2Export {
  89464. /**
  89465. * Exports the geometry of the scene to .gltf file format asynchronously
  89466. * @param scene Babylon scene with scene hierarchy information
  89467. * @param filePrefix File prefix to use when generating the glTF file
  89468. * @param options Exporter options
  89469. * @returns Returns an object with a .gltf file and associates texture names
  89470. * as keys and their data and paths as values
  89471. */
  89472. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89473. private static _PreExportAsync;
  89474. private static _PostExportAsync;
  89475. /**
  89476. * Exports the geometry of the scene to .glb file format asychronously
  89477. * @param scene Babylon scene with scene hierarchy information
  89478. * @param filePrefix File prefix to use when generating glb file
  89479. * @param options Exporter options
  89480. * @returns Returns an object with a .glb filename as key and data as value
  89481. */
  89482. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89483. }
  89484. }
  89485. declare module BABYLON.GLTF2.Exporter {
  89486. /**
  89487. * @hidden
  89488. */
  89489. export class _GLTFUtilities {
  89490. /**
  89491. * Creates a buffer view based on the supplied arguments
  89492. * @param bufferIndex index value of the specified buffer
  89493. * @param byteOffset byte offset value
  89494. * @param byteLength byte length of the bufferView
  89495. * @param byteStride byte distance between conequential elements
  89496. * @param name name of the buffer view
  89497. * @returns bufferView for glTF
  89498. */
  89499. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89500. /**
  89501. * Creates an accessor based on the supplied arguments
  89502. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89503. * @param name The name of the accessor
  89504. * @param type The type of the accessor
  89505. * @param componentType The datatype of components in the attribute
  89506. * @param count The number of attributes referenced by this accessor
  89507. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89508. * @param min Minimum value of each component in this attribute
  89509. * @param max Maximum value of each component in this attribute
  89510. * @returns accessor for glTF
  89511. */
  89512. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89513. /**
  89514. * Calculates the minimum and maximum values of an array of position floats
  89515. * @param positions Positions array of a mesh
  89516. * @param vertexStart Starting vertex offset to calculate min and max values
  89517. * @param vertexCount Number of vertices to check for min and max values
  89518. * @returns min number array and max number array
  89519. */
  89520. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89521. min: number[];
  89522. max: number[];
  89523. };
  89524. /**
  89525. * Converts a new right-handed Vector3
  89526. * @param vector vector3 array
  89527. * @returns right-handed Vector3
  89528. */
  89529. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  89530. /**
  89531. * Converts a Vector3 to right-handed
  89532. * @param vector Vector3 to convert to right-handed
  89533. */
  89534. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  89535. /**
  89536. * Converts a three element number array to right-handed
  89537. * @param vector number array to convert to right-handed
  89538. */
  89539. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  89540. /**
  89541. * Converts a new right-handed Vector3
  89542. * @param vector vector3 array
  89543. * @returns right-handed Vector3
  89544. */
  89545. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  89546. /**
  89547. * Converts a Vector3 to right-handed
  89548. * @param vector Vector3 to convert to right-handed
  89549. */
  89550. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  89551. /**
  89552. * Converts a three element number array to right-handed
  89553. * @param vector number array to convert to right-handed
  89554. */
  89555. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  89556. /**
  89557. * Converts a Vector4 to right-handed
  89558. * @param vector Vector4 to convert to right-handed
  89559. */
  89560. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  89561. /**
  89562. * Converts a Vector4 to right-handed
  89563. * @param vector Vector4 to convert to right-handed
  89564. */
  89565. static _GetRightHandedArray4FromRef(vector: number[]): void;
  89566. /**
  89567. * Converts a Quaternion to right-handed
  89568. * @param quaternion Source quaternion to convert to right-handed
  89569. */
  89570. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  89571. /**
  89572. * Converts a Quaternion to right-handed
  89573. * @param quaternion Source quaternion to convert to right-handed
  89574. */
  89575. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  89576. static _NormalizeTangentFromRef(tangent: Vector4): void;
  89577. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  89578. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  89579. }
  89580. }
  89581. declare module BABYLON.GLTF2.Exporter {
  89582. /**
  89583. * Converts Babylon Scene into glTF 2.0.
  89584. * @hidden
  89585. */
  89586. export class _Exporter {
  89587. /**
  89588. * Stores the glTF to export
  89589. */
  89590. _glTF: IGLTF;
  89591. /**
  89592. * Stores all generated buffer views, which represents views into the main glTF buffer data
  89593. */
  89594. _bufferViews: IBufferView[];
  89595. /**
  89596. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  89597. */
  89598. _accessors: IAccessor[];
  89599. /**
  89600. * Stores all the generated nodes, which contains transform and/or mesh information per node
  89601. */
  89602. _nodes: INode[];
  89603. /**
  89604. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  89605. */
  89606. private _scenes;
  89607. /**
  89608. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  89609. */
  89610. private _meshes;
  89611. /**
  89612. * Stores all the generated material information, which represents the appearance of each primitive
  89613. */
  89614. _materials: IMaterial[];
  89615. _materialMap: {
  89616. [materialID: number]: number;
  89617. };
  89618. /**
  89619. * Stores all the generated texture information, which is referenced by glTF materials
  89620. */
  89621. _textures: ITexture[];
  89622. /**
  89623. * Stores all the generated image information, which is referenced by glTF textures
  89624. */
  89625. _images: IImage[];
  89626. /**
  89627. * Stores all the texture samplers
  89628. */
  89629. _samplers: ISampler[];
  89630. /**
  89631. * Stores all the generated glTF skins
  89632. */
  89633. _skins: ISkin[];
  89634. /**
  89635. * Stores all the generated animation samplers, which is referenced by glTF animations
  89636. */
  89637. /**
  89638. * Stores the animations for glTF models
  89639. */
  89640. private _animations;
  89641. /**
  89642. * Stores the total amount of bytes stored in the glTF buffer
  89643. */
  89644. private _totalByteLength;
  89645. /**
  89646. * Stores a reference to the Babylon scene containing the source geometry and material information
  89647. */
  89648. _babylonScene: Scene;
  89649. /**
  89650. * Stores a map of the image data, where the key is the file name and the value
  89651. * is the image data
  89652. */
  89653. _imageData: {
  89654. [fileName: string]: {
  89655. data: Uint8Array;
  89656. mimeType: ImageMimeType;
  89657. };
  89658. };
  89659. protected _orderedImageData: Array<{
  89660. data: Uint8Array;
  89661. mimeType: ImageMimeType;
  89662. }>;
  89663. /**
  89664. * Stores a map of the unique id of a node to its index in the node array
  89665. */
  89666. _nodeMap: {
  89667. [key: number]: number;
  89668. };
  89669. /**
  89670. * Specifies if the source Babylon scene was left handed, and needed conversion.
  89671. */
  89672. _convertToRightHandedSystem: boolean;
  89673. /**
  89674. * Specifies if a Babylon node should be converted to right-handed on export
  89675. */
  89676. _convertToRightHandedSystemMap: {
  89677. [nodeId: number]: boolean;
  89678. };
  89679. _includeCoordinateSystemConversionNodes: boolean;
  89680. /**
  89681. * Baked animation sample rate
  89682. */
  89683. private _animationSampleRate;
  89684. private _options;
  89685. private _localEngine;
  89686. _glTFMaterialExporter: _GLTFMaterialExporter;
  89687. private _extensions;
  89688. private static _ExtensionNames;
  89689. private static _ExtensionFactories;
  89690. private _applyExtension;
  89691. private _applyExtensions;
  89692. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  89693. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  89694. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89695. [key: number]: number;
  89696. }): Promise<Nullable<INode>>;
  89697. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  89698. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  89699. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89700. private _forEachExtensions;
  89701. private _extensionsOnExporting;
  89702. /**
  89703. * Load glTF serializer extensions
  89704. */
  89705. private _loadExtensions;
  89706. /**
  89707. * Creates a glTF Exporter instance, which can accept optional exporter options
  89708. * @param babylonScene Babylon scene object
  89709. * @param options Options to modify the behavior of the exporter
  89710. */
  89711. constructor(babylonScene: Scene, options?: IExportOptions);
  89712. dispose(): void;
  89713. /**
  89714. * Registers a glTF exporter extension
  89715. * @param name Name of the extension to export
  89716. * @param factory The factory function that creates the exporter extension
  89717. */
  89718. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  89719. /**
  89720. * Un-registers an exporter extension
  89721. * @param name The name fo the exporter extension
  89722. * @returns A boolean indicating whether the extension has been un-registered
  89723. */
  89724. static UnregisterExtension(name: string): boolean;
  89725. private reorderIndicesBasedOnPrimitiveMode;
  89726. /**
  89727. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  89728. * clock-wise during export to glTF
  89729. * @param submesh BabylonJS submesh
  89730. * @param primitiveMode Primitive mode of the mesh
  89731. * @param sideOrientation the winding order of the submesh
  89732. * @param vertexBufferKind The type of vertex attribute
  89733. * @param meshAttributeArray The vertex attribute data
  89734. * @param byteOffset The offset to the binary data
  89735. * @param binaryWriter The binary data for the glTF file
  89736. * @param convertToRightHandedSystem Converts the values to right-handed
  89737. */
  89738. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  89739. /**
  89740. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  89741. * clock-wise during export to glTF
  89742. * @param submesh BabylonJS submesh
  89743. * @param primitiveMode Primitive mode of the mesh
  89744. * @param sideOrientation the winding order of the submesh
  89745. * @param vertexBufferKind The type of vertex attribute
  89746. * @param meshAttributeArray The vertex attribute data
  89747. * @param byteOffset The offset to the binary data
  89748. * @param binaryWriter The binary data for the glTF file
  89749. * @param convertToRightHandedSystem Converts the values to right-handed
  89750. */
  89751. private reorderTriangleFillMode;
  89752. /**
  89753. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  89754. * clock-wise during export to glTF
  89755. * @param submesh BabylonJS submesh
  89756. * @param primitiveMode Primitive mode of the mesh
  89757. * @param sideOrientation the winding order of the submesh
  89758. * @param vertexBufferKind The type of vertex attribute
  89759. * @param meshAttributeArray The vertex attribute data
  89760. * @param byteOffset The offset to the binary data
  89761. * @param binaryWriter The binary data for the glTF file
  89762. * @param convertToRightHandedSystem Converts the values to right-handed
  89763. */
  89764. private reorderTriangleStripDrawMode;
  89765. /**
  89766. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  89767. * clock-wise during export to glTF
  89768. * @param submesh BabylonJS submesh
  89769. * @param primitiveMode Primitive mode of the mesh
  89770. * @param sideOrientation the winding order of the submesh
  89771. * @param vertexBufferKind The type of vertex attribute
  89772. * @param meshAttributeArray The vertex attribute data
  89773. * @param byteOffset The offset to the binary data
  89774. * @param binaryWriter The binary data for the glTF file
  89775. * @param convertToRightHandedSystem Converts the values to right-handed
  89776. */
  89777. private reorderTriangleFanMode;
  89778. /**
  89779. * Writes the vertex attribute data to binary
  89780. * @param vertices The vertices to write to the binary writer
  89781. * @param byteOffset The offset into the binary writer to overwrite binary data
  89782. * @param vertexAttributeKind The vertex attribute type
  89783. * @param meshAttributeArray The vertex attribute data
  89784. * @param binaryWriter The writer containing the binary data
  89785. * @param convertToRightHandedSystem Converts the values to right-handed
  89786. */
  89787. private writeVertexAttributeData;
  89788. /**
  89789. * Writes mesh attribute data to a data buffer
  89790. * Returns the bytelength of the data
  89791. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89792. * @param meshAttributeArray Array containing the attribute data
  89793. * @param byteStride Specifies the space between data
  89794. * @param binaryWriter The buffer to write the binary data to
  89795. * @param convertToRightHandedSystem Converts the values to right-handed
  89796. */
  89797. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  89798. /**
  89799. * Writes mesh attribute data to a data buffer
  89800. * Returns the bytelength of the data
  89801. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89802. * @param meshAttributeArray Array containing the attribute data
  89803. * @param byteStride Specifies the space between data
  89804. * @param binaryWriter The buffer to write the binary data to
  89805. * @param convertToRightHandedSystem Converts the values to right-handed
  89806. */
  89807. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  89808. /**
  89809. * Generates glTF json data
  89810. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  89811. * @param glTFPrefix Text to use when prefixing a glTF file
  89812. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  89813. * @returns json data as string
  89814. */
  89815. private generateJSON;
  89816. /**
  89817. * Generates data for .gltf and .bin files based on the glTF prefix string
  89818. * @param glTFPrefix Text to use when prefixing a glTF file
  89819. * @param dispose Dispose the exporter
  89820. * @returns GLTFData with glTF file data
  89821. */
  89822. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89823. /**
  89824. * Creates a binary buffer for glTF
  89825. * @returns array buffer for binary data
  89826. */
  89827. private _generateBinaryAsync;
  89828. /**
  89829. * Pads the number to a multiple of 4
  89830. * @param num number to pad
  89831. * @returns padded number
  89832. */
  89833. private _getPadding;
  89834. /**
  89835. * @hidden
  89836. */
  89837. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89838. /**
  89839. * Sets the TRS for each node
  89840. * @param node glTF Node for storing the transformation data
  89841. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  89842. * @param convertToRightHandedSystem Converts the values to right-handed
  89843. */
  89844. private setNodeTransformation;
  89845. private getVertexBufferFromMesh;
  89846. /**
  89847. * Creates a bufferview based on the vertices type for the Babylon mesh
  89848. * @param kind Indicates the type of vertices data
  89849. * @param componentType Indicates the numerical type used to store the data
  89850. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  89851. * @param binaryWriter The buffer to write the bufferview data to
  89852. * @param convertToRightHandedSystem Converts the values to right-handed
  89853. */
  89854. private createBufferViewKind;
  89855. /**
  89856. * Creates a bufferview based on the vertices type for the Babylon mesh
  89857. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  89858. * @param babylonMorphTarget the morph target to be exported
  89859. * @param binaryWriter The buffer to write the bufferview data to
  89860. * @param convertToRightHandedSystem Converts the values to right-handed
  89861. */
  89862. private setMorphTargetAttributes;
  89863. /**
  89864. * The primitive mode of the Babylon mesh
  89865. * @param babylonMesh The BabylonJS mesh
  89866. */
  89867. private getMeshPrimitiveMode;
  89868. /**
  89869. * Sets the primitive mode of the glTF mesh primitive
  89870. * @param meshPrimitive glTF mesh primitive
  89871. * @param primitiveMode The primitive mode
  89872. */
  89873. private setPrimitiveMode;
  89874. /**
  89875. * Sets the vertex attribute accessor based of the glTF mesh primitive
  89876. * @param meshPrimitive glTF mesh primitive
  89877. * @param attributeKind vertex attribute
  89878. * @returns boolean specifying if uv coordinates are present
  89879. */
  89880. private setAttributeKind;
  89881. /**
  89882. * Sets data for the primitive attributes of each submesh
  89883. * @param mesh glTF Mesh object to store the primitive attribute information
  89884. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  89885. * @param binaryWriter Buffer to write the attribute data to
  89886. * @param convertToRightHandedSystem Converts the values to right-handed
  89887. */
  89888. private setPrimitiveAttributesAsync;
  89889. /**
  89890. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  89891. * @param node The node to check
  89892. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  89893. */
  89894. private isBabylonCoordinateSystemConvertingNode;
  89895. /**
  89896. * Creates a glTF scene based on the array of meshes
  89897. * Returns the the total byte offset
  89898. * @param babylonScene Babylon scene to get the mesh data from
  89899. * @param binaryWriter Buffer to write binary data to
  89900. */
  89901. private createSceneAsync;
  89902. /**
  89903. * Creates a mapping of Node unique id to node index and handles animations
  89904. * @param babylonScene Babylon Scene
  89905. * @param nodes Babylon transform nodes
  89906. * @param binaryWriter Buffer to write binary data to
  89907. * @returns Node mapping of unique id to index
  89908. */
  89909. private createNodeMapAndAnimationsAsync;
  89910. /**
  89911. * Creates a glTF node from a Babylon mesh
  89912. * @param babylonMesh Source Babylon mesh
  89913. * @param binaryWriter Buffer for storing geometry data
  89914. * @param convertToRightHandedSystem Converts the values to right-handed
  89915. * @param nodeMap Node mapping of unique id to glTF node index
  89916. * @returns glTF node
  89917. */
  89918. private createNodeAsync;
  89919. /**
  89920. * Creates a glTF skin from a Babylon skeleton
  89921. * @param babylonScene Babylon Scene
  89922. * @param nodes Babylon transform nodes
  89923. * @param binaryWriter Buffer to write binary data to
  89924. * @returns Node mapping of unique id to index
  89925. */
  89926. private createSkinsAsync;
  89927. }
  89928. /**
  89929. * @hidden
  89930. *
  89931. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  89932. */
  89933. export class _BinaryWriter {
  89934. /**
  89935. * Array buffer which stores all binary data
  89936. */
  89937. private _arrayBuffer;
  89938. /**
  89939. * View of the array buffer
  89940. */
  89941. private _dataView;
  89942. /**
  89943. * byte offset of data in array buffer
  89944. */
  89945. private _byteOffset;
  89946. /**
  89947. * Initialize binary writer with an initial byte length
  89948. * @param byteLength Initial byte length of the array buffer
  89949. */
  89950. constructor(byteLength: number);
  89951. /**
  89952. * Resize the array buffer to the specified byte length
  89953. * @param byteLength
  89954. */
  89955. private resizeBuffer;
  89956. /**
  89957. * Get an array buffer with the length of the byte offset
  89958. * @returns ArrayBuffer resized to the byte offset
  89959. */
  89960. getArrayBuffer(): ArrayBuffer;
  89961. /**
  89962. * Get the byte offset of the array buffer
  89963. * @returns byte offset
  89964. */
  89965. getByteOffset(): number;
  89966. /**
  89967. * Stores an UInt8 in the array buffer
  89968. * @param entry
  89969. * @param byteOffset If defined, specifies where to set the value as an offset.
  89970. */
  89971. setUInt8(entry: number, byteOffset?: number): void;
  89972. /**
  89973. * Stores an UInt16 in the array buffer
  89974. * @param entry
  89975. * @param byteOffset If defined, specifies where to set the value as an offset.
  89976. */
  89977. setUInt16(entry: number, byteOffset?: number): void;
  89978. /**
  89979. * Gets an UInt32 in the array buffer
  89980. * @param entry
  89981. * @param byteOffset If defined, specifies where to set the value as an offset.
  89982. */
  89983. getUInt32(byteOffset: number): number;
  89984. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89985. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89986. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89987. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89988. /**
  89989. * Stores a Float32 in the array buffer
  89990. * @param entry
  89991. */
  89992. setFloat32(entry: number, byteOffset?: number): void;
  89993. /**
  89994. * Stores an UInt32 in the array buffer
  89995. * @param entry
  89996. * @param byteOffset If defined, specifies where to set the value as an offset.
  89997. */
  89998. setUInt32(entry: number, byteOffset?: number): void;
  89999. }
  90000. }
  90001. declare module BABYLON.GLTF2.Exporter {
  90002. /**
  90003. * @hidden
  90004. * Interface to store animation data.
  90005. */
  90006. export interface _IAnimationData {
  90007. /**
  90008. * Keyframe data.
  90009. */
  90010. inputs: number[];
  90011. /**
  90012. * Value data.
  90013. */
  90014. outputs: number[][];
  90015. /**
  90016. * Animation interpolation data.
  90017. */
  90018. samplerInterpolation: AnimationSamplerInterpolation;
  90019. /**
  90020. * Minimum keyframe value.
  90021. */
  90022. inputsMin: number;
  90023. /**
  90024. * Maximum keyframe value.
  90025. */
  90026. inputsMax: number;
  90027. }
  90028. /**
  90029. * @hidden
  90030. */
  90031. export interface _IAnimationInfo {
  90032. /**
  90033. * The target channel for the animation
  90034. */
  90035. animationChannelTargetPath: AnimationChannelTargetPath;
  90036. /**
  90037. * The glTF accessor type for the data.
  90038. */
  90039. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  90040. /**
  90041. * Specifies if quaternions should be used.
  90042. */
  90043. useQuaternion: boolean;
  90044. }
  90045. /**
  90046. * @hidden
  90047. * Utility class for generating glTF animation data from BabylonJS.
  90048. */
  90049. export class _GLTFAnimation {
  90050. /**
  90051. * @ignore
  90052. *
  90053. * Creates glTF channel animation from BabylonJS animation.
  90054. * @param babylonTransformNode - BabylonJS mesh.
  90055. * @param animation - animation.
  90056. * @param animationChannelTargetPath - The target animation channel.
  90057. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  90058. * @param useQuaternion - Specifies if quaternions are used.
  90059. * @returns nullable IAnimationData
  90060. */
  90061. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  90062. private static _DeduceAnimationInfo;
  90063. /**
  90064. * @ignore
  90065. * Create node animations from the transform node animations
  90066. * @param babylonNode
  90067. * @param runtimeGLTFAnimation
  90068. * @param idleGLTFAnimations
  90069. * @param nodeMap
  90070. * @param nodes
  90071. * @param binaryWriter
  90072. * @param bufferViews
  90073. * @param accessors
  90074. * @param convertToRightHandedSystem
  90075. * @param animationSampleRate
  90076. */
  90077. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90078. [key: number]: number;
  90079. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90080. /**
  90081. * @ignore
  90082. * Create individual morph animations from the mesh's morph target animation tracks
  90083. * @param babylonNode
  90084. * @param runtimeGLTFAnimation
  90085. * @param idleGLTFAnimations
  90086. * @param nodeMap
  90087. * @param nodes
  90088. * @param binaryWriter
  90089. * @param bufferViews
  90090. * @param accessors
  90091. * @param convertToRightHandedSystem
  90092. * @param animationSampleRate
  90093. */
  90094. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90095. [key: number]: number;
  90096. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90097. /**
  90098. * @ignore
  90099. * Create node and morph animations from the animation groups
  90100. * @param babylonScene
  90101. * @param glTFAnimations
  90102. * @param nodeMap
  90103. * @param nodes
  90104. * @param binaryWriter
  90105. * @param bufferViews
  90106. * @param accessors
  90107. * @param convertToRightHandedSystemMap
  90108. * @param animationSampleRate
  90109. */
  90110. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  90111. [key: number]: number;
  90112. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  90113. [nodeId: number]: boolean;
  90114. }, animationSampleRate: number): void;
  90115. private static AddAnimation;
  90116. /**
  90117. * Create a baked animation
  90118. * @param babylonTransformNode BabylonJS mesh
  90119. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  90120. * @param animationChannelTargetPath animation target channel
  90121. * @param minFrame minimum animation frame
  90122. * @param maxFrame maximum animation frame
  90123. * @param fps frames per second of the animation
  90124. * @param inputs input key frames of the animation
  90125. * @param outputs output key frame data of the animation
  90126. * @param convertToRightHandedSystem converts the values to right-handed
  90127. * @param useQuaternion specifies if quaternions should be used
  90128. */
  90129. private static _CreateBakedAnimation;
  90130. private static _ConvertFactorToVector3OrQuaternion;
  90131. private static _SetInterpolatedValue;
  90132. /**
  90133. * Creates linear animation from the animation key frames
  90134. * @param babylonTransformNode BabylonJS mesh
  90135. * @param animation BabylonJS animation
  90136. * @param animationChannelTargetPath The target animation channel
  90137. * @param frameDelta The difference between the last and first frame of the animation
  90138. * @param inputs Array to store the key frame times
  90139. * @param outputs Array to store the key frame data
  90140. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90141. * @param useQuaternion Specifies if quaternions are used in the animation
  90142. */
  90143. private static _CreateLinearOrStepAnimation;
  90144. /**
  90145. * Creates cubic spline animation from the animation key frames
  90146. * @param babylonTransformNode BabylonJS mesh
  90147. * @param animation BabylonJS animation
  90148. * @param animationChannelTargetPath The target animation channel
  90149. * @param frameDelta The difference between the last and first frame of the animation
  90150. * @param inputs Array to store the key frame times
  90151. * @param outputs Array to store the key frame data
  90152. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90153. * @param useQuaternion Specifies if quaternions are used in the animation
  90154. */
  90155. private static _CreateCubicSplineAnimation;
  90156. private static _GetBasePositionRotationOrScale;
  90157. /**
  90158. * Adds a key frame value
  90159. * @param keyFrame
  90160. * @param animation
  90161. * @param outputs
  90162. * @param animationChannelTargetPath
  90163. * @param basePositionRotationOrScale
  90164. * @param convertToRightHandedSystem
  90165. * @param useQuaternion
  90166. */
  90167. private static _AddKeyframeValue;
  90168. /**
  90169. * Determine the interpolation based on the key frames
  90170. * @param keyFrames
  90171. * @param animationChannelTargetPath
  90172. * @param useQuaternion
  90173. */
  90174. private static _DeduceInterpolation;
  90175. /**
  90176. * Adds an input tangent or output tangent to the output data
  90177. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  90178. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  90179. * @param outputs The animation data by keyframe
  90180. * @param animationChannelTargetPath The target animation channel
  90181. * @param interpolation The interpolation type
  90182. * @param keyFrame The key frame with the animation data
  90183. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  90184. * @param useQuaternion Specifies if quaternions are used
  90185. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  90186. */
  90187. private static AddSplineTangent;
  90188. /**
  90189. * Get the minimum and maximum key frames' frame values
  90190. * @param keyFrames animation key frames
  90191. * @returns the minimum and maximum key frame value
  90192. */
  90193. private static calculateMinMaxKeyFrames;
  90194. }
  90195. }
  90196. declare module BABYLON.GLTF2.Exporter {
  90197. /** @hidden */
  90198. export var textureTransformPixelShader: {
  90199. name: string;
  90200. shader: string;
  90201. };
  90202. }
  90203. declare module BABYLON.GLTF2.Exporter.Extensions {
  90204. /**
  90205. * @hidden
  90206. */
  90207. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  90208. private _recordedTextures;
  90209. /** Name of this extension */
  90210. readonly name: string;
  90211. /** Defines whether this extension is enabled */
  90212. enabled: boolean;
  90213. /** Defines whether this extension is required */
  90214. required: boolean;
  90215. /** Reference to the glTF exporter */
  90216. private _wasUsed;
  90217. constructor(exporter: _Exporter);
  90218. dispose(): void;
  90219. /** @hidden */
  90220. get wasUsed(): boolean;
  90221. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90222. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  90223. /**
  90224. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  90225. * @param babylonTexture
  90226. * @param offset
  90227. * @param rotation
  90228. * @param scale
  90229. * @param scene
  90230. */
  90231. private _textureTransformTextureAsync;
  90232. }
  90233. }
  90234. declare module BABYLON.GLTF2.Exporter.Extensions {
  90235. /**
  90236. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90237. */
  90238. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90239. /** The name of this extension. */
  90240. readonly name: string;
  90241. /** Defines whether this extension is enabled. */
  90242. enabled: boolean;
  90243. /** Defines whether this extension is required */
  90244. required: boolean;
  90245. /** Reference to the glTF exporter */
  90246. private _exporter;
  90247. private _lights;
  90248. /** @hidden */
  90249. constructor(exporter: _Exporter);
  90250. /** @hidden */
  90251. dispose(): void;
  90252. /** @hidden */
  90253. get wasUsed(): boolean;
  90254. /** @hidden */
  90255. onExporting(): void;
  90256. /**
  90257. * Define this method to modify the default behavior when exporting a node
  90258. * @param context The context when exporting the node
  90259. * @param node glTF node
  90260. * @param babylonNode BabylonJS node
  90261. * @param nodeMap Node mapping of unique id to glTF node index
  90262. * @returns nullable INode promise
  90263. */
  90264. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90265. [key: number]: number;
  90266. }): Promise<Nullable<INode>>;
  90267. }
  90268. }
  90269. declare module BABYLON.GLTF2.Exporter.Extensions {
  90270. /**
  90271. * @hidden
  90272. */
  90273. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90274. /** Name of this extension */
  90275. readonly name: string;
  90276. /** Defines whether this extension is enabled */
  90277. enabled: boolean;
  90278. /** Defines whether this extension is required */
  90279. required: boolean;
  90280. /** Reference to the glTF exporter */
  90281. private _textureInfos;
  90282. private _exportedTextures;
  90283. private _wasUsed;
  90284. constructor(exporter: _Exporter);
  90285. dispose(): void;
  90286. /** @hidden */
  90287. get wasUsed(): boolean;
  90288. private _getTextureIndex;
  90289. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90290. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90291. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90292. }
  90293. }
  90294. declare module BABYLON.GLTF2.Exporter.Extensions {
  90295. /**
  90296. * @hidden
  90297. */
  90298. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90299. /** Name of this extension */
  90300. readonly name: string;
  90301. /** Defines whether this extension is enabled */
  90302. enabled: boolean;
  90303. /** Defines whether this extension is required */
  90304. required: boolean;
  90305. private _wasUsed;
  90306. constructor(exporter: _Exporter);
  90307. /** @hidden */
  90308. get wasUsed(): boolean;
  90309. dispose(): void;
  90310. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90311. }
  90312. }
  90313. declare module BABYLON {
  90314. /**
  90315. * Class for generating STL data from a Babylon scene.
  90316. */
  90317. export class STLExport {
  90318. /**
  90319. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90320. * @param meshes list defines the mesh to serialize
  90321. * @param download triggers the automatic download of the file.
  90322. * @param fileName changes the downloads fileName.
  90323. * @param binary changes the STL to a binary type.
  90324. * @param isLittleEndian toggle for binary type exporter.
  90325. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90326. * @returns the STL as UTF8 string
  90327. */
  90328. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90329. }
  90330. }
  90331. declare module "babylonjs-gltf2interface" {
  90332. export = BABYLON.GLTF2;
  90333. }
  90334. /**
  90335. * Module for glTF 2.0 Interface
  90336. */
  90337. declare module BABYLON.GLTF2 {
  90338. /**
  90339. * The datatype of the components in the attribute
  90340. */
  90341. const enum AccessorComponentType {
  90342. /**
  90343. * Byte
  90344. */
  90345. BYTE = 5120,
  90346. /**
  90347. * Unsigned Byte
  90348. */
  90349. UNSIGNED_BYTE = 5121,
  90350. /**
  90351. * Short
  90352. */
  90353. SHORT = 5122,
  90354. /**
  90355. * Unsigned Short
  90356. */
  90357. UNSIGNED_SHORT = 5123,
  90358. /**
  90359. * Unsigned Int
  90360. */
  90361. UNSIGNED_INT = 5125,
  90362. /**
  90363. * Float
  90364. */
  90365. FLOAT = 5126,
  90366. }
  90367. /**
  90368. * Specifies if the attirbute is a scalar, vector, or matrix
  90369. */
  90370. const enum AccessorType {
  90371. /**
  90372. * Scalar
  90373. */
  90374. SCALAR = "SCALAR",
  90375. /**
  90376. * Vector2
  90377. */
  90378. VEC2 = "VEC2",
  90379. /**
  90380. * Vector3
  90381. */
  90382. VEC3 = "VEC3",
  90383. /**
  90384. * Vector4
  90385. */
  90386. VEC4 = "VEC4",
  90387. /**
  90388. * Matrix2x2
  90389. */
  90390. MAT2 = "MAT2",
  90391. /**
  90392. * Matrix3x3
  90393. */
  90394. MAT3 = "MAT3",
  90395. /**
  90396. * Matrix4x4
  90397. */
  90398. MAT4 = "MAT4",
  90399. }
  90400. /**
  90401. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90402. */
  90403. const enum AnimationChannelTargetPath {
  90404. /**
  90405. * Translation
  90406. */
  90407. TRANSLATION = "translation",
  90408. /**
  90409. * Rotation
  90410. */
  90411. ROTATION = "rotation",
  90412. /**
  90413. * Scale
  90414. */
  90415. SCALE = "scale",
  90416. /**
  90417. * Weights
  90418. */
  90419. WEIGHTS = "weights",
  90420. }
  90421. /**
  90422. * Interpolation algorithm
  90423. */
  90424. const enum AnimationSamplerInterpolation {
  90425. /**
  90426. * The animated values are linearly interpolated between keyframes
  90427. */
  90428. LINEAR = "LINEAR",
  90429. /**
  90430. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90431. */
  90432. STEP = "STEP",
  90433. /**
  90434. * The animation's interpolation is computed using a cubic spline with specified tangents
  90435. */
  90436. CUBICSPLINE = "CUBICSPLINE",
  90437. }
  90438. /**
  90439. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90440. */
  90441. const enum CameraType {
  90442. /**
  90443. * A perspective camera containing properties to create a perspective projection matrix
  90444. */
  90445. PERSPECTIVE = "perspective",
  90446. /**
  90447. * An orthographic camera containing properties to create an orthographic projection matrix
  90448. */
  90449. ORTHOGRAPHIC = "orthographic",
  90450. }
  90451. /**
  90452. * The mime-type of the image
  90453. */
  90454. const enum ImageMimeType {
  90455. /**
  90456. * JPEG Mime-type
  90457. */
  90458. JPEG = "image/jpeg",
  90459. /**
  90460. * PNG Mime-type
  90461. */
  90462. PNG = "image/png",
  90463. }
  90464. /**
  90465. * The alpha rendering mode of the material
  90466. */
  90467. const enum MaterialAlphaMode {
  90468. /**
  90469. * The alpha value is ignored and the rendered output is fully opaque
  90470. */
  90471. OPAQUE = "OPAQUE",
  90472. /**
  90473. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90474. */
  90475. MASK = "MASK",
  90476. /**
  90477. * 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)
  90478. */
  90479. BLEND = "BLEND",
  90480. }
  90481. /**
  90482. * The type of the primitives to render
  90483. */
  90484. const enum MeshPrimitiveMode {
  90485. /**
  90486. * Points
  90487. */
  90488. POINTS = 0,
  90489. /**
  90490. * Lines
  90491. */
  90492. LINES = 1,
  90493. /**
  90494. * Line Loop
  90495. */
  90496. LINE_LOOP = 2,
  90497. /**
  90498. * Line Strip
  90499. */
  90500. LINE_STRIP = 3,
  90501. /**
  90502. * Triangles
  90503. */
  90504. TRIANGLES = 4,
  90505. /**
  90506. * Triangle Strip
  90507. */
  90508. TRIANGLE_STRIP = 5,
  90509. /**
  90510. * Triangle Fan
  90511. */
  90512. TRIANGLE_FAN = 6,
  90513. }
  90514. /**
  90515. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90516. */
  90517. const enum TextureMagFilter {
  90518. /**
  90519. * Nearest
  90520. */
  90521. NEAREST = 9728,
  90522. /**
  90523. * Linear
  90524. */
  90525. LINEAR = 9729,
  90526. }
  90527. /**
  90528. * Minification filter. All valid values correspond to WebGL enums
  90529. */
  90530. const enum TextureMinFilter {
  90531. /**
  90532. * Nearest
  90533. */
  90534. NEAREST = 9728,
  90535. /**
  90536. * Linear
  90537. */
  90538. LINEAR = 9729,
  90539. /**
  90540. * Nearest Mip-Map Nearest
  90541. */
  90542. NEAREST_MIPMAP_NEAREST = 9984,
  90543. /**
  90544. * Linear Mipmap Nearest
  90545. */
  90546. LINEAR_MIPMAP_NEAREST = 9985,
  90547. /**
  90548. * Nearest Mipmap Linear
  90549. */
  90550. NEAREST_MIPMAP_LINEAR = 9986,
  90551. /**
  90552. * Linear Mipmap Linear
  90553. */
  90554. LINEAR_MIPMAP_LINEAR = 9987,
  90555. }
  90556. /**
  90557. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90558. */
  90559. const enum TextureWrapMode {
  90560. /**
  90561. * Clamp to Edge
  90562. */
  90563. CLAMP_TO_EDGE = 33071,
  90564. /**
  90565. * Mirrored Repeat
  90566. */
  90567. MIRRORED_REPEAT = 33648,
  90568. /**
  90569. * Repeat
  90570. */
  90571. REPEAT = 10497,
  90572. }
  90573. /**
  90574. * glTF Property
  90575. */
  90576. interface IProperty {
  90577. /**
  90578. * Dictionary object with extension-specific objects
  90579. */
  90580. extensions?: {
  90581. [key: string]: any;
  90582. };
  90583. /**
  90584. * Application-Specific data
  90585. */
  90586. extras?: any;
  90587. }
  90588. /**
  90589. * glTF Child of Root Property
  90590. */
  90591. interface IChildRootProperty extends IProperty {
  90592. /**
  90593. * The user-defined name of this object
  90594. */
  90595. name?: string;
  90596. }
  90597. /**
  90598. * Indices of those attributes that deviate from their initialization value
  90599. */
  90600. interface IAccessorSparseIndices extends IProperty {
  90601. /**
  90602. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90603. */
  90604. bufferView: number;
  90605. /**
  90606. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90607. */
  90608. byteOffset?: number;
  90609. /**
  90610. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  90611. */
  90612. componentType: AccessorComponentType;
  90613. }
  90614. /**
  90615. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  90616. */
  90617. interface IAccessorSparseValues extends IProperty {
  90618. /**
  90619. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90620. */
  90621. bufferView: number;
  90622. /**
  90623. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90624. */
  90625. byteOffset?: number;
  90626. }
  90627. /**
  90628. * Sparse storage of attributes that deviate from their initialization value
  90629. */
  90630. interface IAccessorSparse extends IProperty {
  90631. /**
  90632. * The number of attributes encoded in this sparse accessor
  90633. */
  90634. count: number;
  90635. /**
  90636. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  90637. */
  90638. indices: IAccessorSparseIndices;
  90639. /**
  90640. * 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
  90641. */
  90642. values: IAccessorSparseValues;
  90643. }
  90644. /**
  90645. * 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
  90646. */
  90647. interface IAccessor extends IChildRootProperty {
  90648. /**
  90649. * The index of the bufferview
  90650. */
  90651. bufferView?: number;
  90652. /**
  90653. * The offset relative to the start of the bufferView in bytes
  90654. */
  90655. byteOffset?: number;
  90656. /**
  90657. * The datatype of components in the attribute
  90658. */
  90659. componentType: AccessorComponentType;
  90660. /**
  90661. * Specifies whether integer data values should be normalized
  90662. */
  90663. normalized?: boolean;
  90664. /**
  90665. * The number of attributes referenced by this accessor
  90666. */
  90667. count: number;
  90668. /**
  90669. * Specifies if the attribute is a scalar, vector, or matrix
  90670. */
  90671. type: AccessorType;
  90672. /**
  90673. * Maximum value of each component in this attribute
  90674. */
  90675. max?: number[];
  90676. /**
  90677. * Minimum value of each component in this attribute
  90678. */
  90679. min?: number[];
  90680. /**
  90681. * Sparse storage of attributes that deviate from their initialization value
  90682. */
  90683. sparse?: IAccessorSparse;
  90684. }
  90685. /**
  90686. * Targets an animation's sampler at a node's property
  90687. */
  90688. interface IAnimationChannel extends IProperty {
  90689. /**
  90690. * The index of a sampler in this animation used to compute the value for the target
  90691. */
  90692. sampler: number;
  90693. /**
  90694. * The index of the node and TRS property to target
  90695. */
  90696. target: IAnimationChannelTarget;
  90697. }
  90698. /**
  90699. * The index of the node and TRS property that an animation channel targets
  90700. */
  90701. interface IAnimationChannelTarget extends IProperty {
  90702. /**
  90703. * The index of the node to target
  90704. */
  90705. node: number;
  90706. /**
  90707. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90708. */
  90709. path: AnimationChannelTargetPath;
  90710. }
  90711. /**
  90712. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90713. */
  90714. interface IAnimationSampler extends IProperty {
  90715. /**
  90716. * The index of an accessor containing keyframe input values, e.g., time
  90717. */
  90718. input: number;
  90719. /**
  90720. * Interpolation algorithm
  90721. */
  90722. interpolation?: AnimationSamplerInterpolation;
  90723. /**
  90724. * The index of an accessor, containing keyframe output values
  90725. */
  90726. output: number;
  90727. }
  90728. /**
  90729. * A keyframe animation
  90730. */
  90731. interface IAnimation extends IChildRootProperty {
  90732. /**
  90733. * An array of channels, each of which targets an animation's sampler at a node's property
  90734. */
  90735. channels: IAnimationChannel[];
  90736. /**
  90737. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90738. */
  90739. samplers: IAnimationSampler[];
  90740. }
  90741. /**
  90742. * Metadata about the glTF asset
  90743. */
  90744. interface IAsset extends IChildRootProperty {
  90745. /**
  90746. * A copyright message suitable for display to credit the content creator
  90747. */
  90748. copyright?: string;
  90749. /**
  90750. * Tool that generated this glTF model. Useful for debugging
  90751. */
  90752. generator?: string;
  90753. /**
  90754. * The glTF version that this asset targets
  90755. */
  90756. version: string;
  90757. /**
  90758. * The minimum glTF version that this asset targets
  90759. */
  90760. minVersion?: string;
  90761. }
  90762. /**
  90763. * A buffer points to binary geometry, animation, or skins
  90764. */
  90765. interface IBuffer extends IChildRootProperty {
  90766. /**
  90767. * 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
  90768. */
  90769. uri?: string;
  90770. /**
  90771. * The length of the buffer in bytes
  90772. */
  90773. byteLength: number;
  90774. }
  90775. /**
  90776. * A view into a buffer generally representing a subset of the buffer
  90777. */
  90778. interface IBufferView extends IChildRootProperty {
  90779. /**
  90780. * The index of the buffer
  90781. */
  90782. buffer: number;
  90783. /**
  90784. * The offset into the buffer in bytes
  90785. */
  90786. byteOffset?: number;
  90787. /**
  90788. * The lenth of the bufferView in bytes
  90789. */
  90790. byteLength: number;
  90791. /**
  90792. * The stride, in bytes
  90793. */
  90794. byteStride?: number;
  90795. }
  90796. /**
  90797. * An orthographic camera containing properties to create an orthographic projection matrix
  90798. */
  90799. interface ICameraOrthographic extends IProperty {
  90800. /**
  90801. * The floating-point horizontal magnification of the view. Must not be zero
  90802. */
  90803. xmag: number;
  90804. /**
  90805. * The floating-point vertical magnification of the view. Must not be zero
  90806. */
  90807. ymag: number;
  90808. /**
  90809. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  90810. */
  90811. zfar: number;
  90812. /**
  90813. * The floating-point distance to the near clipping plane
  90814. */
  90815. znear: number;
  90816. }
  90817. /**
  90818. * A perspective camera containing properties to create a perspective projection matrix
  90819. */
  90820. interface ICameraPerspective extends IProperty {
  90821. /**
  90822. * The floating-point aspect ratio of the field of view
  90823. */
  90824. aspectRatio?: number;
  90825. /**
  90826. * The floating-point vertical field of view in radians
  90827. */
  90828. yfov: number;
  90829. /**
  90830. * The floating-point distance to the far clipping plane
  90831. */
  90832. zfar?: number;
  90833. /**
  90834. * The floating-point distance to the near clipping plane
  90835. */
  90836. znear: number;
  90837. }
  90838. /**
  90839. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90840. */
  90841. interface ICamera extends IChildRootProperty {
  90842. /**
  90843. * An orthographic camera containing properties to create an orthographic projection matrix
  90844. */
  90845. orthographic?: ICameraOrthographic;
  90846. /**
  90847. * A perspective camera containing properties to create a perspective projection matrix
  90848. */
  90849. perspective?: ICameraPerspective;
  90850. /**
  90851. * Specifies if the camera uses a perspective or orthographic projection
  90852. */
  90853. type: CameraType;
  90854. }
  90855. /**
  90856. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  90857. */
  90858. interface IImage extends IChildRootProperty {
  90859. /**
  90860. * 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
  90861. */
  90862. uri?: string;
  90863. /**
  90864. * The image's MIME type
  90865. */
  90866. mimeType?: ImageMimeType;
  90867. /**
  90868. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  90869. */
  90870. bufferView?: number;
  90871. }
  90872. /**
  90873. * Material Normal Texture Info
  90874. */
  90875. interface IMaterialNormalTextureInfo extends ITextureInfo {
  90876. /**
  90877. * The scalar multiplier applied to each normal vector of the normal texture
  90878. */
  90879. scale?: number;
  90880. }
  90881. /**
  90882. * Material Occlusion Texture Info
  90883. */
  90884. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  90885. /**
  90886. * A scalar multiplier controlling the amount of occlusion applied
  90887. */
  90888. strength?: number;
  90889. }
  90890. /**
  90891. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  90892. */
  90893. interface IMaterialPbrMetallicRoughness {
  90894. /**
  90895. * The material's base color factor
  90896. */
  90897. baseColorFactor?: number[];
  90898. /**
  90899. * The base color texture
  90900. */
  90901. baseColorTexture?: ITextureInfo;
  90902. /**
  90903. * The metalness of the material
  90904. */
  90905. metallicFactor?: number;
  90906. /**
  90907. * The roughness of the material
  90908. */
  90909. roughnessFactor?: number;
  90910. /**
  90911. * The metallic-roughness texture
  90912. */
  90913. metallicRoughnessTexture?: ITextureInfo;
  90914. }
  90915. /**
  90916. * The material appearance of a primitive
  90917. */
  90918. interface IMaterial extends IChildRootProperty {
  90919. /**
  90920. * 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
  90921. */
  90922. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  90923. /**
  90924. * The normal map texture
  90925. */
  90926. normalTexture?: IMaterialNormalTextureInfo;
  90927. /**
  90928. * The occlusion map texture
  90929. */
  90930. occlusionTexture?: IMaterialOcclusionTextureInfo;
  90931. /**
  90932. * The emissive map texture
  90933. */
  90934. emissiveTexture?: ITextureInfo;
  90935. /**
  90936. * 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
  90937. */
  90938. emissiveFactor?: number[];
  90939. /**
  90940. * The alpha rendering mode of the material
  90941. */
  90942. alphaMode?: MaterialAlphaMode;
  90943. /**
  90944. * The alpha cutoff value of the material
  90945. */
  90946. alphaCutoff?: number;
  90947. /**
  90948. * Specifies whether the material is double sided
  90949. */
  90950. doubleSided?: boolean;
  90951. }
  90952. /**
  90953. * Geometry to be rendered with the given material
  90954. */
  90955. interface IMeshPrimitive extends IProperty {
  90956. /**
  90957. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  90958. */
  90959. attributes: {
  90960. [name: string]: number;
  90961. };
  90962. /**
  90963. * The index of the accessor that contains the indices
  90964. */
  90965. indices?: number;
  90966. /**
  90967. * The index of the material to apply to this primitive when rendering
  90968. */
  90969. material?: number;
  90970. /**
  90971. * The type of primitives to render. All valid values correspond to WebGL enums
  90972. */
  90973. mode?: MeshPrimitiveMode;
  90974. /**
  90975. * 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
  90976. */
  90977. targets?: {
  90978. [name: string]: number;
  90979. }[];
  90980. }
  90981. /**
  90982. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  90983. */
  90984. interface IMesh extends IChildRootProperty {
  90985. /**
  90986. * An array of primitives, each defining geometry to be rendered with a material
  90987. */
  90988. primitives: IMeshPrimitive[];
  90989. /**
  90990. * Array of weights to be applied to the Morph Targets
  90991. */
  90992. weights?: number[];
  90993. }
  90994. /**
  90995. * A node in the node hierarchy
  90996. */
  90997. interface INode extends IChildRootProperty {
  90998. /**
  90999. * The index of the camera referenced by this node
  91000. */
  91001. camera?: number;
  91002. /**
  91003. * The indices of this node's children
  91004. */
  91005. children?: number[];
  91006. /**
  91007. * The index of the skin referenced by this node
  91008. */
  91009. skin?: number;
  91010. /**
  91011. * A floating-point 4x4 transformation matrix stored in column-major order
  91012. */
  91013. matrix?: number[];
  91014. /**
  91015. * The index of the mesh in this node
  91016. */
  91017. mesh?: number;
  91018. /**
  91019. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  91020. */
  91021. rotation?: number[];
  91022. /**
  91023. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  91024. */
  91025. scale?: number[];
  91026. /**
  91027. * The node's translation along the x, y, and z axes
  91028. */
  91029. translation?: number[];
  91030. /**
  91031. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  91032. */
  91033. weights?: number[];
  91034. }
  91035. /**
  91036. * Texture sampler properties for filtering and wrapping modes
  91037. */
  91038. interface ISampler extends IChildRootProperty {
  91039. /**
  91040. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91041. */
  91042. magFilter?: TextureMagFilter;
  91043. /**
  91044. * Minification filter. All valid values correspond to WebGL enums
  91045. */
  91046. minFilter?: TextureMinFilter;
  91047. /**
  91048. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91049. */
  91050. wrapS?: TextureWrapMode;
  91051. /**
  91052. * T (V) wrapping mode. All valid values correspond to WebGL enums
  91053. */
  91054. wrapT?: TextureWrapMode;
  91055. }
  91056. /**
  91057. * The root nodes of a scene
  91058. */
  91059. interface IScene extends IChildRootProperty {
  91060. /**
  91061. * The indices of each root node
  91062. */
  91063. nodes: number[];
  91064. }
  91065. /**
  91066. * Joints and matrices defining a skin
  91067. */
  91068. interface ISkin extends IChildRootProperty {
  91069. /**
  91070. * 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
  91071. */
  91072. inverseBindMatrices?: number;
  91073. /**
  91074. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  91075. */
  91076. skeleton?: number;
  91077. /**
  91078. * 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)
  91079. */
  91080. joints: number[];
  91081. }
  91082. /**
  91083. * A texture and its sampler
  91084. */
  91085. interface ITexture extends IChildRootProperty {
  91086. /**
  91087. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  91088. */
  91089. sampler?: number;
  91090. /**
  91091. * The index of the image used by this texture
  91092. */
  91093. source: number;
  91094. }
  91095. /**
  91096. * Reference to a texture
  91097. */
  91098. interface ITextureInfo extends IProperty {
  91099. /**
  91100. * The index of the texture
  91101. */
  91102. index: number;
  91103. /**
  91104. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  91105. */
  91106. texCoord?: number;
  91107. }
  91108. /**
  91109. * The root object for a glTF asset
  91110. */
  91111. interface IGLTF extends IProperty {
  91112. /**
  91113. * An array of accessors. An accessor is a typed view into a bufferView
  91114. */
  91115. accessors?: IAccessor[];
  91116. /**
  91117. * An array of keyframe animations
  91118. */
  91119. animations?: IAnimation[];
  91120. /**
  91121. * Metadata about the glTF asset
  91122. */
  91123. asset: IAsset;
  91124. /**
  91125. * An array of buffers. A buffer points to binary geometry, animation, or skins
  91126. */
  91127. buffers?: IBuffer[];
  91128. /**
  91129. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  91130. */
  91131. bufferViews?: IBufferView[];
  91132. /**
  91133. * An array of cameras
  91134. */
  91135. cameras?: ICamera[];
  91136. /**
  91137. * Names of glTF extensions used somewhere in this asset
  91138. */
  91139. extensionsUsed?: string[];
  91140. /**
  91141. * Names of glTF extensions required to properly load this asset
  91142. */
  91143. extensionsRequired?: string[];
  91144. /**
  91145. * An array of images. An image defines data used to create a texture
  91146. */
  91147. images?: IImage[];
  91148. /**
  91149. * An array of materials. A material defines the appearance of a primitive
  91150. */
  91151. materials?: IMaterial[];
  91152. /**
  91153. * An array of meshes. A mesh is a set of primitives to be rendered
  91154. */
  91155. meshes?: IMesh[];
  91156. /**
  91157. * An array of nodes
  91158. */
  91159. nodes?: INode[];
  91160. /**
  91161. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  91162. */
  91163. samplers?: ISampler[];
  91164. /**
  91165. * The index of the default scene
  91166. */
  91167. scene?: number;
  91168. /**
  91169. * An array of scenes
  91170. */
  91171. scenes?: IScene[];
  91172. /**
  91173. * An array of skins. A skin is defined by joints and matrices
  91174. */
  91175. skins?: ISkin[];
  91176. /**
  91177. * An array of textures
  91178. */
  91179. textures?: ITexture[];
  91180. }
  91181. /**
  91182. * The glTF validation results
  91183. * @ignore
  91184. */
  91185. interface IGLTFValidationResults {
  91186. info: {
  91187. generator: string;
  91188. hasAnimations: boolean;
  91189. hasDefaultScene: boolean;
  91190. hasMaterials: boolean;
  91191. hasMorphTargets: boolean;
  91192. hasSkins: boolean;
  91193. hasTextures: boolean;
  91194. maxAttributesUsed: number;
  91195. primitivesCount: number
  91196. };
  91197. issues: {
  91198. messages: Array<string>;
  91199. numErrors: number;
  91200. numHints: number;
  91201. numInfos: number;
  91202. numWarnings: number;
  91203. truncated: boolean
  91204. };
  91205. mimeType: string;
  91206. uri: string;
  91207. validatedAt: string;
  91208. validatorVersion: string;
  91209. }
  91210. /**
  91211. * The glTF validation options
  91212. */
  91213. interface IGLTFValidationOptions {
  91214. /** Uri to use */
  91215. uri?: string;
  91216. /** Function used to load external resources */
  91217. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  91218. /** Boolean indicating that we need to validate accessor data */
  91219. validateAccessorData?: boolean;
  91220. /** max number of issues allowed */
  91221. maxIssues?: number;
  91222. /** Ignored issues */
  91223. ignoredIssues?: Array<string>;
  91224. /** Value to override severy settings */
  91225. severityOverrides?: Object;
  91226. }
  91227. /**
  91228. * The glTF validator object
  91229. * @ignore
  91230. */
  91231. interface IGLTFValidator {
  91232. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91233. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91234. }
  91235. /**
  91236. * Interfaces from the EXT_lights_image_based extension
  91237. */
  91238. /** @hidden */
  91239. interface IEXTLightsImageBased_LightReferenceImageBased {
  91240. light: number;
  91241. }
  91242. /** @hidden */
  91243. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91244. intensity: number;
  91245. rotation: number[];
  91246. specularImageSize: number;
  91247. specularImages: number[][];
  91248. irradianceCoefficients: number[][];
  91249. }
  91250. /** @hidden */
  91251. interface IEXTLightsImageBased {
  91252. lights: IEXTLightsImageBased_LightImageBased[];
  91253. }
  91254. /**
  91255. * Interfaces from the EXT_mesh_gpu_instancing extension
  91256. * !!! Experimental Extension Subject to Changes !!!
  91257. */
  91258. /** @hidden */
  91259. interface IEXTMeshGpuInstancing {
  91260. mesh?: number;
  91261. attributes: { [name: string]: number };
  91262. }
  91263. /**
  91264. * Interfaces from the KHR_draco_mesh_compression extension
  91265. */
  91266. /** @hidden */
  91267. interface IKHRDracoMeshCompression {
  91268. bufferView: number;
  91269. attributes: { [name: string]: number };
  91270. }
  91271. /**
  91272. * Interfaces from the KHR_lights_punctual extension
  91273. */
  91274. /** @hidden */
  91275. const enum IKHRLightsPunctual_LightType {
  91276. DIRECTIONAL = "directional",
  91277. POINT = "point",
  91278. SPOT = "spot"
  91279. }
  91280. /** @hidden */
  91281. interface IKHRLightsPunctual_LightReference {
  91282. light: number;
  91283. }
  91284. /** @hidden */
  91285. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91286. type: IKHRLightsPunctual_LightType;
  91287. color?: number[];
  91288. intensity?: number;
  91289. range?: number;
  91290. spot?: {
  91291. innerConeAngle?: number;
  91292. outerConeAngle?: number;
  91293. };
  91294. }
  91295. /** @hidden */
  91296. interface IKHRLightsPunctual {
  91297. lights: IKHRLightsPunctual_Light[];
  91298. }
  91299. /**
  91300. * Interfaces from the KHR_materials_clearcoat extension
  91301. * !!! Experimental Extension Subject to Changes !!!
  91302. */
  91303. /** @hidden */
  91304. interface IKHRMaterialsClearcoat {
  91305. clearcoatFactor: number;
  91306. clearcoatTexture: ITextureInfo;
  91307. clearcoatRoughnessFactor: number;
  91308. clearcoatRoughnessTexture: ITextureInfo;
  91309. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91310. }
  91311. /**
  91312. * Interfaces from the KHR_materials_ior extension
  91313. * !!! Experimental Extension Subject to Changes !!!
  91314. */
  91315. /** @hidden */
  91316. interface IKHRMaterialsIor {
  91317. ior: number;
  91318. }
  91319. /**
  91320. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91321. */
  91322. /** @hidden */
  91323. interface IKHRMaterialsPbrSpecularGlossiness {
  91324. diffuseFactor: number[];
  91325. diffuseTexture: ITextureInfo;
  91326. specularFactor: number[];
  91327. glossinessFactor: number;
  91328. specularGlossinessTexture: ITextureInfo;
  91329. }
  91330. /**
  91331. * Interfaces from the KHR_materials_sheen extension
  91332. * !!! Experimental Extension Subject to Changes !!!
  91333. */
  91334. /** @hidden */
  91335. interface IKHRMaterialsSheen {
  91336. sheenColorFactor?: number[];
  91337. sheenColorTexture?: ITextureInfo;
  91338. sheenRoughnessFactor?: number;
  91339. sheenRoughnessTexture?: ITextureInfo;
  91340. }
  91341. /**
  91342. * Interfaces from the KHR_materials_specular extension
  91343. * !!! Experimental Extension Subject to Changes !!!
  91344. */
  91345. /** @hidden */
  91346. interface IKHRMaterialsSpecular {
  91347. specularFactor: number;
  91348. specularColorFactor: number[];
  91349. specularTexture: ITextureInfo;
  91350. }
  91351. /**
  91352. * Interfaces from the KHR_materials_transmission extension
  91353. * !!! Experimental Extension Subject to Changes !!!
  91354. */
  91355. /** @hidden */
  91356. interface IKHRMaterialsTransmission {
  91357. transmissionFactor?: number;
  91358. transmissionTexture?: ITextureInfo;
  91359. }
  91360. /**
  91361. * Interfaces from the KHR_materials_translucency extension
  91362. * !!! Experimental Extension Subject to Changes !!!
  91363. */
  91364. /** @hidden */
  91365. interface IKHRMaterialsTranslucency {
  91366. translucencyFactor?: number;
  91367. translucencyTexture?: ITextureInfo;
  91368. }
  91369. /**
  91370. * Interfaces from the KHR_materials_variants extension
  91371. * !!! Experimental Extension Subject to Changes !!!
  91372. */
  91373. /** @hidden */
  91374. interface IKHRMaterialVariants_Mapping extends IProperty {
  91375. mappings: Array<{
  91376. variants: number[];
  91377. material: number;
  91378. }>;
  91379. }
  91380. /** @hidden */
  91381. interface IKHRMaterialVariants_Variant extends IProperty {
  91382. name: string;
  91383. }
  91384. /** @hidden */
  91385. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91386. variants: Array<IKHRMaterialVariants_Variant>;
  91387. }
  91388. /**
  91389. * Interfaces from the KHR_texture_basisu extension
  91390. * !!! Experimental Extension Subject to Changes !!!
  91391. */
  91392. /** @hidden */
  91393. interface IKHRTextureBasisU {
  91394. source: number;
  91395. }
  91396. /**
  91397. * Interfaces from the EXT_texture_webp extension
  91398. */
  91399. /** @hidden */
  91400. interface IEXTTextureWebP {
  91401. source: number;
  91402. }
  91403. /**
  91404. * Interfaces from the KHR_texture_transform extension
  91405. */
  91406. /** @hidden */
  91407. interface IKHRTextureTransform {
  91408. offset?: number[];
  91409. rotation?: number;
  91410. scale?: number[];
  91411. texCoord?: number;
  91412. }
  91413. /**
  91414. * Interfaces from the KHR_xmp_json_ld extension
  91415. * !!! Experimental Extension Subject to Changes !!!
  91416. */
  91417. /** @hidden */
  91418. interface IKHRXmpJsonLd_Gltf {
  91419. packets: Array<{
  91420. [key: string]: unknown;
  91421. }>;
  91422. }
  91423. /** @hidden */
  91424. interface IKHRXmpJsonLd_Node {
  91425. packet: number;
  91426. }
  91427. /**
  91428. * Interfaces from the MSFT_audio_emitter extension
  91429. */
  91430. /** @hidden */
  91431. interface IMSFTAudioEmitter_ClipReference {
  91432. clip: number;
  91433. weight?: number;
  91434. }
  91435. /** @hidden */
  91436. interface IMSFTAudioEmitter_EmittersReference {
  91437. emitters: number[];
  91438. }
  91439. /** @hidden */
  91440. const enum IMSFTAudioEmitter_DistanceModel {
  91441. linear = "linear",
  91442. inverse = "inverse",
  91443. exponential = "exponential",
  91444. }
  91445. /** @hidden */
  91446. interface IMSFTAudioEmitter_Emitter {
  91447. name?: string;
  91448. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91449. refDistance?: number;
  91450. maxDistance?: number;
  91451. rolloffFactor?: number;
  91452. innerAngle?: number;
  91453. outerAngle?: number;
  91454. loop?: boolean;
  91455. volume?: number;
  91456. clips: IMSFTAudioEmitter_ClipReference[];
  91457. }
  91458. /** @hidden */
  91459. const enum IMSFTAudioEmitter_AudioMimeType {
  91460. WAV = "audio/wav",
  91461. }
  91462. /** @hidden */
  91463. interface IMSFTAudioEmitter_Clip extends IProperty {
  91464. uri?: string;
  91465. bufferView?: number;
  91466. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91467. }
  91468. /** @hidden */
  91469. const enum IMSFTAudioEmitter_AnimationEventAction {
  91470. play = "play",
  91471. pause = "pause",
  91472. stop = "stop",
  91473. }
  91474. /** @hidden */
  91475. interface IMSFTAudioEmitter_AnimationEvent {
  91476. action: IMSFTAudioEmitter_AnimationEventAction;
  91477. emitter: number;
  91478. time: number;
  91479. startOffset?: number;
  91480. }
  91481. /**
  91482. * Interfaces from the MSFT_lod extension
  91483. */
  91484. /** @hidden */
  91485. interface IMSFTLOD {
  91486. ids: number[];
  91487. }
  91488. /**
  91489. * Interfaces from the EXT_meshopt_compression extension
  91490. */
  91491. /** @hidden */
  91492. interface IEXTMeshoptCompression {
  91493. buffer: number;
  91494. byteOffset?: number;
  91495. byteLength: number;
  91496. byteStride: number;
  91497. count: number;
  91498. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91499. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91500. }
  91501. }
  91502. declare module BABYLON {
  91503. /** @hidden */
  91504. export var cellPixelShader: {
  91505. name: string;
  91506. shader: string;
  91507. };
  91508. }
  91509. declare module BABYLON {
  91510. /** @hidden */
  91511. export var cellVertexShader: {
  91512. name: string;
  91513. shader: string;
  91514. };
  91515. }
  91516. declare module BABYLON {
  91517. export class CellMaterial extends BABYLON.PushMaterial {
  91518. private _diffuseTexture;
  91519. diffuseTexture: BABYLON.BaseTexture;
  91520. diffuseColor: BABYLON.Color3;
  91521. _computeHighLevel: boolean;
  91522. computeHighLevel: boolean;
  91523. private _disableLighting;
  91524. disableLighting: boolean;
  91525. private _maxSimultaneousLights;
  91526. maxSimultaneousLights: number;
  91527. constructor(name: string, scene: BABYLON.Scene);
  91528. needAlphaBlending(): boolean;
  91529. needAlphaTesting(): boolean;
  91530. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91531. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91532. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91533. getAnimatables(): BABYLON.IAnimatable[];
  91534. getActiveTextures(): BABYLON.BaseTexture[];
  91535. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91536. dispose(forceDisposeEffect?: boolean): void;
  91537. getClassName(): string;
  91538. clone(name: string): CellMaterial;
  91539. serialize(): any;
  91540. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  91541. }
  91542. }
  91543. declare module BABYLON {
  91544. export class CustomShaderStructure {
  91545. FragmentStore: string;
  91546. VertexStore: string;
  91547. constructor();
  91548. }
  91549. export class ShaderSpecialParts {
  91550. constructor();
  91551. Fragment_Begin: string;
  91552. Fragment_Definitions: string;
  91553. Fragment_MainBegin: string;
  91554. Fragment_Custom_Diffuse: string;
  91555. Fragment_Before_Lights: string;
  91556. Fragment_Before_Fog: string;
  91557. Fragment_Custom_Alpha: string;
  91558. Fragment_Before_FragColor: string;
  91559. Vertex_Begin: string;
  91560. Vertex_Definitions: string;
  91561. Vertex_MainBegin: string;
  91562. Vertex_Before_PositionUpdated: string;
  91563. Vertex_Before_NormalUpdated: string;
  91564. Vertex_After_WorldPosComputed: string;
  91565. Vertex_MainEnd: string;
  91566. }
  91567. export class CustomMaterial extends BABYLON.StandardMaterial {
  91568. static ShaderIndexer: number;
  91569. CustomParts: ShaderSpecialParts;
  91570. _isCreatedShader: boolean;
  91571. _createdShaderName: string;
  91572. _customUniform: string[];
  91573. _newUniforms: string[];
  91574. _newUniformInstances: {
  91575. [name: string]: any;
  91576. };
  91577. _newSamplerInstances: {
  91578. [name: string]: BABYLON.Texture;
  91579. };
  91580. _customAttributes: string[];
  91581. FragmentShader: string;
  91582. VertexShader: string;
  91583. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91584. ReviewUniform(name: string, arr: string[]): string[];
  91585. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91586. constructor(name: string, scene: BABYLON.Scene);
  91587. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  91588. AddAttribute(name: string): CustomMaterial;
  91589. Fragment_Begin(shaderPart: string): CustomMaterial;
  91590. Fragment_Definitions(shaderPart: string): CustomMaterial;
  91591. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  91592. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  91593. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  91594. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  91595. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  91596. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  91597. Vertex_Begin(shaderPart: string): CustomMaterial;
  91598. Vertex_Definitions(shaderPart: string): CustomMaterial;
  91599. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  91600. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  91601. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  91602. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  91603. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  91604. }
  91605. }
  91606. declare module BABYLON {
  91607. export class ShaderAlebdoParts {
  91608. constructor();
  91609. Fragment_Begin: string;
  91610. Fragment_Definitions: string;
  91611. Fragment_MainBegin: string;
  91612. Fragment_Custom_Albedo: string;
  91613. Fragment_Before_Lights: string;
  91614. Fragment_Custom_MetallicRoughness: string;
  91615. Fragment_Custom_MicroSurface: string;
  91616. Fragment_Before_Fog: string;
  91617. Fragment_Custom_Alpha: string;
  91618. Fragment_Before_FragColor: string;
  91619. Vertex_Begin: string;
  91620. Vertex_Definitions: string;
  91621. Vertex_MainBegin: string;
  91622. Vertex_Before_PositionUpdated: string;
  91623. Vertex_Before_NormalUpdated: string;
  91624. Vertex_After_WorldPosComputed: string;
  91625. Vertex_MainEnd: string;
  91626. }
  91627. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  91628. static ShaderIndexer: number;
  91629. CustomParts: ShaderAlebdoParts;
  91630. _isCreatedShader: boolean;
  91631. _createdShaderName: string;
  91632. _customUniform: string[];
  91633. _newUniforms: string[];
  91634. _newUniformInstances: {
  91635. [name: string]: any;
  91636. };
  91637. _newSamplerInstances: {
  91638. [name: string]: BABYLON.Texture;
  91639. };
  91640. _customAttributes: string[];
  91641. FragmentShader: string;
  91642. VertexShader: string;
  91643. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91644. ReviewUniform(name: string, arr: string[]): string[];
  91645. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91646. constructor(name: string, scene: BABYLON.Scene);
  91647. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  91648. AddAttribute(name: string): PBRCustomMaterial;
  91649. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  91650. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  91651. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  91652. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  91653. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  91654. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  91655. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  91656. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  91657. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  91658. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  91659. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  91660. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  91661. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  91662. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  91663. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  91664. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  91665. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  91666. }
  91667. }
  91668. declare module BABYLON {
  91669. /** @hidden */
  91670. export var firePixelShader: {
  91671. name: string;
  91672. shader: string;
  91673. };
  91674. }
  91675. declare module BABYLON {
  91676. /** @hidden */
  91677. export var fireVertexShader: {
  91678. name: string;
  91679. shader: string;
  91680. };
  91681. }
  91682. declare module BABYLON {
  91683. export class FireMaterial extends BABYLON.PushMaterial {
  91684. private _diffuseTexture;
  91685. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91686. private _distortionTexture;
  91687. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91688. private _opacityTexture;
  91689. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91690. diffuseColor: BABYLON.Color3;
  91691. speed: number;
  91692. private _scaledDiffuse;
  91693. private _lastTime;
  91694. constructor(name: string, scene: BABYLON.Scene);
  91695. needAlphaBlending(): boolean;
  91696. needAlphaTesting(): boolean;
  91697. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91698. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91699. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91700. getAnimatables(): BABYLON.IAnimatable[];
  91701. getActiveTextures(): BABYLON.BaseTexture[];
  91702. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91703. getClassName(): string;
  91704. dispose(forceDisposeEffect?: boolean): void;
  91705. clone(name: string): FireMaterial;
  91706. serialize(): any;
  91707. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  91708. }
  91709. }
  91710. declare module BABYLON {
  91711. /** @hidden */
  91712. export var furPixelShader: {
  91713. name: string;
  91714. shader: string;
  91715. };
  91716. }
  91717. declare module BABYLON {
  91718. /** @hidden */
  91719. export var furVertexShader: {
  91720. name: string;
  91721. shader: string;
  91722. };
  91723. }
  91724. declare module BABYLON {
  91725. export class FurMaterial extends BABYLON.PushMaterial {
  91726. private _diffuseTexture;
  91727. diffuseTexture: BABYLON.BaseTexture;
  91728. private _heightTexture;
  91729. heightTexture: BABYLON.BaseTexture;
  91730. diffuseColor: BABYLON.Color3;
  91731. furLength: number;
  91732. furAngle: number;
  91733. furColor: BABYLON.Color3;
  91734. furOffset: number;
  91735. furSpacing: number;
  91736. furGravity: BABYLON.Vector3;
  91737. furSpeed: number;
  91738. furDensity: number;
  91739. furOcclusion: number;
  91740. furTexture: BABYLON.DynamicTexture;
  91741. private _disableLighting;
  91742. disableLighting: boolean;
  91743. private _maxSimultaneousLights;
  91744. maxSimultaneousLights: number;
  91745. highLevelFur: boolean;
  91746. _meshes: BABYLON.AbstractMesh[];
  91747. private _furTime;
  91748. constructor(name: string, scene: BABYLON.Scene);
  91749. get furTime(): number;
  91750. set furTime(furTime: number);
  91751. needAlphaBlending(): boolean;
  91752. needAlphaTesting(): boolean;
  91753. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91754. updateFur(): void;
  91755. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91756. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91757. getAnimatables(): BABYLON.IAnimatable[];
  91758. getActiveTextures(): BABYLON.BaseTexture[];
  91759. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91760. dispose(forceDisposeEffect?: boolean): void;
  91761. clone(name: string): FurMaterial;
  91762. serialize(): any;
  91763. getClassName(): string;
  91764. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  91765. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  91766. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  91767. }
  91768. }
  91769. declare module BABYLON {
  91770. /** @hidden */
  91771. export var gradientPixelShader: {
  91772. name: string;
  91773. shader: string;
  91774. };
  91775. }
  91776. declare module BABYLON {
  91777. /** @hidden */
  91778. export var gradientVertexShader: {
  91779. name: string;
  91780. shader: string;
  91781. };
  91782. }
  91783. declare module BABYLON {
  91784. export class GradientMaterial extends BABYLON.PushMaterial {
  91785. private _maxSimultaneousLights;
  91786. maxSimultaneousLights: number;
  91787. topColor: BABYLON.Color3;
  91788. topColorAlpha: number;
  91789. bottomColor: BABYLON.Color3;
  91790. bottomColorAlpha: number;
  91791. offset: number;
  91792. scale: number;
  91793. smoothness: number;
  91794. private _disableLighting;
  91795. disableLighting: boolean;
  91796. constructor(name: string, scene: BABYLON.Scene);
  91797. needAlphaBlending(): boolean;
  91798. needAlphaTesting(): boolean;
  91799. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91800. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91801. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91802. getAnimatables(): BABYLON.IAnimatable[];
  91803. dispose(forceDisposeEffect?: boolean): void;
  91804. clone(name: string): GradientMaterial;
  91805. serialize(): any;
  91806. getClassName(): string;
  91807. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  91808. }
  91809. }
  91810. declare module BABYLON {
  91811. /** @hidden */
  91812. export var gridPixelShader: {
  91813. name: string;
  91814. shader: string;
  91815. };
  91816. }
  91817. declare module BABYLON {
  91818. /** @hidden */
  91819. export var gridVertexShader: {
  91820. name: string;
  91821. shader: string;
  91822. };
  91823. }
  91824. declare module BABYLON {
  91825. /**
  91826. * The grid materials allows you to wrap any shape with a grid.
  91827. * Colors are customizable.
  91828. */
  91829. export class GridMaterial extends BABYLON.PushMaterial {
  91830. /**
  91831. * Main color of the grid (e.g. between lines)
  91832. */
  91833. mainColor: BABYLON.Color3;
  91834. /**
  91835. * Color of the grid lines.
  91836. */
  91837. lineColor: BABYLON.Color3;
  91838. /**
  91839. * The scale of the grid compared to unit.
  91840. */
  91841. gridRatio: number;
  91842. /**
  91843. * Allows setting an offset for the grid lines.
  91844. */
  91845. gridOffset: BABYLON.Vector3;
  91846. /**
  91847. * The frequency of thicker lines.
  91848. */
  91849. majorUnitFrequency: number;
  91850. /**
  91851. * The visibility of minor units in the grid.
  91852. */
  91853. minorUnitVisibility: number;
  91854. /**
  91855. * The grid opacity outside of the lines.
  91856. */
  91857. opacity: number;
  91858. /**
  91859. * Determine RBG output is premultiplied by alpha value.
  91860. */
  91861. preMultiplyAlpha: boolean;
  91862. private _opacityTexture;
  91863. opacityTexture: BABYLON.BaseTexture;
  91864. private _gridControl;
  91865. /**
  91866. * constructor
  91867. * @param name The name given to the material in order to identify it afterwards.
  91868. * @param scene The scene the material is used in.
  91869. */
  91870. constructor(name: string, scene: BABYLON.Scene);
  91871. /**
  91872. * Returns wehter or not the grid requires alpha blending.
  91873. */
  91874. needAlphaBlending(): boolean;
  91875. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91876. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91877. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91878. /**
  91879. * Dispose the material and its associated resources.
  91880. * @param forceDisposeEffect will also dispose the used effect when true
  91881. */
  91882. dispose(forceDisposeEffect?: boolean): void;
  91883. clone(name: string): GridMaterial;
  91884. serialize(): any;
  91885. getClassName(): string;
  91886. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  91887. }
  91888. }
  91889. declare module BABYLON {
  91890. /** @hidden */
  91891. export var lavaPixelShader: {
  91892. name: string;
  91893. shader: string;
  91894. };
  91895. }
  91896. declare module BABYLON {
  91897. /** @hidden */
  91898. export var lavaVertexShader: {
  91899. name: string;
  91900. shader: string;
  91901. };
  91902. }
  91903. declare module BABYLON {
  91904. export class LavaMaterial extends BABYLON.PushMaterial {
  91905. private _diffuseTexture;
  91906. diffuseTexture: BABYLON.BaseTexture;
  91907. noiseTexture: BABYLON.BaseTexture;
  91908. fogColor: BABYLON.Color3;
  91909. speed: number;
  91910. movingSpeed: number;
  91911. lowFrequencySpeed: number;
  91912. fogDensity: number;
  91913. private _lastTime;
  91914. diffuseColor: BABYLON.Color3;
  91915. private _disableLighting;
  91916. disableLighting: boolean;
  91917. private _unlit;
  91918. unlit: boolean;
  91919. private _maxSimultaneousLights;
  91920. maxSimultaneousLights: number;
  91921. private _scaledDiffuse;
  91922. constructor(name: string, scene: BABYLON.Scene);
  91923. needAlphaBlending(): boolean;
  91924. needAlphaTesting(): boolean;
  91925. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91926. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91927. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91928. getAnimatables(): BABYLON.IAnimatable[];
  91929. getActiveTextures(): BABYLON.BaseTexture[];
  91930. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91931. dispose(forceDisposeEffect?: boolean): void;
  91932. clone(name: string): LavaMaterial;
  91933. serialize(): any;
  91934. getClassName(): string;
  91935. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  91936. }
  91937. }
  91938. declare module BABYLON {
  91939. /** @hidden */
  91940. export var mixPixelShader: {
  91941. name: string;
  91942. shader: string;
  91943. };
  91944. }
  91945. declare module BABYLON {
  91946. /** @hidden */
  91947. export var mixVertexShader: {
  91948. name: string;
  91949. shader: string;
  91950. };
  91951. }
  91952. declare module BABYLON {
  91953. export class MixMaterial extends BABYLON.PushMaterial {
  91954. /**
  91955. * Mix textures
  91956. */
  91957. private _mixTexture1;
  91958. mixTexture1: BABYLON.BaseTexture;
  91959. private _mixTexture2;
  91960. mixTexture2: BABYLON.BaseTexture;
  91961. /**
  91962. * Diffuse textures
  91963. */
  91964. private _diffuseTexture1;
  91965. diffuseTexture1: BABYLON.Texture;
  91966. private _diffuseTexture2;
  91967. diffuseTexture2: BABYLON.Texture;
  91968. private _diffuseTexture3;
  91969. diffuseTexture3: BABYLON.Texture;
  91970. private _diffuseTexture4;
  91971. diffuseTexture4: BABYLON.Texture;
  91972. private _diffuseTexture5;
  91973. diffuseTexture5: BABYLON.Texture;
  91974. private _diffuseTexture6;
  91975. diffuseTexture6: BABYLON.Texture;
  91976. private _diffuseTexture7;
  91977. diffuseTexture7: BABYLON.Texture;
  91978. private _diffuseTexture8;
  91979. diffuseTexture8: BABYLON.Texture;
  91980. /**
  91981. * Uniforms
  91982. */
  91983. diffuseColor: BABYLON.Color3;
  91984. specularColor: BABYLON.Color3;
  91985. specularPower: number;
  91986. private _disableLighting;
  91987. disableLighting: boolean;
  91988. private _maxSimultaneousLights;
  91989. maxSimultaneousLights: number;
  91990. constructor(name: string, scene: BABYLON.Scene);
  91991. needAlphaBlending(): boolean;
  91992. needAlphaTesting(): boolean;
  91993. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91994. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91995. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91996. getAnimatables(): BABYLON.IAnimatable[];
  91997. getActiveTextures(): BABYLON.BaseTexture[];
  91998. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91999. dispose(forceDisposeEffect?: boolean): void;
  92000. clone(name: string): MixMaterial;
  92001. serialize(): any;
  92002. getClassName(): string;
  92003. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  92004. }
  92005. }
  92006. declare module BABYLON {
  92007. /** @hidden */
  92008. export var normalPixelShader: {
  92009. name: string;
  92010. shader: string;
  92011. };
  92012. }
  92013. declare module BABYLON {
  92014. /** @hidden */
  92015. export var normalVertexShader: {
  92016. name: string;
  92017. shader: string;
  92018. };
  92019. }
  92020. declare module BABYLON {
  92021. export class NormalMaterial extends BABYLON.PushMaterial {
  92022. private _diffuseTexture;
  92023. diffuseTexture: BABYLON.BaseTexture;
  92024. diffuseColor: BABYLON.Color3;
  92025. private _disableLighting;
  92026. disableLighting: boolean;
  92027. private _maxSimultaneousLights;
  92028. maxSimultaneousLights: number;
  92029. constructor(name: string, scene: BABYLON.Scene);
  92030. needAlphaBlending(): boolean;
  92031. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92032. needAlphaTesting(): boolean;
  92033. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92034. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92035. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92036. getAnimatables(): BABYLON.IAnimatable[];
  92037. getActiveTextures(): BABYLON.BaseTexture[];
  92038. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92039. dispose(forceDisposeEffect?: boolean): void;
  92040. clone(name: string): NormalMaterial;
  92041. serialize(): any;
  92042. getClassName(): string;
  92043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  92044. }
  92045. }
  92046. declare module BABYLON {
  92047. /** @hidden */
  92048. export var shadowOnlyPixelShader: {
  92049. name: string;
  92050. shader: string;
  92051. };
  92052. }
  92053. declare module BABYLON {
  92054. /** @hidden */
  92055. export var shadowOnlyVertexShader: {
  92056. name: string;
  92057. shader: string;
  92058. };
  92059. }
  92060. declare module BABYLON {
  92061. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  92062. private _activeLight;
  92063. private _needAlphaBlending;
  92064. constructor(name: string, scene: BABYLON.Scene);
  92065. shadowColor: BABYLON.Color3;
  92066. needAlphaBlending(): boolean;
  92067. needAlphaTesting(): boolean;
  92068. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92069. get activeLight(): BABYLON.IShadowLight;
  92070. set activeLight(light: BABYLON.IShadowLight);
  92071. private _getFirstShadowLightForMesh;
  92072. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92073. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92074. clone(name: string): ShadowOnlyMaterial;
  92075. serialize(): any;
  92076. getClassName(): string;
  92077. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  92078. }
  92079. }
  92080. declare module BABYLON {
  92081. /** @hidden */
  92082. export var simplePixelShader: {
  92083. name: string;
  92084. shader: string;
  92085. };
  92086. }
  92087. declare module BABYLON {
  92088. /** @hidden */
  92089. export var simpleVertexShader: {
  92090. name: string;
  92091. shader: string;
  92092. };
  92093. }
  92094. declare module BABYLON {
  92095. export class SimpleMaterial extends BABYLON.PushMaterial {
  92096. private _diffuseTexture;
  92097. diffuseTexture: BABYLON.BaseTexture;
  92098. diffuseColor: BABYLON.Color3;
  92099. private _disableLighting;
  92100. disableLighting: boolean;
  92101. private _maxSimultaneousLights;
  92102. maxSimultaneousLights: number;
  92103. constructor(name: string, scene: BABYLON.Scene);
  92104. needAlphaBlending(): boolean;
  92105. needAlphaTesting(): boolean;
  92106. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92107. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92108. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92109. getAnimatables(): BABYLON.IAnimatable[];
  92110. getActiveTextures(): BABYLON.BaseTexture[];
  92111. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92112. dispose(forceDisposeEffect?: boolean): void;
  92113. clone(name: string): SimpleMaterial;
  92114. serialize(): any;
  92115. getClassName(): string;
  92116. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  92117. }
  92118. }
  92119. declare module BABYLON {
  92120. /** @hidden */
  92121. export var skyPixelShader: {
  92122. name: string;
  92123. shader: string;
  92124. };
  92125. }
  92126. declare module BABYLON {
  92127. /** @hidden */
  92128. export var skyVertexShader: {
  92129. name: string;
  92130. shader: string;
  92131. };
  92132. }
  92133. declare module BABYLON {
  92134. /**
  92135. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  92136. * @see https://doc.babylonjs.com/extensions/sky
  92137. */
  92138. export class SkyMaterial extends BABYLON.PushMaterial {
  92139. /**
  92140. * Defines the overall luminance of sky in interval ]0, 1[.
  92141. */
  92142. luminance: number;
  92143. /**
  92144. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  92145. */
  92146. turbidity: number;
  92147. /**
  92148. * Defines the sky appearance (light intensity).
  92149. */
  92150. rayleigh: number;
  92151. /**
  92152. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  92153. */
  92154. mieCoefficient: number;
  92155. /**
  92156. * Defines the amount of haze particles following the Mie scattering theory.
  92157. */
  92158. mieDirectionalG: number;
  92159. /**
  92160. * Defines the distance of the sun according to the active scene camera.
  92161. */
  92162. distance: number;
  92163. /**
  92164. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  92165. * "inclined".
  92166. */
  92167. inclination: number;
  92168. /**
  92169. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  92170. * an object direction and a reference direction.
  92171. */
  92172. azimuth: number;
  92173. /**
  92174. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  92175. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  92176. */
  92177. sunPosition: BABYLON.Vector3;
  92178. /**
  92179. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  92180. * .sunPosition property.
  92181. */
  92182. useSunPosition: boolean;
  92183. /**
  92184. * Defines an offset vector used to get a horizon offset.
  92185. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  92186. */
  92187. cameraOffset: BABYLON.Vector3;
  92188. /**
  92189. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  92190. */
  92191. up: BABYLON.Vector3;
  92192. private _cameraPosition;
  92193. private _skyOrientation;
  92194. /**
  92195. * Instantiates a new sky material.
  92196. * This material allows to create dynamic and texture free
  92197. * effects for skyboxes by taking care of the atmosphere state.
  92198. * @see https://doc.babylonjs.com/extensions/sky
  92199. * @param name Define the name of the material in the scene
  92200. * @param scene Define the scene the material belong to
  92201. */
  92202. constructor(name: string, scene: BABYLON.Scene);
  92203. /**
  92204. * Specifies if the material will require alpha blending
  92205. * @returns a boolean specifying if alpha blending is needed
  92206. */
  92207. needAlphaBlending(): boolean;
  92208. /**
  92209. * Specifies if this material should be rendered in alpha test mode
  92210. * @returns false as the sky material doesn't need alpha testing.
  92211. */
  92212. needAlphaTesting(): boolean;
  92213. /**
  92214. * Get the texture used for alpha test purpose.
  92215. * @returns null as the sky material has no texture.
  92216. */
  92217. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92218. /**
  92219. * Get if the submesh is ready to be used and all its information available.
  92220. * Child classes can use it to update shaders
  92221. * @param mesh defines the mesh to check
  92222. * @param subMesh defines which submesh to check
  92223. * @param useInstances specifies that instances should be used
  92224. * @returns a boolean indicating that the submesh is ready or not
  92225. */
  92226. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92227. /**
  92228. * Binds the submesh to this material by preparing the effect and shader to draw
  92229. * @param world defines the world transformation matrix
  92230. * @param mesh defines the mesh containing the submesh
  92231. * @param subMesh defines the submesh to bind the material to
  92232. */
  92233. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92234. /**
  92235. * Get the list of animatables in the material.
  92236. * @returns the list of animatables object used in the material
  92237. */
  92238. getAnimatables(): BABYLON.IAnimatable[];
  92239. /**
  92240. * Disposes the material
  92241. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92242. */
  92243. dispose(forceDisposeEffect?: boolean): void;
  92244. /**
  92245. * Makes a duplicate of the material, and gives it a new name
  92246. * @param name defines the new name for the duplicated material
  92247. * @returns the cloned material
  92248. */
  92249. clone(name: string): SkyMaterial;
  92250. /**
  92251. * Serializes this material in a JSON representation
  92252. * @returns the serialized material object
  92253. */
  92254. serialize(): any;
  92255. /**
  92256. * Gets the current class name of the material e.g. "SkyMaterial"
  92257. * Mainly use in serialization.
  92258. * @returns the class name
  92259. */
  92260. getClassName(): string;
  92261. /**
  92262. * Creates a sky material from parsed material data
  92263. * @param source defines the JSON representation of the material
  92264. * @param scene defines the hosting scene
  92265. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92266. * @returns a new sky material
  92267. */
  92268. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92269. }
  92270. }
  92271. declare module BABYLON {
  92272. /** @hidden */
  92273. export var terrainPixelShader: {
  92274. name: string;
  92275. shader: string;
  92276. };
  92277. }
  92278. declare module BABYLON {
  92279. /** @hidden */
  92280. export var terrainVertexShader: {
  92281. name: string;
  92282. shader: string;
  92283. };
  92284. }
  92285. declare module BABYLON {
  92286. export class TerrainMaterial extends BABYLON.PushMaterial {
  92287. private _mixTexture;
  92288. mixTexture: BABYLON.BaseTexture;
  92289. private _diffuseTexture1;
  92290. diffuseTexture1: BABYLON.Texture;
  92291. private _diffuseTexture2;
  92292. diffuseTexture2: BABYLON.Texture;
  92293. private _diffuseTexture3;
  92294. diffuseTexture3: BABYLON.Texture;
  92295. private _bumpTexture1;
  92296. bumpTexture1: BABYLON.Texture;
  92297. private _bumpTexture2;
  92298. bumpTexture2: BABYLON.Texture;
  92299. private _bumpTexture3;
  92300. bumpTexture3: BABYLON.Texture;
  92301. diffuseColor: BABYLON.Color3;
  92302. specularColor: BABYLON.Color3;
  92303. specularPower: number;
  92304. private _disableLighting;
  92305. disableLighting: boolean;
  92306. private _maxSimultaneousLights;
  92307. maxSimultaneousLights: number;
  92308. constructor(name: string, scene: BABYLON.Scene);
  92309. needAlphaBlending(): boolean;
  92310. needAlphaTesting(): boolean;
  92311. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92312. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92313. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92314. getAnimatables(): BABYLON.IAnimatable[];
  92315. getActiveTextures(): BABYLON.BaseTexture[];
  92316. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92317. dispose(forceDisposeEffect?: boolean): void;
  92318. clone(name: string): TerrainMaterial;
  92319. serialize(): any;
  92320. getClassName(): string;
  92321. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92322. }
  92323. }
  92324. declare module BABYLON {
  92325. /** @hidden */
  92326. export var triplanarPixelShader: {
  92327. name: string;
  92328. shader: string;
  92329. };
  92330. }
  92331. declare module BABYLON {
  92332. /** @hidden */
  92333. export var triplanarVertexShader: {
  92334. name: string;
  92335. shader: string;
  92336. };
  92337. }
  92338. declare module BABYLON {
  92339. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92340. mixTexture: BABYLON.BaseTexture;
  92341. private _diffuseTextureX;
  92342. diffuseTextureX: BABYLON.BaseTexture;
  92343. private _diffuseTextureY;
  92344. diffuseTextureY: BABYLON.BaseTexture;
  92345. private _diffuseTextureZ;
  92346. diffuseTextureZ: BABYLON.BaseTexture;
  92347. private _normalTextureX;
  92348. normalTextureX: BABYLON.BaseTexture;
  92349. private _normalTextureY;
  92350. normalTextureY: BABYLON.BaseTexture;
  92351. private _normalTextureZ;
  92352. normalTextureZ: BABYLON.BaseTexture;
  92353. tileSize: number;
  92354. diffuseColor: BABYLON.Color3;
  92355. specularColor: BABYLON.Color3;
  92356. specularPower: number;
  92357. private _disableLighting;
  92358. disableLighting: boolean;
  92359. private _maxSimultaneousLights;
  92360. maxSimultaneousLights: number;
  92361. constructor(name: string, scene: BABYLON.Scene);
  92362. needAlphaBlending(): boolean;
  92363. needAlphaTesting(): boolean;
  92364. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92365. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92366. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92367. getAnimatables(): BABYLON.IAnimatable[];
  92368. getActiveTextures(): BABYLON.BaseTexture[];
  92369. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92370. dispose(forceDisposeEffect?: boolean): void;
  92371. clone(name: string): TriPlanarMaterial;
  92372. serialize(): any;
  92373. getClassName(): string;
  92374. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92375. }
  92376. }
  92377. declare module BABYLON {
  92378. /** @hidden */
  92379. export var waterPixelShader: {
  92380. name: string;
  92381. shader: string;
  92382. };
  92383. }
  92384. declare module BABYLON {
  92385. /** @hidden */
  92386. export var waterVertexShader: {
  92387. name: string;
  92388. shader: string;
  92389. };
  92390. }
  92391. declare module BABYLON {
  92392. export class WaterMaterial extends BABYLON.PushMaterial {
  92393. renderTargetSize: BABYLON.Vector2;
  92394. private _bumpTexture;
  92395. bumpTexture: BABYLON.BaseTexture;
  92396. diffuseColor: BABYLON.Color3;
  92397. specularColor: BABYLON.Color3;
  92398. specularPower: number;
  92399. private _disableLighting;
  92400. disableLighting: boolean;
  92401. private _maxSimultaneousLights;
  92402. maxSimultaneousLights: number;
  92403. /**
  92404. * Defines the wind force.
  92405. */
  92406. windForce: number;
  92407. /**
  92408. * Defines the direction of the wind in the plane (X, Z).
  92409. */
  92410. windDirection: BABYLON.Vector2;
  92411. /**
  92412. * Defines the height of the waves.
  92413. */
  92414. waveHeight: number;
  92415. /**
  92416. * Defines the bump height related to the bump map.
  92417. */
  92418. bumpHeight: number;
  92419. /**
  92420. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92421. */
  92422. private _bumpSuperimpose;
  92423. bumpSuperimpose: boolean;
  92424. /**
  92425. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92426. */
  92427. private _fresnelSeparate;
  92428. fresnelSeparate: boolean;
  92429. /**
  92430. * Defines wether or not bump Wwves modify the reflection.
  92431. */
  92432. private _bumpAffectsReflection;
  92433. bumpAffectsReflection: boolean;
  92434. /**
  92435. * Defines the water color blended with the refraction (near).
  92436. */
  92437. waterColor: BABYLON.Color3;
  92438. /**
  92439. * Defines the blend factor related to the water color.
  92440. */
  92441. colorBlendFactor: number;
  92442. /**
  92443. * Defines the water color blended with the reflection (far).
  92444. */
  92445. waterColor2: BABYLON.Color3;
  92446. /**
  92447. * Defines the blend factor related to the water color (reflection, far).
  92448. */
  92449. colorBlendFactor2: number;
  92450. /**
  92451. * Defines the maximum length of a wave.
  92452. */
  92453. waveLength: number;
  92454. /**
  92455. * Defines the waves speed.
  92456. */
  92457. waveSpeed: number;
  92458. /**
  92459. * 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.
  92460. */
  92461. waveCount: number;
  92462. /**
  92463. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92464. * will avoid calculating useless pixels in the pixel shader of the water material.
  92465. */
  92466. disableClipPlane: boolean;
  92467. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92468. private _mesh;
  92469. private _refractionRTT;
  92470. private _reflectionRTT;
  92471. private _reflectionTransform;
  92472. private _lastTime;
  92473. private _lastDeltaTime;
  92474. private _useLogarithmicDepth;
  92475. private _waitingRenderList;
  92476. private _imageProcessingConfiguration;
  92477. private _imageProcessingObserver;
  92478. /**
  92479. * Gets a boolean indicating that current material needs to register RTT
  92480. */
  92481. get hasRenderTargetTextures(): boolean;
  92482. /**
  92483. * Constructor
  92484. */
  92485. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92486. get useLogarithmicDepth(): boolean;
  92487. set useLogarithmicDepth(value: boolean);
  92488. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92489. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92490. addToRenderList(node: any): void;
  92491. enableRenderTargets(enable: boolean): void;
  92492. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92493. get renderTargetsEnabled(): boolean;
  92494. needAlphaBlending(): boolean;
  92495. needAlphaTesting(): boolean;
  92496. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92497. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92498. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92499. private _createRenderTargets;
  92500. getAnimatables(): BABYLON.IAnimatable[];
  92501. getActiveTextures(): BABYLON.BaseTexture[];
  92502. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92503. dispose(forceDisposeEffect?: boolean): void;
  92504. clone(name: string): WaterMaterial;
  92505. serialize(): any;
  92506. getClassName(): string;
  92507. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92508. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92509. }
  92510. }
  92511. declare module BABYLON {
  92512. /** @hidden */
  92513. export var asciiartPixelShader: {
  92514. name: string;
  92515. shader: string;
  92516. };
  92517. }
  92518. declare module BABYLON {
  92519. /**
  92520. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92521. *
  92522. * It basically takes care rendering the font front the given font size to a texture.
  92523. * This is used later on in the postprocess.
  92524. */
  92525. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  92526. private _font;
  92527. private _text;
  92528. private _charSize;
  92529. /**
  92530. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92531. */
  92532. get charSize(): number;
  92533. /**
  92534. * Create a new instance of the Ascii Art FontTexture class
  92535. * @param name the name of the texture
  92536. * @param font the font to use, use the W3C CSS notation
  92537. * @param text the caracter set to use in the rendering.
  92538. * @param scene the scene that owns the texture
  92539. */
  92540. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92541. /**
  92542. * Gets the max char width of a font.
  92543. * @param font the font to use, use the W3C CSS notation
  92544. * @return the max char width
  92545. */
  92546. private getFontWidth;
  92547. /**
  92548. * Gets the max char height of a font.
  92549. * @param font the font to use, use the W3C CSS notation
  92550. * @return the max char height
  92551. */
  92552. private getFontHeight;
  92553. /**
  92554. * Clones the current AsciiArtTexture.
  92555. * @return the clone of the texture.
  92556. */
  92557. clone(): AsciiArtFontTexture;
  92558. /**
  92559. * Parses a json object representing the texture and returns an instance of it.
  92560. * @param source the source JSON representation
  92561. * @param scene the scene to create the texture for
  92562. * @return the parsed texture
  92563. */
  92564. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  92565. }
  92566. /**
  92567. * Option available in the Ascii Art Post Process.
  92568. */
  92569. export interface IAsciiArtPostProcessOptions {
  92570. /**
  92571. * The font to use following the w3c font definition.
  92572. */
  92573. font?: string;
  92574. /**
  92575. * The character set to use in the postprocess.
  92576. */
  92577. characterSet?: string;
  92578. /**
  92579. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92580. * This number is defined between 0 and 1;
  92581. */
  92582. mixToTile?: number;
  92583. /**
  92584. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92585. * This number is defined between 0 and 1;
  92586. */
  92587. mixToNormal?: number;
  92588. }
  92589. /**
  92590. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  92591. *
  92592. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92593. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  92594. */
  92595. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  92596. /**
  92597. * The font texture used to render the char in the post process.
  92598. */
  92599. private _asciiArtFontTexture;
  92600. /**
  92601. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  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 ascii art.
  92607. * This number is defined between 0 and 1;
  92608. */
  92609. mixToNormal: number;
  92610. /**
  92611. * Instantiates a new Ascii Art Post Process.
  92612. * @param name the name to give to the postprocess
  92613. * @camera the camera to apply the post process to.
  92614. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  92615. */
  92616. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  92617. }
  92618. }
  92619. declare module BABYLON {
  92620. /** @hidden */
  92621. export var digitalrainPixelShader: {
  92622. name: string;
  92623. shader: string;
  92624. };
  92625. }
  92626. declare module BABYLON {
  92627. /**
  92628. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  92629. *
  92630. * It basically takes care rendering the font front the given font size to a texture.
  92631. * This is used later on in the postprocess.
  92632. */
  92633. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  92634. private _font;
  92635. private _text;
  92636. private _charSize;
  92637. /**
  92638. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92639. */
  92640. get charSize(): number;
  92641. /**
  92642. * Create a new instance of the Digital Rain FontTexture class
  92643. * @param name the name of the texture
  92644. * @param font the font to use, use the W3C CSS notation
  92645. * @param text the caracter set to use in the rendering.
  92646. * @param scene the scene that owns the texture
  92647. */
  92648. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92649. /**
  92650. * Gets the max char width of a font.
  92651. * @param font the font to use, use the W3C CSS notation
  92652. * @return the max char width
  92653. */
  92654. private getFontWidth;
  92655. /**
  92656. * Gets the max char height of a font.
  92657. * @param font the font to use, use the W3C CSS notation
  92658. * @return the max char height
  92659. */
  92660. private getFontHeight;
  92661. /**
  92662. * Clones the current DigitalRainFontTexture.
  92663. * @return the clone of the texture.
  92664. */
  92665. clone(): DigitalRainFontTexture;
  92666. /**
  92667. * Parses a json object representing the texture and returns an instance of it.
  92668. * @param source the source JSON representation
  92669. * @param scene the scene to create the texture for
  92670. * @return the parsed texture
  92671. */
  92672. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  92673. }
  92674. /**
  92675. * Option available in the Digital Rain Post Process.
  92676. */
  92677. export interface IDigitalRainPostProcessOptions {
  92678. /**
  92679. * The font to use following the w3c font definition.
  92680. */
  92681. font?: string;
  92682. /**
  92683. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92684. * This number is defined between 0 and 1;
  92685. */
  92686. mixToTile?: number;
  92687. /**
  92688. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92689. * This number is defined between 0 and 1;
  92690. */
  92691. mixToNormal?: number;
  92692. }
  92693. /**
  92694. * DigitalRainPostProcess helps rendering everithing in digital rain.
  92695. *
  92696. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92697. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  92698. */
  92699. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  92700. /**
  92701. * The font texture used to render the char in the post process.
  92702. */
  92703. private _digitalRainFontTexture;
  92704. /**
  92705. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92706. * This number is defined between 0 and 1;
  92707. */
  92708. mixToTile: number;
  92709. /**
  92710. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92711. * This number is defined between 0 and 1;
  92712. */
  92713. mixToNormal: number;
  92714. /**
  92715. * Instantiates a new Digital Rain Post Process.
  92716. * @param name the name to give to the postprocess
  92717. * @camera the camera to apply the post process to.
  92718. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  92719. */
  92720. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  92721. }
  92722. }
  92723. declare module BABYLON {
  92724. /** @hidden */
  92725. export var brickProceduralTexturePixelShader: {
  92726. name: string;
  92727. shader: string;
  92728. };
  92729. }
  92730. declare module BABYLON {
  92731. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  92732. private _numberOfBricksHeight;
  92733. private _numberOfBricksWidth;
  92734. private _jointColor;
  92735. private _brickColor;
  92736. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92737. updateShaderUniforms(): void;
  92738. get numberOfBricksHeight(): number;
  92739. set numberOfBricksHeight(value: number);
  92740. get numberOfBricksWidth(): number;
  92741. set numberOfBricksWidth(value: number);
  92742. get jointColor(): BABYLON.Color3;
  92743. set jointColor(value: BABYLON.Color3);
  92744. get brickColor(): BABYLON.Color3;
  92745. set brickColor(value: BABYLON.Color3);
  92746. /**
  92747. * Serializes this brick procedural texture
  92748. * @returns a serialized brick procedural texture object
  92749. */
  92750. serialize(): any;
  92751. /**
  92752. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  92753. * @param parsedTexture defines parsed texture data
  92754. * @param scene defines the current scene
  92755. * @param rootUrl defines the root URL containing brick procedural texture information
  92756. * @returns a parsed Brick Procedural BABYLON.Texture
  92757. */
  92758. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  92759. }
  92760. }
  92761. declare module BABYLON {
  92762. /** @hidden */
  92763. export var cloudProceduralTexturePixelShader: {
  92764. name: string;
  92765. shader: string;
  92766. };
  92767. }
  92768. declare module BABYLON {
  92769. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  92770. private _skyColor;
  92771. private _cloudColor;
  92772. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92773. updateShaderUniforms(): void;
  92774. get skyColor(): BABYLON.Color4;
  92775. set skyColor(value: BABYLON.Color4);
  92776. get cloudColor(): BABYLON.Color4;
  92777. set cloudColor(value: BABYLON.Color4);
  92778. /**
  92779. * Serializes this cloud procedural texture
  92780. * @returns a serialized cloud procedural texture object
  92781. */
  92782. serialize(): any;
  92783. /**
  92784. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  92785. * @param parsedTexture defines parsed texture data
  92786. * @param scene defines the current scene
  92787. * @param rootUrl defines the root URL containing cloud procedural texture information
  92788. * @returns a parsed Cloud Procedural BABYLON.Texture
  92789. */
  92790. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  92791. }
  92792. }
  92793. declare module BABYLON {
  92794. /** @hidden */
  92795. export var fireProceduralTexturePixelShader: {
  92796. name: string;
  92797. shader: string;
  92798. };
  92799. }
  92800. declare module BABYLON {
  92801. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  92802. private _time;
  92803. private _speed;
  92804. private _autoGenerateTime;
  92805. private _fireColors;
  92806. private _alphaThreshold;
  92807. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92808. updateShaderUniforms(): void;
  92809. render(useCameraPostProcess?: boolean): void;
  92810. static get PurpleFireColors(): BABYLON.Color3[];
  92811. static get GreenFireColors(): BABYLON.Color3[];
  92812. static get RedFireColors(): BABYLON.Color3[];
  92813. static get BlueFireColors(): BABYLON.Color3[];
  92814. get autoGenerateTime(): boolean;
  92815. set autoGenerateTime(value: boolean);
  92816. get fireColors(): BABYLON.Color3[];
  92817. set fireColors(value: BABYLON.Color3[]);
  92818. get time(): number;
  92819. set time(value: number);
  92820. get speed(): BABYLON.Vector2;
  92821. set speed(value: BABYLON.Vector2);
  92822. get alphaThreshold(): number;
  92823. set alphaThreshold(value: number);
  92824. /**
  92825. * Serializes this fire procedural texture
  92826. * @returns a serialized fire procedural texture object
  92827. */
  92828. serialize(): any;
  92829. /**
  92830. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  92831. * @param parsedTexture defines parsed texture data
  92832. * @param scene defines the current scene
  92833. * @param rootUrl defines the root URL containing fire procedural texture information
  92834. * @returns a parsed Fire Procedural BABYLON.Texture
  92835. */
  92836. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  92837. }
  92838. }
  92839. declare module BABYLON {
  92840. /** @hidden */
  92841. export var grassProceduralTexturePixelShader: {
  92842. name: string;
  92843. shader: string;
  92844. };
  92845. }
  92846. declare module BABYLON {
  92847. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  92848. private _grassColors;
  92849. private _groundColor;
  92850. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92851. updateShaderUniforms(): void;
  92852. get grassColors(): BABYLON.Color3[];
  92853. set grassColors(value: BABYLON.Color3[]);
  92854. get groundColor(): BABYLON.Color3;
  92855. set groundColor(value: BABYLON.Color3);
  92856. /**
  92857. * Serializes this grass procedural texture
  92858. * @returns a serialized grass procedural texture object
  92859. */
  92860. serialize(): any;
  92861. /**
  92862. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  92863. * @param parsedTexture defines parsed texture data
  92864. * @param scene defines the current scene
  92865. * @param rootUrl defines the root URL containing grass procedural texture information
  92866. * @returns a parsed Grass Procedural BABYLON.Texture
  92867. */
  92868. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  92869. }
  92870. }
  92871. declare module BABYLON {
  92872. /** @hidden */
  92873. export var marbleProceduralTexturePixelShader: {
  92874. name: string;
  92875. shader: string;
  92876. };
  92877. }
  92878. declare module BABYLON {
  92879. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  92880. private _numberOfTilesHeight;
  92881. private _numberOfTilesWidth;
  92882. private _amplitude;
  92883. private _jointColor;
  92884. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92885. updateShaderUniforms(): void;
  92886. get numberOfTilesHeight(): number;
  92887. set numberOfTilesHeight(value: number);
  92888. get amplitude(): number;
  92889. set amplitude(value: number);
  92890. get numberOfTilesWidth(): number;
  92891. set numberOfTilesWidth(value: number);
  92892. get jointColor(): BABYLON.Color3;
  92893. set jointColor(value: BABYLON.Color3);
  92894. /**
  92895. * Serializes this marble procedural texture
  92896. * @returns a serialized marble procedural texture object
  92897. */
  92898. serialize(): any;
  92899. /**
  92900. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  92901. * @param parsedTexture defines parsed texture data
  92902. * @param scene defines the current scene
  92903. * @param rootUrl defines the root URL containing marble procedural texture information
  92904. * @returns a parsed Marble Procedural BABYLON.Texture
  92905. */
  92906. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  92907. }
  92908. }
  92909. declare module BABYLON {
  92910. /** @hidden */
  92911. export var normalMapProceduralTexturePixelShader: {
  92912. name: string;
  92913. shader: string;
  92914. };
  92915. }
  92916. declare module BABYLON {
  92917. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  92918. private _baseTexture;
  92919. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92920. updateShaderUniforms(): void;
  92921. render(useCameraPostProcess?: boolean): void;
  92922. resize(size: any, generateMipMaps: any): void;
  92923. isReady(): boolean;
  92924. get baseTexture(): BABYLON.Texture;
  92925. set baseTexture(texture: BABYLON.Texture);
  92926. /**
  92927. * Serializes this normal map procedural texture
  92928. * @returns a serialized normal map procedural texture object
  92929. */
  92930. serialize(): any;
  92931. /**
  92932. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  92933. * @param parsedTexture defines parsed texture data
  92934. * @param scene defines the current scene
  92935. * @param rootUrl defines the root URL containing normal map procedural texture information
  92936. * @returns a parsed Normal Map Procedural BABYLON.Texture
  92937. */
  92938. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  92939. }
  92940. }
  92941. declare module BABYLON {
  92942. /** @hidden */
  92943. export var perlinNoiseProceduralTexturePixelShader: {
  92944. name: string;
  92945. shader: string;
  92946. };
  92947. }
  92948. declare module BABYLON {
  92949. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  92950. time: number;
  92951. timeScale: number;
  92952. translationSpeed: number;
  92953. private _currentTranslation;
  92954. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92955. updateShaderUniforms(): void;
  92956. render(useCameraPostProcess?: boolean): void;
  92957. resize(size: any, generateMipMaps: any): void;
  92958. /**
  92959. * Serializes this perlin noise procedural texture
  92960. * @returns a serialized perlin noise procedural texture object
  92961. */
  92962. serialize(): any;
  92963. /**
  92964. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  92965. * @param parsedTexture defines parsed texture data
  92966. * @param scene defines the current scene
  92967. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  92968. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  92969. */
  92970. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  92971. }
  92972. }
  92973. declare module BABYLON {
  92974. /** @hidden */
  92975. export var roadProceduralTexturePixelShader: {
  92976. name: string;
  92977. shader: string;
  92978. };
  92979. }
  92980. declare module BABYLON {
  92981. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  92982. private _roadColor;
  92983. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92984. updateShaderUniforms(): void;
  92985. get roadColor(): BABYLON.Color3;
  92986. set roadColor(value: BABYLON.Color3);
  92987. /**
  92988. * Serializes this road procedural texture
  92989. * @returns a serialized road procedural texture object
  92990. */
  92991. serialize(): any;
  92992. /**
  92993. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  92994. * @param parsedTexture defines parsed texture data
  92995. * @param scene defines the current scene
  92996. * @param rootUrl defines the root URL containing road procedural texture information
  92997. * @returns a parsed Road Procedural BABYLON.Texture
  92998. */
  92999. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  93000. }
  93001. }
  93002. declare module BABYLON {
  93003. /** @hidden */
  93004. export var starfieldProceduralTexturePixelShader: {
  93005. name: string;
  93006. shader: string;
  93007. };
  93008. }
  93009. declare module BABYLON {
  93010. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  93011. private _time;
  93012. private _alpha;
  93013. private _beta;
  93014. private _zoom;
  93015. private _formuparam;
  93016. private _stepsize;
  93017. private _tile;
  93018. private _brightness;
  93019. private _darkmatter;
  93020. private _distfading;
  93021. private _saturation;
  93022. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93023. updateShaderUniforms(): void;
  93024. get time(): number;
  93025. set time(value: number);
  93026. get alpha(): number;
  93027. set alpha(value: number);
  93028. get beta(): number;
  93029. set beta(value: number);
  93030. get formuparam(): number;
  93031. set formuparam(value: number);
  93032. get stepsize(): number;
  93033. set stepsize(value: number);
  93034. get zoom(): number;
  93035. set zoom(value: number);
  93036. get tile(): number;
  93037. set tile(value: number);
  93038. get brightness(): number;
  93039. set brightness(value: number);
  93040. get darkmatter(): number;
  93041. set darkmatter(value: number);
  93042. get distfading(): number;
  93043. set distfading(value: number);
  93044. get saturation(): number;
  93045. set saturation(value: number);
  93046. /**
  93047. * Serializes this starfield procedural texture
  93048. * @returns a serialized starfield procedural texture object
  93049. */
  93050. serialize(): any;
  93051. /**
  93052. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  93053. * @param parsedTexture defines parsed texture data
  93054. * @param scene defines the current scene
  93055. * @param rootUrl defines the root URL containing startfield procedural texture information
  93056. * @returns a parsed Starfield Procedural BABYLON.Texture
  93057. */
  93058. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  93059. }
  93060. }
  93061. declare module BABYLON {
  93062. /** @hidden */
  93063. export var woodProceduralTexturePixelShader: {
  93064. name: string;
  93065. shader: string;
  93066. };
  93067. }
  93068. declare module BABYLON {
  93069. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  93070. private _ampScale;
  93071. private _woodColor;
  93072. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93073. updateShaderUniforms(): void;
  93074. get ampScale(): number;
  93075. set ampScale(value: number);
  93076. get woodColor(): BABYLON.Color3;
  93077. set woodColor(value: BABYLON.Color3);
  93078. /**
  93079. * Serializes this wood procedural texture
  93080. * @returns a serialized wood procedural texture object
  93081. */
  93082. serialize(): any;
  93083. /**
  93084. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  93085. * @param parsedTexture defines parsed texture data
  93086. * @param scene defines the current scene
  93087. * @param rootUrl defines the root URL containing wood procedural texture information
  93088. * @returns a parsed Wood Procedural BABYLON.Texture
  93089. */
  93090. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  93091. }
  93092. }